diff --git a/src/js/background.js b/src/js/background.js index dd9710bd3b..392f0924ce 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -801,9 +801,9 @@ Badger.prototype = { return; } - var executeScriptCallback = function() { + var noop = function() { if (chrome.runtime.lastError) { - // Do nothing + // // Do nothing } }; @@ -813,29 +813,29 @@ Badger.prototype = { 'file': '/js/contentscripts/fingerprinting.js', 'frameId': frame_id, 'runAt': 'document_start' - }, executeScriptCallback); + }, noop); chrome.tabs.executeScript(tab_id, { 'file': '/js/contentscripts/clobbercookie.js', 'frameId': frame_id, 'runAt': 'document_start' - }, executeScriptCallback); + }, noop); chrome.tabs.executeScript(tab_id, { 'file': '/js/contentscripts/clobberlocalstorage.js', 'frameId': frame_id, 'runAt': 'document_start' - }, executeScriptCallback); + }, noop); chrome.tabs.executeScript(tab_id, { 'file': '/js/contentscripts/supercookie.js', 'frameId': frame_id, 'runAt': 'document_idle' - }, executeScriptCallback); + }, noop); if (this.isSocialWidgetReplacementEnabled()) { chrome.tabs.executeScript(tab_id, { 'file': '/js/contentscripts/socialwidgets.js', 'frameId': frame_id, 'runAt': 'document_start' - }, executeScriptCallback); + }, noop); } }, diff --git a/src/js/contentscripts/fingerprinting.js b/src/js/contentscripts/fingerprinting.js index 95afec2358..7578949822 100644 --- a/src/js/contentscripts/fingerprinting.js +++ b/src/js/contentscripts/fingerprinting.js @@ -19,8 +19,6 @@ */ function getFpPageScript() { - - console.log('inserting fp script'); // code below is not a content script: no chrome.* APIs ///////////////////// // return a string diff --git a/src/js/contentscripts/socialwidgets.js b/src/js/contentscripts/socialwidgets.js index 311e6d1fda..803a556c32 100644 --- a/src/js/contentscripts/socialwidgets.js +++ b/src/js/contentscripts/socialwidgets.js @@ -55,7 +55,6 @@ let i18n = chrome.i18n; * Initializes the content script. */ function initialize() { - console.info('insert social widget script'); // Get tracker info and check for initial blocks (that happened // before content script was attached) getTrackerData(function (trackers, trackerButtonsToReplace) { diff --git a/src/js/webrequest.js b/src/js/webrequest.js index 2c18744251..426210fdd8 100644 --- a/src/js/webrequest.js +++ b/src/js/webrequest.js @@ -40,6 +40,16 @@ var temporarySocialWidgetUnblock = {}; /***************** Blocking Listener Functions **************/ +function injectScripts(details) { + var frame_id = details.frameId, + tab_id = details.tabId, + url = details.url; + + if (!_isTabChromeInternal(tab_id)) { + badger.insertContentScripts(tab_id, url, frame_id); + } +} + /** * Event handling of http requests, main logic to collect data what to block * @@ -63,14 +73,12 @@ function onBeforeRequest(details) { frame_id = 0; } - badger.insertContentScripts(tab_id, url, frame_id, is_internal); badger.recordFrame(tab_id, frame_id, details.parentFrameId, url); return {}; } if (type == "sub_frame") { - badger.insertContentScripts(tab_id, url, frame_id, is_internal); badger.recordFrame(tab_id, frame_id, details.parentFrameId, url); } @@ -708,6 +716,7 @@ function startListeners() { chrome.webRequest.onBeforeRequest.addListener(onBeforeRequest, {urls: ["http://*/*", "https://*/*"]}, ["blocking"]); chrome.webRequest.onBeforeSendHeaders.addListener(onBeforeSendHeaders, {urls: ["http://*/*", "https://*/*"]}, ["requestHeaders", "blocking"]); chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: [""]}, ["responseHeaders", "blocking"]); + chrome.webNavigation.onCommitted.addListener(injectScripts); chrome.tabs.onRemoved.addListener(onTabRemoved); chrome.tabs.onReplaced.addListener(onTabReplaced); chrome.runtime.onMessage.addListener(dispatcher);