I've been developing a cross-browser extension (for Chrome, Firefox, Opera, etc) that runs a script every time the user goes to a new page on Youtube. Since Youtube uses the History API's pushState to navigate to a new page, injecting the script declaratively only works when a page is reloaded or the URL is explicitly entered into the address bar. To get around this, I used onHistoryStateUpdated from the webNavigation API to inject the script programmatically (as explained here).
manifest.json:
...
"permissions": ["webNavigation", "https://*.youtube.com/*"]
...
background.js:
chrome.webNavigation.onHistoryStateUpdated.addListener(function(details) {
chrome.tabs.executeScript(details.tabId, {file: "/content.js"});
}
I want to port my extension to Safari, but according to their documentation, onHistoryStateUpdated is not supported. Are there any alternative ways to detect changes for pushState in Safari?
P.S. I hope I'm explaining this well enough, since this is my first question on Stack Exchange. Thanks so much in advance!