Skip to content

Commit

Permalink
Merge branch 'whitelist-fingerprinting' of https://github.com/EFForg/…
Browse files Browse the repository at this point in the history
…privacybadger into whitelist-fingerprinting
  • Loading branch information
alexristich committed Apr 14, 2018
2 parents 23dde3a + 7053026 commit c005ae7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 32 deletions.
3 changes: 2 additions & 1 deletion src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function Badger() {
self.heuristicBlocking = new HeuristicBlocking.HeuristicBlocker(thisStorage);
self.updateTabList();
self.initializeDefaultSettings();
self.registerContentScripts();
try {
self.runMigrations();
} finally {
Expand Down Expand Up @@ -694,6 +695,7 @@ Badger.prototype = {
if (disabledSites.indexOf(origin) < 0) {
disabledSites.push(origin);
settings.setItem("disabledSites", disabledSites);
this.registerContentScripts();
}
},

Expand Down Expand Up @@ -768,7 +770,6 @@ Badger.prototype = {
}

const registerActive = browser.contentScripts.register(activeScripts);
// TODO socialwidgets.js should only be loaded if widget replacement is enabled.
const registerIdle = browser.contentScripts.register(idleScripts);

registerActive.then((res) => {badger.activeContentScripts = res;});
Expand Down
39 changes: 16 additions & 23 deletions src/js/contentscripts/fingerprinting.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,27 +320,20 @@ function insertFpScript(text, data) {
parent.removeChild(script);
}

// TODO race condition; fix waiting on https://crbug.com/478183
chrome.runtime.sendMessage({checkEnabled: true},
function (enabled) {
if (!enabled) {
return;
}
/**
* Communicating to webrequest.js
*/
var event_id = Math.random();

// listen for messages from the script we are about to insert
document.addEventListener(event_id, function (e) {
// pass these on to the background page
chrome.runtime.sendMessage({
'fpReport': e.detail
});
});
/**
* Communicating to webrequest.js
*/
var event_id = Math.random();

// listen for messages from the script we are about to insert
document.addEventListener(event_id, function (e) {
// pass these on to the background page
chrome.runtime.sendMessage({
'fpReport': e.detail
});
});

insertFpScript(getFpPageScript(), {
event_id: event_id
});

insertFpScript(getFpPageScript(), {
event_id: event_id
});
}
);
9 changes: 1 addition & 8 deletions src/js/contentscripts/socialwidgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,4 @@ function unblockTracker(buttonUrls, callback) {
chrome.runtime.sendMessage(request, callback);
}

chrome.runtime.sendMessage({
checkSocialWidgetReplacementEnabled: true
}, function (checkSocialWidgetReplacementEnabled) {
if (!checkSocialWidgetReplacementEnabled) {
return;
}
initialize();
});
initialize();
1 change: 1 addition & 0 deletions src/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ function updateSocialWidgetReplacement() {
socialWidgetReplacementEnabled: enabled
}
});
badger.registerContentScripts();
}

function updateCheckingDNTPolicy() {
Expand Down
2 changes: 2 additions & 0 deletions src/js/webrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ 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);
}

Expand Down

0 comments on commit c005ae7

Please sign in to comment.