1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-06-14 12:11:02 +02:00

Always specify correct function names

This commit is contained in:
kkapsner 2020-01-22 13:38:24 +01:00
parent 29e61ada25
commit e2efb727b9
3 changed files with 52 additions and 35 deletions

View File

@ -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,

View File

@ -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 {
[method](){
const value = arguments.length? const value = arguments.length?
original.call(this, ...arguments): original.call(this, ...arguments):
original.call(this); original.call(this);
allCallback(); allCallback();
return value; return value;
}); }
}.prototype[method]);
}); });
protectionDefinition.getters.forEach(function(property){ protectionDefinition.getters.forEach(function(property){
const temp = { const temp = {

View File

@ -143,13 +143,8 @@
} }
map.set(object, originalPropertyDescriptor); map.set(object, originalPropertyDescriptor);
Object.defineProperty( const temp = class {
object, [`get ${name}`](){
name,
{
enumerable: true,
configurable: true,
get: extension.exportFunctionWithName(function(){
if (forceLoad){ if (forceLoad){
logging.warning("force load the settings. Calling stack:", (new Error()).stack); logging.warning("force load the settings. Calling stack:", (new Error()).stack);
undoPreIntercept(); undoPreIntercept();
@ -175,8 +170,17 @@
}); });
return undef; return undef;
} }
}, windowToProcess, `get ${name}`), }
set: extension.exportFunctionWithName(function(){}, windowToProcess, `set ${name}`) [`set ${name}`](newValue){}
}.prototype;
Object.defineProperty(
object,
name,
{
enumerable: true,
configurable: true,
get: extension.exportFunctionWithName(temp[`get ${name}`], windowToProcess, `get ${name}`),
set: extension.exportFunctionWithName(temp[`set ${name}`], windowToProcess, `set ${name}`)
} }
); );
}); });