javascript - Adding an image next to text if the text links to a certain page -
so i've been working on chrome extension changes fonts , color scheme of website. decided kind of cool easter-eggy type thing cool if chrome extension's logo showed next name when posted on site's forums.
what best way of doing this? i'm able inject css , js site. thinking script looks tag links profile page, , adds icon right of or something. have no experience javascript appreciated.
thanks, erik
var x = document.queryselectorall("a"); for(var i=0;i<x.length;i++){ if(x[i].href.indexof('link_to_your_profile')==-1) // skip if link not link profile continue var node = document.createelement("img"); node.src = "http://via.placeholder.com/350x150"; x[i].appendchild(node); }
try code
it search anchor tags , add them array "x" , loops on array , creates new img node , adds next tag. have change img src of course!
hope answer looking for!
Comments
Post a Comment