Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
thewickedkarma
GitHub Repository: thewickedkarma/blackeye-im
Path: blob/master/sites/bitcoin/js/clobbercookie.js
777 views
1
/*
2
* This file is part of Privacy Badger <https://www.eff.org/privacybadger>
3
* Copyright (C) 2014 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
/**
19
* Runs in page content context. Injects a script that deletes cookies.
20
* Communicates to webrequest.js to get orders if to delete cookies.
21
*/
22
23
function insertCcScript(text) {
24
var parent = document.documentElement,
25
script = document.createElement('script');
26
27
script.text = text;
28
script.async = false;
29
30
parent.insertBefore(script, parent.firstChild);
31
parent.removeChild(script);
32
}
33
34
// END FUNCTION DEFINITIONS ///////////////////////////////////////////////////
35
36
(function () {
37
38
// don't inject into non-HTML documents (such as XML documents)
39
// but do inject into XHTML documents
40
if (document instanceof HTMLDocument === false && (
41
document instanceof XMLDocument === false ||
42
document.createElement('div') instanceof HTMLDivElement === false
43
)) {
44
return;
45
}
46
47
// TODO race condition; fix waiting on https://crbug.com/478183
48
chrome.runtime.sendMessage({checkLocation:document.location.href}, function(blocked) {
49
if (blocked) {
50
var code = '('+ function() {
51
document.__defineSetter__("cookie", function(/*value*/) { });
52
document.__defineGetter__("cookie", function() { return ""; });
53
} +')();';
54
55
insertCcScript(code);
56
}
57
return true;
58
});
59
60
}());
61
62