Although there are a lot of similar questions here, I couldn't solve my problem with any of the accepted solutions, so I'm creating a new question.
I have a content script that adds some functionality to a Jira Issue. However, when navigating to the Jira Issue from a Filter Results Page, the content script doesn't run until I manually reload the page.
What I've tried so far:
- Adding webNavigation Listeners (with the manifest permission), but none of them seem to trigger when the Jira Issue link is clicked from the Filter Page.
// background.js
const myLog = () => console.log('webNavigation event triggered');
browser.webNavigation.onDOMContentLoaded.addListener(myLog);
browser.webNavigation.onHistoryStateUpdated.addListener(myLog);
browser.webNavigation.onReferenceFragmentUpdated.addListener(myLog);
- Adding "all_frames": true to the manifest.json, but that didn't make it work either:
// manifest.json
...
"background": {
"scripts": ["background.js"],
"persistent": false
},
"content_scripts": [
{
"matches": ["*://jira.atlassian.com/*"],
"js": ["content.js"],
"all_frames": true
}
],
"permissions": ["tabs", "webNavigation", "<all_urls>"]
- Listening to window.onpopstate event inside the content script. Although it detects when I click the "Back" and "Forward" arrows in the browser, it doesn't fire when I click the links inside the Filter Results Page.
// content.js
window.onpopstate = () => {
browser.runtime.sendMessage('webNavigation event triggered');
}
How can I run this content script without having to manually reload the page?