From 30407e71a07ec9d74a02237f61576cf7c77f55e5 Mon Sep 17 00:00:00 2001 From: kkapsner Date: Wed, 22 Apr 2015 11:18:26 +0200 Subject: [PATCH] Added fake for readPixels and removed new tab bug Bug description: if a new tab is opened the wrong blockmode could be used. --- canvasblocker.xpi | Bin 26382 -> 27189 bytes data/inject.js | 87 +++++++++++++++++++++------------ lib/main.js | 106 +++++++++-------------------------------- lib/sharedFunctions.js | 89 ++++++++++++++++++++++++++++++++++ 4 files changed, 169 insertions(+), 113 deletions(-) create mode 100644 lib/sharedFunctions.js diff --git a/canvasblocker.xpi b/canvasblocker.xpi index b7de47aa28abd57ed1c3175f7a7a212ef9b66d07..12b26bf8d3fc3e4285b6c5eec9ab6e9a3ee42139 100644 GIT binary patch delta 6832 zcmZXZWl$VUv$hu}I0T2_?(Xg^EFL_#v*-fB7kAB)#RCK!2@5O z=d1Uedh5)eo~i2U>HafUPv0q1NQea_TpbM*RAK-CfC(@+fq%hGq(%8_8**u>kpJDZ z(tl$klr({>#CALB^tpAgHOd--W*kljRAouhU{C=<8`GyTH8F2@a^%cPv<8rFDBTxKdJ z*?Fl9xve5EO5n;c#lwi4)6s6t!UueZ0!DE4LJIsHcqwmWr9&4IT}Cm9#teia9B<#M zqG4)PcI0SyD-l$&k_8KwDI>Xhgx#l2IMGv_fK{#sO14)|DS*Q?*@D6c?`>{eoJa#n zxOeOpz)JBJnF&>`vL`Y`Cd1Ks6bix& z4gS@{NZ=xziN3pjBCppZ_tPi#TyYd);`P>GvpMk` ztKkV@rQRy>+gU>KVwdzOtSMz^u)o}gY)6R9S!86VnAlP3dgZ7o|5c>ggQ~|6TD+HZ zEFzLH_|GK6(AIRy2)1IK<5X`SiNBGswqr!*E*c5B{I{@3o?rd4&@Isg(IEu`ZjOGm zT6dcU>}Pb8`V!ql&uHZO7bg zTLMQdEmkaSSDdC5lGW>lqfHu1#ll%16$k!W7=d5(xN0E4QLhX>+hE*O7)pw_LY_Rctcp^zteE zTe-4qit<-;O$W3%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&^TVTr_mup?Jo2wDI0g#rG3%>U}jEs+GS%%oHR PD!|S^KaSk?U#tHDHLa_n diff --git a/data/inject.js b/data/inject.js index 7112e2d..f5c6fbd 100644 --- a/data/inject.js +++ b/data/inject.js @@ -171,7 +171,15 @@ }, readPixels: { mode: blockMode.readAPI, - object: unsafeWindow.WebGLRenderingContext + object: unsafeWindow.WebGLRenderingContext, + fake: function(x, y, width, height, format, type, pixels){ + // fake not working due to XRay copy restrictions... + // for (var i = 0; i < pixels.length; i += 1){ + // pixels[i] = Math.floor( + // Math.random() * 256 + // ); + // } + } } }; @@ -253,37 +261,56 @@ // Communication with main.js - self.port.on("block", function(){ - blockMode.getContext.status = "block"; - blockMode.readAPI.status = "allow"; - }); - self.port.on("ask", function(askOnce){ - blockMode.getContext.status = "ask"; - blockMode.getContext.askStatus.askOnce = askOnce; - blockMode.readAPI.status = "allow"; - }); - self.port.on("blockReadout", function(){ - blockMode.getContext.status = "allow"; - blockMode.readAPI.status = "block"; - }); - self.port.on("fakeReadout", function(){ - blockMode.getContext.status = "allow"; - blockMode.readAPI.status = "fake"; - }); - self.port.on("askReadout", function(askOnce){ - blockMode.getContext.status = "allow"; - blockMode.readAPI.status = "ask"; - blockMode.readAPI.askStatus.askOnce = askOnce; - }); - self.port.on("unblock", function(){ - blockMode.getContext.status = "allow"; - blockMode.readAPI.status = "allow"; - }); - self.port.on("detach", function(){ - blockMode.getContext.status = "allow"; - blockMode.readAPI.status = "allow"; + function setStatus(mode, askOnce){ + switch (mode){ + case "block": + blockMode.getContext.status = "block"; + blockMode.readAPI.status = "allow"; + break; + case "ask": + blockMode.getContext.status = "ask"; + blockMode.getContext.askStatus.askOnce = askOnce; + blockMode.readAPI.status = "allow"; + break; + case "blockReadout": + blockMode.getContext.status = "allow"; + blockMode.readAPI.status = "block"; + break; + case "fakeReadout": + blockMode.getContext.status = "allow"; + blockMode.readAPI.status = "fake"; + break; + case "askReadout": + blockMode.getContext.status = "allow"; + blockMode.readAPI.status = "ask"; + blockMode.readAPI.askStatus.askOnce = askOnce; + break; + case "unblock": + blockMode.getContext.status = "allow"; + blockMode.readAPI.status = "allow"; + break; + case "detach": + blockMode.getContext.status = "allow"; + blockMode.readAPI.status = "allow"; + break; + } + } + ["block", "ask", "blockReadout", "fakeReadout", "askReadout", "unblock", "detach"].forEach(function(mode){ + self.port.on(mode, function(askOnce){ + setStatus(mode, askOnce); + }); }); + setStatus( + checkURL( + location, + self.options.blockMode, + getDomainRegExpList(self.options.whiteList), + getDomainRegExpList(self.options.blackList) + ), + self.options.askOnce + ); + // settings passthrough self.port.on("set", function(name, value){ settings[name] = value; diff --git a/lib/main.js b/lib/main.js index 9413bee..a144043 100644 --- a/lib/main.js +++ b/lib/main.js @@ -4,46 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ (function(){ "use strict"; - - function getDomainRegExpList(domainList){ - var list = domainList - .split(",") - .map(function(entry){ - return entry.replace(/^\s+|\s+$/g, ""); - }) - .filter(function(entry){ - return !!entry.length; - }) - .map(function(entry){ - var regExp; - var domain = !!entry.match(/^[\w.]+$/); - if (domain){ - regExp = new RegExp("(?:^|\\.)" + entry.replace(/([\\\+\*\?\[\^\]\$\(\)\{\}\=\!\|\.])/g, "\\$1") + "\\.?$", "i"); - } - else { - regExp = new RegExp(entry, "i"); - } - return { - match: function(url){ - if (domain){ - return url.hostname.match(regExp); - } - else { - return url.href.match(regExp); - } - } - }; - }); - - list.match = function(url){ - return this.some(function(entry){ - return entry.match(url); - }); - }; - - return list; - } - + var self = require("sdk/self"); var pageMod = require("sdk/page-mod"); var array = require("sdk/util/array"); @@ -55,6 +16,8 @@ var tabUtils = require("sdk/tabs/utils"); var windowUtils = require("sdk/window/utils"); + var sharedFunctions = require("./sharedFunctions.js"); + var getDomainRegExpList = sharedFunctions.getDomainRegExpList; // preferences Object.keys(prefs).forEach(function(pref){ preferences.on(pref, function(){ @@ -90,48 +53,7 @@ }); function checkURL(url){ - var mode = "block"; - switch (prefs.blockMode){ - case "blockEverything": - mode = "block"; - break; - case "allowOnlyWhiteList": - if (whiteList.match(url)){ - mode = "unblock"; - } - else { - mode = "block"; - } - break; - case "ask": - case "blockReadout": - case "fakeReadout": - case "askReadout": - if (whiteList.match(url)){ - mode = "unblock"; - } - else if (blackList.match(url)){ - mode = "block"; - } - else { - mode = prefs.blockMode; - } - break; - case "blockOnlyBlackList": - if (blackList.match(url)){ - mode = "block"; - } - else { - mode = "unblock"; - } - break; - case "allowEverything": - mode = "unblock"; - break; - default: - console.log("Unknown blocking mode. Default to block everything."); - } - return mode; + return sharedFunctions.checkURL(url, prefs.blockMode, whiteList, blackList); } function checkWorker(worker){ try { @@ -154,10 +76,28 @@ } var workers = []; + var workerOptions = { + blockMode: checkURL(), + whiteList: prefs.whiteList, + blackList: prefs.blackList, + askOnce: prefs.askOnce + }; + preferences.on("blockMode", function(){ + workerOptions.blockMode = checkURL(); + }); + ["whiteList", "blackList", "askOnce"].forEach(function(prefName){ + preferences.on(prefName, function(){ + workerOptions[prefName] = prefs[prefName]; + }); + }); pageMod.PageMod({ include: "*", contentScriptWhen: "start", - contentScriptFile: self.data.url("inject.js"), + contentScriptFile: [ + self.data.url("sharedFunctions.js").replace("/data/", "/lib/"), + self.data.url("inject.js"), + ], + contentScriptOptions: workerOptions, onAttach: function(worker){ array.add(workers, worker); diff --git a/lib/sharedFunctions.js b/lib/sharedFunctions.js new file mode 100644 index 0000000..ad69c34 --- /dev/null +++ b/lib/sharedFunctions.js @@ -0,0 +1,89 @@ +function getDomainRegExpList(domainList){ + var list = domainList + .split(",") + .map(function(entry){ + return entry.replace(/^\s+|\s+$/g, ""); + }) + .filter(function(entry){ + return !!entry.length; + }) + .map(function(entry){ + var regExp; + var domain = !!entry.match(/^[\w.]+$/); + if (domain){ + regExp = new RegExp("(?:^|\\.)" + entry.replace(/([\\\+\*\?\[\^\]\$\(\)\{\}\=\!\|\.])/g, "\\$1") + "\\.?$", "i"); + } + else { + regExp = new RegExp(entry, "i"); + } + return { + match: function(url){ + if (domain){ + return url.hostname.match(regExp); + } + else { + return url.href.match(regExp); + } + } + }; + }); + + list.match = function(url){ + return this.some(function(entry){ + return entry.match(url); + }); + }; + + return list; +} + +function checkURL(url, blockMode, whiteList, blackList){ + var mode = "block"; + switch (blockMode){ + case "blockEverything": + mode = "block"; + break; + case "allowOnlyWhiteList": + if (url && whiteList.match(url)){ + mode = "unblock"; + } + else { + mode = "block"; + } + break; + case "ask": + case "blockReadout": + case "fakeReadout": + case "askReadout": + if (url && whiteList.match(url)){ + mode = "unblock"; + } + else if (url && blackList.match(url)){ + mode = "block"; + } + else { + mode = blockMode; + } + break; + case "blockOnlyBlackList": + if (url && blackList.match(url)){ + mode = "block"; + } + else { + mode = "unblock"; + } + break; + case "allowEverything": + mode = "unblock"; + break; + default: + console.log("Unknown blocking mode (" + blockMode + "). Default to block everything."); + } + return mode; +} + +try { + exports.getDomainRegExpList = getDomainRegExpList; + exports.checkURL = checkURL; +} +catch(e){} \ No newline at end of file