Skip to content Skip to sidebar Skip to footer

Content Script Only Runs Once (temporary Addon)

I made a simple temporary addon: manifest.json { 'manifest_version': 2, 'name': 'Content script test', 'version': '1.0', 'description': 'TEST', 'content_scripts': [

Solution 1:

The solution is:

content-script.js

let lastUrl = location.href; 
newMutationObserver(() => {
  const url = location.href;
  if (url !== lastUrl) {
    lastUrl = url;
    onUrlChange();
  }
}).observe(document, {subtree: true, childList: true});

functiononUrlChange() {
  console.log('*** URL changed!', location.href);
}

Post a Comment for "Content Script Only Runs Once (temporary Addon)"