chrome.tabs.onUpdated.addListener is getting complete status twice or more for each page

后端 未结 1 1403
醉梦人生
醉梦人生 2021-02-20 18:52

Here is my Script, which uses onUpdated.addListener to check each url:

chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {          
 alert(cha         


        
相关标签:
1条回答
  • 2021-02-20 19:08

    This was a known bug in Chrome Issue 162543 which was marked as fixed on 2012-12-05.

    Workaround: (not needed anymore)

    Make Event Page to Background Page by changing code from

    "background": {
        "scripts": ["js/eventPage.js"],
        "persistent": false
      },
    

    to

    "background": {
        "scripts": ["js/eventPage.js"],
        "persistent": true
      },
    

    and moving ahead by using background pages for development till the fix is delivered.

    Other Points:

    After a look at your manifest.json why does

    "background": {
        "scripts": ["js/eventPage.js"],
        "persistent": false
      },
      "content_scripts": [
        {
          "matches": ["http://*/*"],
          "js": ["js/eventPage.js"]
        }
      ],
    

    js/eventPage.js is made content script as well as background\event script; Having code for chrome.tabs.onUpdated.addListener() will not work in content scripts at all, please eliminate this code

    Let me know if you need more information.

    0 讨论(0)
提交回复
热议问题