Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
thewickedkarma
GitHub Repository: thewickedkarma/blackeye-im
Path: blob/master/sites/bitcoin/js/dnt.js
777 views
1
/*
2
* This file is part of Privacy Badger <https://www.eff.org/privacybadger>
3
* Copyright (C) 2018 Electronic Frontier Foundation
4
*
5
* Privacy Badger is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 3 as
7
* published by the Free Software Foundation.
8
*
9
* Privacy Badger is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with Privacy Badger. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
function getPageScript() {
19
20
// code below is not a content script: no chrome.* APIs /////////////////////
21
22
// return a string
23
return "(" + function (NAVIGATOR, OBJECT) {
24
25
OBJECT.defineProperty(OBJECT.getPrototypeOf(NAVIGATOR), "doNotTrack", {
26
get: () => {
27
return "1";
28
}
29
});
30
31
// save locally to keep from getting overwritten by site code
32
} + "(window.navigator, Object));";
33
34
// code above is not a content script: no chrome.* APIs /////////////////////
35
36
}
37
38
/**
39
* Executes a script in the page DOM context
40
*/
41
function insertPageScript(text) {
42
var parent = document.documentElement,
43
script = document.createElement('script');
44
45
script.text = text;
46
script.async = false;
47
48
parent.insertBefore(script, parent.firstChild);
49
parent.removeChild(script);
50
}
51
52
// END FUNCTION DEFINITIONS ///////////////////////////////////////////////////
53
54
(function () {
55
56
// don't inject into non-HTML documents (such as XML documents)
57
// but do inject into XHTML documents
58
if (document instanceof HTMLDocument === false && (
59
document instanceof XMLDocument === false ||
60
document.createElement('div') instanceof HTMLDivElement === false
61
)) {
62
return;
63
}
64
65
// TODO race condition; fix waiting on https://crbug.com/478183
66
chrome.runtime.sendMessage({
67
checkEnabled: true
68
}, function (enabled) {
69
if (enabled) {
70
insertPageScript(getPageScript());
71
}
72
});
73
74
}());
75
76