I'm making a Chrome extension and I want to manipulate the DOM on the Home, Popular, and Subreddit pages. When I open reddit, the image I am trying to display appears, but when I click on a link to a post, subreddit, or anywhere the image does not load on the next page. If I refresh the page, it appears (until I click onto another page).
My code is in a content script and I'm using JQuery. Here is the structure of my script.
$( "<div><img src='...'></div>" ).insertBefore( $(".CLASS") );
I'm not getting any error messages, but I wonder if it has to do with how reddit loads pages. How can I get it to manipulate the DOM for every page? Any advice would help.