To execute a function when there is a change in the URL, you can use the browser.webNavigation.onHistoryStateUpdated API. Here's how you can use it in your add-on:
"permissions": [
"webNavigation"
]
browser.webNavigation.onHistoryStateUpdated.addListener(function(details) {
// execute your function here
});
The details
parameter contains information about the navigation event, including the new URL. You can use this information to determine if your function should be executed.
Note that this event fires when the user navigates forward or backward, as well as when navigating between pages using links or the address bar.
Asked: 2023-05-06 21:12:37 +0000
Seen: 10 times
Last updated: May 06 '23