Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable sending the Do Not Track (DNT) signal #2089

Merged
merged 6 commits into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/_locales/en_US/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"message": "Currently Privacy Badger only checks if third parties are using cookies, HTML5 local storage, or canvas fingerprinting to track your browsing. Some of these domains may be using tracking methods that Privacy Badger can't detect.",
"description": ""
},
"options_enable_dnt_checkbox": {
"message": "Send the <a href='https://www.eff.org/issues/do-not-track' target='_blank'>Do Not Track</a> signal",
"description": "Checkbox label for enabling/disabling the Do Not Track signal, found on the general settings page"
},
"options_dnt_policy_setting": {
"message": "Check if sites comply with EFF's Do Not Track policy",
"description": "Checkbox label on the general settings page"
Expand Down Expand Up @@ -439,4 +443,4 @@
"message": "Oops. Something went wrong.",
"description": ""
}
}
}
10 changes: 9 additions & 1 deletion src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,10 @@ Badger.prototype = {
learnInIncognito: false,
migrationLevel: 0,
seenComic: false,
sendDNTSignal: true,
showCounter: true,
showTrackingDomains: false,
socialWidgetReplacementEnabled: true,
socialWidgetReplacementEnabled: true
},

/**
Expand Down Expand Up @@ -612,6 +613,13 @@ Badger.prototype = {
return this.getSettings().getItem("socialWidgetReplacementEnabled");
},

/**
* Check if social widget replacement functionality is enabled
*/
isDNTSignalEnabled: function() {
return this.getSettings().getItem("sendDNTSignal");
},

isCheckingDNTPolicyEnabled: function() {
return this.getSettings().getItem("checkForDNTPolicy");
},
Expand Down
2 changes: 1 addition & 1 deletion src/js/contentscripts/dnt.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if (document instanceof HTMLDocument === false && (

// TODO race condition; fix waiting on https://crbug.com/478183
chrome.runtime.sendMessage({
checkEnabled: true
checkDNT: true
}, function (enabled) {
if (enabled) {
insertPageScript(getPageScript());
Expand Down
21 changes: 20 additions & 1 deletion src/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ function loadOptions() {
$("#show_counter_checkbox").prop("checked", badger.showCounter());
$("#replace_social_widgets_checkbox").on("click", updateSocialWidgetReplacement);
$("#replace_social_widgets_checkbox").prop("checked", badger.isSocialWidgetReplacementEnabled());
$("#enable_dnt_checkbox").on("click", updateDNTCheckboxClicked);
$("#enable_dnt_checkbox").prop("checked", badger.isDNTSignalEnabled());
$("#check_dnt_policy_checkbox").on("click", updateCheckingDNTPolicy);
$("#check_dnt_policy_checkbox").prop("checked", badger.isCheckingDNTPolicyEnabled());
$("#check_dnt_policy_checkbox").prop("checked", badger.isCheckingDNTPolicyEnabled()).prop("disabled", !badger.isDNTSignalEnabled());

if (badger.webRTCAvailable) {
$("#toggle_webrtc_mode").on("click", toggleWebRTCIPProtection);
Expand Down Expand Up @@ -316,6 +318,23 @@ function updateSocialWidgetReplacement() {
});
}

/**
* Update DNT checkbox clicked
*/
function updateDNTCheckboxClicked() {
const enabled = $("#enable_dnt_checkbox").prop("checked");

chrome.runtime.sendMessage({
type: "updateSettings",
data: {
sendDNTSignal: enabled
}
});

$("#check_dnt_policy_checkbox").prop("checked", enabled).prop("disabled", !enabled);
updateCheckingDNTPolicy();
}

function updateCheckingDNTPolicy() {
const enabled = $("#check_dnt_policy_checkbox").prop("checked");

Expand Down
21 changes: 18 additions & 3 deletions src/js/webrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ function onBeforeSendHeaders(details) {
if (!isThirdPartyDomain(requestDomain, tabDomain)) {
if (badger.isPrivacyBadgerEnabled(tabDomain)) {
// Still sending Do Not Track even if HTTP and cookie blocking are disabled
details.requestHeaders.push({name: "DNT", value: "1"});
if (badger.isDNTSignalEnabled()) {
details.requestHeaders.push({name: "DNT", value: "1"});
}
return {requestHeaders: details.requestHeaders};
} else {
return {};
Expand Down Expand Up @@ -233,13 +235,17 @@ function onBeforeSendHeaders(details) {
let newHeaders = details.requestHeaders.filter(function (header) {
return (header.name.toLowerCase() != "cookie" && header.name.toLowerCase() != "referer");
});
newHeaders.push({name: "DNT", value: "1"});
if (badger.isDNTSignalEnabled()) {
newHeaders.push({name: "DNT", value: "1"});
}
return {requestHeaders: newHeaders};
}

// if we are here, we're looking at a third party
// that's not yet blocked or cookieblocked
details.requestHeaders.push({name: "DNT", value: "1"});
if (badger.isDNTSignalEnabled()) {
details.requestHeaders.push({name: "DNT", value: "1"});
}
return {requestHeaders: details.requestHeaders};
}

Expand Down Expand Up @@ -776,6 +782,15 @@ function dispatcher(request, sender, sendResponse) {
badger.storage.getBadgerStorageObject("action_map").deleteItem(request.origin);

sendResponse();

} else if (request.checkDNT) {
// called from contentscripts/dnt.js to check if we should enable it
sendResponse(
badger.isDNTSignalEnabled()
&& badger.isPrivacyBadgerEnabled(
window.extractHostFromURL(sender.tab.url)
)
);
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/skin/options-layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ button
margin: 12px 0;
}

#check_dnt_policy_row {
position: relative;
left: 25px;
}

a, a:hover, a:active, a:visited{
color: #00aaaa;
text-decoration: underline;
Expand Down
6 changes: 6 additions & 0 deletions src/skin/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ <h1><span class="i18n_options_title"></span></h1>
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" id="enable_dnt_checkbox">
<span class="i18n_options_enable_dnt_checkbox"></span>
</label>
</div>
<div class="checkbox" id="check_dnt_policy_row">
<label>
<input type="checkbox" id="check_dnt_policy_checkbox">
<span class="i18n_options_dnt_policy_setting"></span>
Expand Down