1

I'm writing a Chrome extension for Twitter that runs fine when I load any twitter page by putting in the URL manually, or when I refresh a twitter page. However, often (though not always) it will not run when I am navigating within twitter. For example, often if I click on someone's profile, the extension doesn't run. But if I refresh the page (still on the profile page) it will run.

I feel like it might be related to this question, Chrome extension is not loading on browser navigation at YouTube, but I'm exactly sure how.

I can tell that it's not running (as opposed to not working in some other way) because I have log a bunch of stuff to the console whenever it runs.

Here is my manifest:

{
  "name": "Twitter Extend",
  "version": "1.0",
  "description": "A sea of white space",
  "permissions": ["tabs", "<all_urls>"],
  "content_scripts": [
   {
     "matches": ["http://*.twitter.com/*", "https://*.twitter.com/*"],
     "js": ["main.js"]
   }
 ],
  "manifest_version": 2
}
oregano
  • 816
  • 9
  • 25
  • 1
    See this answer: [Is there a JavaScript/jQuery DOM change listener?](//stackoverflow.com/a/39508954) – wOxxOm Aug 04 '18 at 17:45
  • Just to make sure, is the page actually reloading? Twitter sometimes relies content dynamically without actually reloading the page. This could explain the lack of logging. When I click on a Twitter profile from the feed, there is no page load. – BrotherDonkey Aug 04 '18 at 18:18
  • I suspect it's not actually reloading. (It seems weird to change the url without reloading, but what do I know.) The "Cloaking History API inside an injected DOM script" from @wOxxOm 's answer catches it, but now I'm struggling to get the script to run on the page correctly from within the event listener. – oregano Aug 04 '18 at 22:21

0 Answers0