diff --git a/core/interceptor.js b/core/interceptor.js index 17ae2c89b81c75b18ee7152a8b987f15a1ad09e3..78cb9aedde064060516264e197d23ec74ed16432 100644 --- a/core/interceptor.js +++ b/core/interceptor.js @@ -29,11 +29,11 @@ const HTTP_EXPRESSION = /^http?:\/\//; * Public Methods */ -interceptor.handleRequest = function (requestDetails, tabIdentifier, tabUrl) { +interceptor.handleRequest = function (requestDetails, tabIdentifier, tab) { - let validCandidate, targetDetails, targetPath, amountInjected; + let validCandidate, targetDetails, targetPath; - validCandidate = requestAnalyzer.isValidCandidate(requestDetails, tabUrl); + validCandidate = requestAnalyzer.isValidCandidate(requestDetails, tab); if (!validCandidate) { diff --git a/core/state-manager.js b/core/state-manager.js index b8675ff5aa6c3c562677fe34d0400d231d6dfb93..58bddafe1d841252bf7d88dc3bb69c69560ce9ff 100644 --- a/core/state-manager.js +++ b/core/state-manager.js @@ -111,13 +111,22 @@ stateManager._removeTab = function (tabIdentifier) { stateManager._updateTab = function (details) { - let tabIdentifier = details.tabId; + let tabIdentifier, frameIdentifier; - if (tabIdentifier !== -1) { + tabIdentifier = details.tabId; + frameIdentifier = details.frameId; - if (stateManager.tabs[tabIdentifier]) { - stateManager.tabs[tabIdentifier].injections = {}; - } + if (tabIdentifier === -1 || frameIdentifier !== 0) { + return; + } + + chrome.browserAction.setBadgeText({ + tabId: tabIdentifier, + text: '' + }); + + if (stateManager.tabs[tabIdentifier]) { + stateManager.tabs[tabIdentifier].injections = {}; } }; @@ -157,8 +166,8 @@ chrome.tabs.query({}, function (tabs) { chrome.tabs.onCreated.addListener(stateManager._createTab); chrome.tabs.onRemoved.addListener(stateManager._removeTab); -chrome.webRequest.onBeforeRequest.addListener(stateManager._updateTab, { - urls: ['<all_urls>'], types: ['main_frame'] +chrome.webNavigation.onCommitted.addListener(stateManager._updateTab, { + url: [{urlContains: ':'}] }); chrome.webRequest.onErrorOccurred.addListener(function (requestDetails) { diff --git a/manifest.json b/manifest.json index a79f948ca1eff8f32a2f1aa807661293fb0198cb..c5387e288a8bf08cf571e5e25f98b969a4134af1 100644 --- a/manifest.json +++ b/manifest.json @@ -20,6 +20,7 @@ "privacy", "storage", "tabs", + "webNavigation", "webRequest", "webRequestBlocking" ],