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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -