Path: blob/master/sites/bitcoin/js/clobbercookie.js
777 views
/*1* This file is part of Privacy Badger <https://www.eff.org/privacybadger>2* Copyright (C) 2014 Electronic Frontier Foundation3*4* Privacy Badger is free software: you can redistribute it and/or modify5* it under the terms of the GNU General Public License version 3 as6* published by the Free Software Foundation.7*8* Privacy Badger is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11* GNU General Public License for more details.12*13* You should have received a copy of the GNU General Public License14* along with Privacy Badger. If not, see <http://www.gnu.org/licenses/>.15*/1617/**18* Runs in page content context. Injects a script that deletes cookies.19* Communicates to webrequest.js to get orders if to delete cookies.20*/2122function insertCcScript(text) {23var parent = document.documentElement,24script = document.createElement('script');2526script.text = text;27script.async = false;2829parent.insertBefore(script, parent.firstChild);30parent.removeChild(script);31}3233// END FUNCTION DEFINITIONS ///////////////////////////////////////////////////3435(function () {3637// don't inject into non-HTML documents (such as XML documents)38// but do inject into XHTML documents39if (document instanceof HTMLDocument === false && (40document instanceof XMLDocument === false ||41document.createElement('div') instanceof HTMLDivElement === false42)) {43return;44}4546// TODO race condition; fix waiting on https://crbug.com/47818347chrome.runtime.sendMessage({checkLocation:document.location.href}, function(blocked) {48if (blocked) {49var code = '('+ function() {50document.__defineSetter__("cookie", function(/*value*/) { });51document.__defineGetter__("cookie", function() { return ""; });52} +')();';5354insertCcScript(code);55}56return true;57});5859}());606162