I’m making a Google Chrome extension. My extension currently extends the content area and header to make room for another icon in the jewel container (where notifications and friend requests are) and adds the icon. It works fine when the page is first loaded, but when you go to a different page on the site and then back home the layout gets screwed up.
Since this isn’t an issue with code (as it works fine the first time the page is loaded), I’d like to know if there’s a way to run a content script every single time a page is loaded. Is this possible, or can I inject the Javascript I have into Facebook every time it loads with a different method?
I’ve found a way around this by using
setInterval()to run the code (or at least the code that wasn’t always running) every millisecond.Apparently, unless I misunderstood, Chrome runs the code once per browser session, so using
setInterval()is the best alternative. Though, the strange behavior was that Chrome was running part of my code once, and then wasn’t after that unless certain circumstances were met.setInterval()worked wonders in this case, though.