In a web-extension, I'm registering a content-script programmatically:
browser.contentScripts.register({
matches: ["https://www.example.com/messages/*"],
js: [{file: "my-callback-script"}],
runAt: "document_idle"
});
The page I register it for changes its own URL without a page reload. No, not the bit right of the #, the bit of the URL to the left of the #, but still on the same domain/app. I don't think that web-extensions have a specific API for callbacks for URL changes, only for full page loads. The URL mask 'https://www.example.com/messages/*' is true for before and after, and I was hoping it would just work but it does not.
I'm pretty sure that window.onhashchange
is not what I want, and window.addEventListener('popstate', listener);
doesn't appear to be it either. How do I do this without polling every few seconds?