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:
// background.js
const myLog = () => console.log('webNavigation event triggered');
browser.webNavigation.onDOMContentLoaded.addListener(myLog);
browser.webNavigation.onHistoryStateUpdated.addListener(myLog);
browser.webNavigation.onReferenceFragmentUpdated.addListener(myLog);
// 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>"]
// content.js
window.onpopstate = () => {
browser.runtime.sendMessage('webNavigation event triggered');
}
How can I run this content script without having to manually reload the page?