mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-03 10:31:54 +01:00
Trying to get wrappedJSObject of an wrappedJSObject is wrong...
Fixes #133 and #134.
This commit is contained in:
parent
42ee6e483e
commit
eb62521adc
@ -8,6 +8,7 @@
|
|||||||
const {ask} = require("./askForPermission.js");
|
const {ask} = require("./askForPermission.js");
|
||||||
const lists = require("./lists.js");
|
const lists = require("./lists.js");
|
||||||
const {check: originalCheck, checkStack: originalCheckStack} = require("./check.js");
|
const {check: originalCheck, checkStack: originalCheckStack} = require("./check.js");
|
||||||
|
const getWrapped = require("sdk/getWrapped");
|
||||||
|
|
||||||
const logging = require("./logging");
|
const logging = require("./logging");
|
||||||
const {error, warning, message, notice, verbose, setPrefix: setLogPrefix} = logging;
|
const {error, warning, message, notice, verbose, setPrefix: setLogPrefix} = logging;
|
||||||
@ -100,11 +101,11 @@
|
|||||||
{check, checkStack, ask: askWrapper, notify, prefs}
|
{check, checkStack, ask: askWrapper, notify, prefs}
|
||||||
);
|
);
|
||||||
message("prepare to intercept (i)frames.");
|
message("prepare to intercept (i)frames.");
|
||||||
|
|
||||||
[window.HTMLIFrameElement, window.HTMLFrameElement].forEach(function(constructor){
|
[window.HTMLIFrameElement, window.HTMLFrameElement].forEach(function(constructor){
|
||||||
var oldContentWindowGetter = constructor.prototype.__lookupGetter__("contentWindow");
|
var oldContentWindowGetter = constructor.prototype.__lookupGetter__("contentWindow");
|
||||||
Object.defineProperty(
|
Object.defineProperty(
|
||||||
constructor.prototype.wrappedJSObject,
|
getWrapped(constructor.prototype),
|
||||||
"contentWindow",
|
"contentWindow",
|
||||||
{
|
{
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
@ -118,7 +119,7 @@
|
|||||||
);
|
);
|
||||||
var oldContentDocumentGetter = constructor.prototype.__lookupGetter__("contentDocument");
|
var oldContentDocumentGetter = constructor.prototype.__lookupGetter__("contentDocument");
|
||||||
Object.defineProperty(
|
Object.defineProperty(
|
||||||
constructor.prototype.wrappedJSObject,
|
getWrapped(constructor.prototype),
|
||||||
"contentDocument",
|
"contentDocument",
|
||||||
{
|
{
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
const {changedFunctions, setRandomSupply} = require("./modifiedAPI");
|
const {changedFunctions, setRandomSupply} = require("./modifiedAPI");
|
||||||
const randomSupplies = require("./randomSupplies");
|
const randomSupplies = require("./randomSupplies");
|
||||||
|
const getWrapped = require("sdk/getWrapped");
|
||||||
|
|
||||||
setRandomSupply(randomSupplies.nonPersistent);
|
setRandomSupply(randomSupplies.nonPersistent);
|
||||||
var apiNames = Object.keys(changedFunctions);
|
var apiNames = Object.keys(changedFunctions);
|
||||||
var undef;
|
var undef;
|
||||||
@ -64,7 +66,7 @@
|
|||||||
changedFunction.object:
|
changedFunction.object:
|
||||||
[changedFunction.object]
|
[changedFunction.object]
|
||||||
).forEach(function(object){
|
).forEach(function(object){
|
||||||
var constructor = window.wrappedJSObject[object];
|
var constructor = getWrapped(window)[object];
|
||||||
if (constructor){
|
if (constructor){
|
||||||
var original = constructor.prototype[name];
|
var original = constructor.prototype[name];
|
||||||
|
|
||||||
@ -134,7 +136,7 @@
|
|||||||
case false:
|
case false:
|
||||||
return undef;
|
return undef;
|
||||||
default:
|
default:
|
||||||
return exportFunction(fake, window.wrappedJSObject);
|
return exportFunction(fake, getWrapped(window));
|
||||||
}
|
}
|
||||||
//case "block":
|
//case "block":
|
||||||
default:
|
default:
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
const colorStatistics = require("./colorStatistics");
|
const colorStatistics = require("./colorStatistics");
|
||||||
const logging = require("./logging");
|
const logging = require("./logging");
|
||||||
const {copyCanvasToWebgl} = require("./webgl");
|
const {copyCanvasToWebgl} = require("./webgl");
|
||||||
|
const getWrapped = require("sdk/getWrapped");
|
||||||
|
|
||||||
var randomSupply = null;
|
var randomSupply = null;
|
||||||
|
|
||||||
@ -30,8 +31,8 @@
|
|||||||
var imageData;
|
var imageData;
|
||||||
var source;
|
var source;
|
||||||
if ((context.canvas.width || 0) * (context.canvas.height || 0) === 0){
|
if ((context.canvas.width || 0) * (context.canvas.height || 0) === 0){
|
||||||
imageData = new window.wrappedJSObject.ImageData(0, 0);
|
imageData = new getWrapped(window).ImageData(0, 0);
|
||||||
source = new window.wrappedJSObject.ImageData(0, 0);
|
source = new getWrapped(window).ImageData(0, 0);
|
||||||
}
|
}
|
||||||
else if (context instanceof window.CanvasRenderingContext2D){
|
else if (context instanceof window.CanvasRenderingContext2D){
|
||||||
imageData = window.CanvasRenderingContext2D.prototype.getImageData.call(
|
imageData = window.CanvasRenderingContext2D.prototype.getImageData.call(
|
||||||
@ -42,7 +43,7 @@
|
|||||||
source = imageData.data;
|
source = imageData.data;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
imageData = new window.wrappedJSObject.ImageData(context.canvas.width, context.canvas.height);
|
imageData = new getWrapped(window).ImageData(context.canvas.width, context.canvas.height);
|
||||||
source = new Uint8Array(imageData.data.length);
|
source = new Uint8Array(imageData.data.length);
|
||||||
window.WebGLRenderingContext.prototype.readPixels.call(
|
window.WebGLRenderingContext.prototype.readPixels.call(
|
||||||
context,
|
context,
|
||||||
|
@ -9,6 +9,11 @@ function require(module){
|
|||||||
var scopeName = module.substr(2).replace(/\..+/, "");
|
var scopeName = module.substr(2).replace(/\..+/, "");
|
||||||
return window.scope[scopeName];
|
return window.scope[scopeName];
|
||||||
}
|
}
|
||||||
|
else if (module === "sdk/getWrapped"){
|
||||||
|
return function getWrapped(obj){
|
||||||
|
return obj.wrappedJSObject || obj;
|
||||||
|
};
|
||||||
|
}
|
||||||
else if (module === "sdk/simple-prefs"){
|
else if (module === "sdk/simple-prefs"){
|
||||||
return {
|
return {
|
||||||
prefs: settings,
|
prefs: settings,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user