mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-06-13 19:51:03 +02:00
Always specify correct function names
This commit is contained in:
parent
29e61ada25
commit
e2efb727b9
@ -55,6 +55,17 @@
|
|||||||
return exportedTry;
|
return exportedTry;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (func.name === name){
|
||||||
|
logging.message(
|
||||||
|
"FireFox bug: Need to change name in exportFunction from",
|
||||||
|
exportedTry.name,
|
||||||
|
"(originally correct) to",
|
||||||
|
name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logging.error("Wrong name specified for", name, new Error());
|
||||||
|
}
|
||||||
const wrappedContext = scope.getWrapped(context);
|
const wrappedContext = scope.getWrapped(context);
|
||||||
const options = {
|
const options = {
|
||||||
allowCrossOriginArguments: true,
|
allowCrossOriginArguments: true,
|
||||||
|
@ -131,13 +131,15 @@
|
|||||||
protectionDefinition.methods.forEach(function(method){
|
protectionDefinition.methods.forEach(function(method){
|
||||||
const descriptor = Object.getOwnPropertyDescriptor(object, method);
|
const descriptor = Object.getOwnPropertyDescriptor(object, method);
|
||||||
const original = descriptor.value;
|
const original = descriptor.value;
|
||||||
changeProperty(object, method, "value", function method(){
|
changeProperty(object, method, "value", class {
|
||||||
const value = arguments.length?
|
[method](){
|
||||||
original.call(this, ...arguments):
|
const value = arguments.length?
|
||||||
original.call(this);
|
original.call(this, ...arguments):
|
||||||
allCallback();
|
original.call(this);
|
||||||
return value;
|
allCallback();
|
||||||
});
|
return value;
|
||||||
|
}
|
||||||
|
}.prototype[method]);
|
||||||
});
|
});
|
||||||
protectionDefinition.getters.forEach(function(property){
|
protectionDefinition.getters.forEach(function(property){
|
||||||
const temp = {
|
const temp = {
|
||||||
|
@ -143,40 +143,44 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
map.set(object, originalPropertyDescriptor);
|
map.set(object, originalPropertyDescriptor);
|
||||||
|
const temp = class {
|
||||||
|
[`get ${name}`](){
|
||||||
|
if (forceLoad){
|
||||||
|
logging.warning("force load the settings. Calling stack:", (new Error()).stack);
|
||||||
|
undoPreIntercept();
|
||||||
|
settings.forceLoad();
|
||||||
|
doRealIntercept(windowToProcess, apis, state);
|
||||||
|
const descriptor = Object.getOwnPropertyDescriptor(object, name);
|
||||||
|
return descriptor.value || descriptor.get.call(this);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logging.notice("API blocked (%s)", name);
|
||||||
|
const url = getURL(windowToProcess);
|
||||||
|
if (!url){
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
const error = new Error();
|
||||||
|
apis.notify({
|
||||||
|
url,
|
||||||
|
errorStack: error.stack,
|
||||||
|
messageId: "preBlock",
|
||||||
|
timestamp: new Date(),
|
||||||
|
functionName: name,
|
||||||
|
dataURL: false
|
||||||
|
});
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[`set ${name}`](newValue){}
|
||||||
|
}.prototype;
|
||||||
Object.defineProperty(
|
Object.defineProperty(
|
||||||
object,
|
object,
|
||||||
name,
|
name,
|
||||||
{
|
{
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true,
|
configurable: true,
|
||||||
get: extension.exportFunctionWithName(function(){
|
get: extension.exportFunctionWithName(temp[`get ${name}`], windowToProcess, `get ${name}`),
|
||||||
if (forceLoad){
|
set: extension.exportFunctionWithName(temp[`set ${name}`], windowToProcess, `set ${name}`)
|
||||||
logging.warning("force load the settings. Calling stack:", (new Error()).stack);
|
|
||||||
undoPreIntercept();
|
|
||||||
settings.forceLoad();
|
|
||||||
doRealIntercept(windowToProcess, apis, state);
|
|
||||||
const descriptor = Object.getOwnPropertyDescriptor(object, name);
|
|
||||||
return descriptor.value || descriptor.get.call(this);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logging.notice("API blocked (%s)", name);
|
|
||||||
const url = getURL(windowToProcess);
|
|
||||||
if (!url){
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
const error = new Error();
|
|
||||||
apis.notify({
|
|
||||||
url,
|
|
||||||
errorStack: error.stack,
|
|
||||||
messageId: "preBlock",
|
|
||||||
timestamp: new Date(),
|
|
||||||
functionName: name,
|
|
||||||
dataURL: false
|
|
||||||
});
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
}, windowToProcess, `get ${name}`),
|
|
||||||
set: extension.exportFunctionWithName(function(){}, windowToProcess, `set ${name}`)
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user