mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 04:40:20 +01:00
Allow cross origin arguments and remove apply(..., Array.from)
Fixes #415
This commit is contained in:
parent
8506757c62
commit
4601dd25af
@ -49,13 +49,14 @@
|
||||
};
|
||||
|
||||
scope.exportFunctionWithName = function exportFunctionWithName(func, context, name){
|
||||
const exportedTry = exportFunction(func, context);
|
||||
const exportedTry = exportFunction(func, context, {allowCrossOriginArguments: true});
|
||||
if (exportedTry.name === name){
|
||||
return exportedTry;
|
||||
}
|
||||
else {
|
||||
const wrappedContext = scope.getWrapped(context);
|
||||
const options = {
|
||||
allowCrossOriginArguments: true,
|
||||
defineAs: name
|
||||
};
|
||||
const oldDescriptor = Object.getOwnPropertyDescriptor(wrappedContext, name);
|
||||
|
@ -174,7 +174,7 @@
|
||||
}
|
||||
else {
|
||||
return arguments.length > 1?
|
||||
originalMatchMedia.apply(this, wrappedWindow.Array.from(arguments)):
|
||||
originalMatchMedia.call(this, ...arguments):
|
||||
originalMatchMedia.call(this, query);
|
||||
}
|
||||
}, window, originalMatchMedia.name);
|
||||
|
@ -133,7 +133,7 @@
|
||||
const original = descriptor.value;
|
||||
changeProperty(object, method, "value", function method(){
|
||||
const value = arguments.length?
|
||||
original.apply(this, window.Array.from(arguments)):
|
||||
original.call(this, ...arguments):
|
||||
original.call(this);
|
||||
allCallback();
|
||||
return value;
|
||||
@ -272,7 +272,7 @@
|
||||
wrappedWindow,
|
||||
"open", "value", function open(){
|
||||
const newWindow = arguments.length?
|
||||
windowOpen.apply(this, window.Array.from(arguments)):
|
||||
windowOpen.call(this, ...arguments):
|
||||
windowOpen.call(this);
|
||||
if (newWindow){
|
||||
// if we use windowOpen from the normal window we see some SOP errors
|
||||
|
@ -17,7 +17,7 @@
|
||||
if (check.allow){
|
||||
if (check.allow === true){
|
||||
return args.length?
|
||||
check.original.apply(object, check.window.Array.from(args)):
|
||||
check.original.call(object, ...args):
|
||||
check.original.call(object);
|
||||
}
|
||||
return callback.call(object, args, check);
|
||||
|
@ -166,7 +166,7 @@
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
notify("fakedAudioReadout");
|
||||
const ret = original.apply(this, window.Array.from(args));
|
||||
const ret = original.call(this, ...args);
|
||||
fakeFloat32Array(array, window, prefs);
|
||||
return ret;
|
||||
});
|
||||
@ -180,7 +180,7 @@
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
notify("fakedAudioReadout");
|
||||
const ret = original.apply(this, window.Array.from(args));
|
||||
const ret = original.call(this, ...args);
|
||||
fakeUint8Array(array, window, prefs);
|
||||
return ret;
|
||||
});
|
||||
@ -194,7 +194,7 @@
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
notify("fakedAudioReadout");
|
||||
const ret = original.apply(this, window.Array.from(args));
|
||||
const ret = original.call(this, ...args);
|
||||
fakeFloat32Array(array, window, prefs);
|
||||
return ret;
|
||||
});
|
||||
@ -208,7 +208,7 @@
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
notify("fakedAudioReadout");
|
||||
const ret = original.apply(this, window.Array.from(args));
|
||||
const ret = original.call(this, ...args);
|
||||
fakeUint8Array(array, window, prefs);
|
||||
return ret;
|
||||
});
|
||||
@ -221,7 +221,7 @@
|
||||
return function getChannelData(channel){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
const ret = original.apply(this, window.Array.from(args));
|
||||
const ret = original.call(this, ...args);
|
||||
if (!getChannelDataAlreadyFakedArrays.get(ret)){
|
||||
notify("fakedAudioReadout");
|
||||
fakeFloat32Array(ret, window, prefs);
|
||||
@ -244,7 +244,7 @@
|
||||
fakeFloat32Array(channelData, window, prefs);
|
||||
getChannelDataAlreadyFakedArrays.set(channelData, true);
|
||||
}
|
||||
const ret = original.apply(this, window.Array.from(args));
|
||||
const ret = original.call(this, ...args);
|
||||
return ret;
|
||||
});
|
||||
};
|
||||
@ -257,7 +257,7 @@
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
notify("fakedAudioReadout");
|
||||
const ret = original.apply(this, window.Array.from(args));
|
||||
const ret = original.call(this, ...args);
|
||||
fakeFloat32Array(magResponseOutput, window, prefs);
|
||||
fakeFloat32Array(phaseResponseOutput, window, prefs);
|
||||
return ret;
|
||||
|
@ -214,10 +214,10 @@
|
||||
if (fakeCanvas !== this){
|
||||
notify("fakedReadout");
|
||||
}
|
||||
return original.apply(fakeCanvas, window.Array.from(args));
|
||||
return original.call(fakeCanvas, ...args);
|
||||
}
|
||||
else {
|
||||
return original.apply(this, window.Array.from(args));
|
||||
return original.call(this, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,13 +234,13 @@
|
||||
// nothing to do here
|
||||
}
|
||||
// if "this" is not a correct context the next line will throw an error
|
||||
const ret = original.apply(this, window.Array.from(args));
|
||||
const ret = original.call(this, ...args);
|
||||
const newImageData = getImageData(window, this).imageData;
|
||||
this.putImageData(randomMixImageData(window, oldImageData, newImageData), 0, 0);
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
return original.apply(this, window.Array.from(args));
|
||||
return original.call(this, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,9 +273,9 @@
|
||||
fakeGenerator: function(checker){
|
||||
return function(context, contextAttributes){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {window, original} = check;
|
||||
const {original} = check;
|
||||
canvasContextType.set(this, context);
|
||||
return original.apply(this, window.Array.from(args));
|
||||
return original.call(this, ...args);
|
||||
});
|
||||
};
|
||||
}
|
||||
@ -332,10 +332,10 @@
|
||||
"2d"
|
||||
);
|
||||
}
|
||||
return original.apply(context, window.Array.from(args));
|
||||
return original.call(context, ...args);
|
||||
}
|
||||
else {
|
||||
return original.apply(this, window.Array.from(args));
|
||||
return original.call(this, ...args);
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -350,7 +350,7 @@
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {notify, window, original} = check;
|
||||
const rng = randomSupply.getValueRng(1, window);
|
||||
const originalValue = original.apply(this, window.Array.from(args));
|
||||
const originalValue = original.call(this, ...args);
|
||||
if ((typeof originalValue) === "boolean"){
|
||||
notify("fakedReadout");
|
||||
const index = x + this.width * y;
|
||||
@ -372,7 +372,7 @@
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {notify, window, original} = check;
|
||||
const rng = randomSupply.getValueRng(1, window);
|
||||
const originalValue = original.apply(this, window.Array.from(args));
|
||||
const originalValue = original.call(this, ...args);
|
||||
if ((typeof originalValue) === "boolean"){
|
||||
notify("fakedReadout");
|
||||
if (x instanceof window.Path2D){
|
||||
@ -431,10 +431,10 @@
|
||||
fakeCanvas,
|
||||
this instanceof window.WebGLRenderingContext? "webgl": "webgl2"
|
||||
);
|
||||
return original.apply(context, window.Array.from(args));
|
||||
return original.call(context, ...args);
|
||||
}
|
||||
else {
|
||||
return original.apply(this, window.Array.from(args));
|
||||
return original.call(this, ...args);
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -449,7 +449,7 @@
|
||||
return function getParameter(pname){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
const originalValue = original.apply(this, window.Array.from(args));
|
||||
const originalValue = original.call(this, ...args);
|
||||
if (webgl.parameterChangeDefinition[pname]){
|
||||
const definition = webgl.parameterChangeDefinition[pname];
|
||||
const {value, faked} = definition.fake(originalValue, window, prefs);
|
||||
|
@ -91,7 +91,7 @@
|
||||
function registerCallback(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
const originalValue = args.length?
|
||||
original.apply(this, window.Array.from(args)):
|
||||
original.call(this, ...args):
|
||||
original.call(this);
|
||||
registerDOMRect(originalValue, notify, window, prefs);
|
||||
return originalValue;
|
||||
@ -104,7 +104,7 @@
|
||||
return function getClientRects(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
const ret = args.length? original.apply(this, window.Array.from(args)): original.call(this);
|
||||
const ret = args.length? original.call(this, ...args): original.call(this);
|
||||
for (let i = 0; i < ret.length; i += 1){
|
||||
registerDOMRect(ret[i], notify, window, prefs);
|
||||
}
|
||||
@ -195,7 +195,7 @@
|
||||
});
|
||||
}
|
||||
else {
|
||||
original.apply(this, window.Array.from(arguments));
|
||||
original.call(this, ...arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -23,7 +23,7 @@
|
||||
get length(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
const originalLength = original.apply(this, window.Array.from(args));
|
||||
const originalLength = original.call(this, ...args);
|
||||
const threshold = prefs("historyLengthThreshold", window.location);
|
||||
if (originalLength > threshold){
|
||||
notify("fakedHistoryReadout");
|
||||
|
@ -23,8 +23,8 @@
|
||||
const temp = {
|
||||
get [property](){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {notify, window, original} = check;
|
||||
const originalValue = original.apply(this, window.Array.from(args));
|
||||
const {notify, original} = check;
|
||||
const originalValue = original.call(this, ...args);
|
||||
const returnValue = navigator.getNavigatorValue(property);
|
||||
if (originalValue !== returnValue){
|
||||
notify("fakedNavigatorReadout");
|
||||
|
@ -92,7 +92,7 @@
|
||||
function getFaker(dimension){
|
||||
return function fake(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
const originalValue = original.apply(this, window.Array.from(args));
|
||||
const originalValue = original.call(this, ...args);
|
||||
const returnValue = (typeof dimension) === "function"?
|
||||
dimension(window):
|
||||
dimension?
|
||||
@ -254,7 +254,7 @@
|
||||
get matches(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
const originalValue = original.apply(this, window.Array.from(args));
|
||||
const originalValue = original.call(this, ...args);
|
||||
const screenSize = prefs("screenSize", window.location);
|
||||
if (
|
||||
(
|
||||
|
@ -23,8 +23,8 @@
|
||||
const temp = {
|
||||
get opener(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {notify, window, original} = check;
|
||||
const originalOpener = original.apply(this, window.Array.from(args));
|
||||
const {notify, original} = check;
|
||||
const originalOpener = original.call(this, ...args);
|
||||
if (originalOpener !== null){
|
||||
notify("fakedWindowReadout");
|
||||
}
|
||||
@ -49,7 +49,7 @@
|
||||
get name(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {notify, window, original} = check;
|
||||
const originalName = original.apply(this, window.Array.from(args));
|
||||
const originalName = original.call(this, ...args);
|
||||
const returnedName = windowNames.get(window) || "";
|
||||
if (originalName !== returnedName){
|
||||
notify("fakedWindowReadout");
|
||||
@ -63,7 +63,7 @@
|
||||
setterGenerator: function(window, original){
|
||||
const temp = {
|
||||
set name(name){
|
||||
original.apply(this, window.Array.from(arguments));
|
||||
original.call(this, ...arguments);
|
||||
windowNames.set(window, name);
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user