1
0
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:
kkapsner 2017-10-07 23:26:04 +02:00
parent 42ee6e483e
commit eb62521adc
4 changed files with 17 additions and 8 deletions

View File

@ -8,6 +8,7 @@
const {ask} = require("./askForPermission.js");
const lists = require("./lists.js");
const {check: originalCheck, checkStack: originalCheckStack} = require("./check.js");
const getWrapped = require("sdk/getWrapped");
const logging = require("./logging");
const {error, warning, message, notice, verbose, setPrefix: setLogPrefix} = logging;
@ -100,11 +101,11 @@
{check, checkStack, ask: askWrapper, notify, prefs}
);
message("prepare to intercept (i)frames.");
[window.HTMLIFrameElement, window.HTMLFrameElement].forEach(function(constructor){
var oldContentWindowGetter = constructor.prototype.__lookupGetter__("contentWindow");
Object.defineProperty(
constructor.prototype.wrappedJSObject,
getWrapped(constructor.prototype),
"contentWindow",
{
enumerable: true,
@ -118,7 +119,7 @@
);
var oldContentDocumentGetter = constructor.prototype.__lookupGetter__("contentDocument");
Object.defineProperty(
constructor.prototype.wrappedJSObject,
getWrapped(constructor.prototype),
"contentDocument",
{
enumerable: true,

View File

@ -15,6 +15,8 @@
const {changedFunctions, setRandomSupply} = require("./modifiedAPI");
const randomSupplies = require("./randomSupplies");
const getWrapped = require("sdk/getWrapped");
setRandomSupply(randomSupplies.nonPersistent);
var apiNames = Object.keys(changedFunctions);
var undef;
@ -64,7 +66,7 @@
changedFunction.object:
[changedFunction.object]
).forEach(function(object){
var constructor = window.wrappedJSObject[object];
var constructor = getWrapped(window)[object];
if (constructor){
var original = constructor.prototype[name];
@ -134,7 +136,7 @@
case false:
return undef;
default:
return exportFunction(fake, window.wrappedJSObject);
return exportFunction(fake, getWrapped(window));
}
//case "block":
default:

View File

@ -16,6 +16,7 @@
const colorStatistics = require("./colorStatistics");
const logging = require("./logging");
const {copyCanvasToWebgl} = require("./webgl");
const getWrapped = require("sdk/getWrapped");
var randomSupply = null;
@ -30,8 +31,8 @@
var imageData;
var source;
if ((context.canvas.width || 0) * (context.canvas.height || 0) === 0){
imageData = new window.wrappedJSObject.ImageData(0, 0);
source = new window.wrappedJSObject.ImageData(0, 0);
imageData = new getWrapped(window).ImageData(0, 0);
source = new getWrapped(window).ImageData(0, 0);
}
else if (context instanceof window.CanvasRenderingContext2D){
imageData = window.CanvasRenderingContext2D.prototype.getImageData.call(
@ -42,7 +43,7 @@
source = imageData.data;
}
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);
window.WebGLRenderingContext.prototype.readPixels.call(
context,

View File

@ -9,6 +9,11 @@ function require(module){
var scopeName = module.substr(2).replace(/\..+/, "");
return window.scope[scopeName];
}
else if (module === "sdk/getWrapped"){
return function getWrapped(obj){
return obj.wrappedJSObject || obj;
};
}
else if (module === "sdk/simple-prefs"){
return {
prefs: settings,