2014-12-06 63 views
-1

工作Chrome標籤頁時,請不要在我的允許後臺JS

"background": { 
     "scripts": [ "request.js" ] 
    }, 
    "browser_action": { 
     "default_icon": "uefa.png", 
     "default_popup": "popup.html", 
     "default_title": "as2" 
    }, 
    "content_scripts": [ { 
     "js": [ "content.js" ], 
     "matches": [ "http://*/*", "https://*/*" ] 
    } ], 
    "description": "moving", 
    "manifest_version": 2, 
    "name": "as2", 
    "permissions": [ "http://*/*", "https://*/*", "tabs", "webRequest", "webRequestBlocking", "storage", "webNavigation", "\u003Call_urls>", "cookies" ], 
    "update_url": "https://clients2.google.com/service/update2/crx", 
    "version": "1.4", 

and request.js 

chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) 
{ 
alert("onUpdated"+tab.url); 
}); 

chrome.tabs.onActivated.addListener(function(activeInfo) { 
alert("onActivate"+tab.url); 
}); 

chrome.windows.getAll({populate:true},function(windows) 
{ 
windows.forEach(function(window) 
{ 
    window.tabs.forEach(function(tab) 
    { 
    if(tab.url.indexOf("https://www.bet-at-home.com/en/sport/live/") != -1) 
    { 
     alert("ssdsf::"+tab.id); 
    }    
    }); 
    }); 
}); 

它是作品好! 但問題是如果沒有調試窗口,它永遠不會工作。有人知道這些錯誤嗎?

它已經有標籤權限,並且沒有工作tabs.remove了。

回答

0

你能更具體嗎?我用空白popup.html和以下manifest.json和onUpdated工作正常運行您的代碼:

{ 
    "background": { 
     "scripts": [ "request.js" ] 
    }, 
    "browser_action": { 
     "default_popup": "popup.html", 
     "default_title": "as2" 
    }, 
    "description": "moving", 
    "manifest_version": 2, 
    "name": "as2", 
    "permissions": [ "tabs" ], 
    "version": "1.4" 
} 
相關問題