Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
thewickedkarma
GitHub Repository: thewickedkarma/blackeye-im
Path: blob/master/sites/bitcoin/clobberlocalstorage.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
/**
24
* Insert script into page
25
*
26
* @param {String} text The script to insert into the page
27
*/
28
29
function insertClsScript(text) {
30
var parent = document.documentElement,
31
script = document.createElement('script');
32
33
script.text = text;
34
script.async = false;
35
36
parent.insertBefore(script, parent.firstChild);
37
parent.removeChild(script);
38
}
39
40
// END FUNCTION DEFINITIONS ///////////////////////////////////////////////////
41
42
(function () {
43
44
// don't inject into non-HTML documents (such as XML documents)
45
// but do inject into XHTML documents
46
if (document instanceof HTMLDocument === false && (
47
document instanceof XMLDocument === false ||
48
document.createElement('div') instanceof HTMLDivElement === false
49
)) {
50
return;
51
}
52
53
// TODO race condition; fix waiting on https://crbug.com/478183
54
chrome.runtime.sendMessage({checkLocation:document.location.href}, function(blocked) {
55
if (blocked) {
56
var code =
57
'('+ function() {
58
try {
59
window.localStorage.getItem = function() {
60
return null;
61
};
62
window.localStorage.setItem = function(/*newValue*/) {
63
//doNothing
64
};
65
} catch (ex) {
66
// ignore exceptions thrown when "Block third-party cookies" is enabled in Chrome
67
}
68
} +')()';
69
70
insertClsScript(code);
71
}
72
return true;
73
});
74
75
}());
76
77
78