mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +01:00
parent
a8611230b1
commit
f85303065c
@ -41,56 +41,59 @@
|
||||
var changedFunction = changedFunctions[name];
|
||||
if (changedFunction.getStatus(undefined, siteStatus).active){
|
||||
(Array.isArray(changedFunction.object)? changedFunction.object: [changedFunction.object]).forEach(function(object){
|
||||
var original = window.wrappedJSObject[object].prototype[name];
|
||||
|
||||
Object.defineProperty(
|
||||
window.wrappedJSObject[object].prototype,
|
||||
name,
|
||||
{
|
||||
enumerable: true,
|
||||
configureable: false,
|
||||
get: function(){
|
||||
var url = getURL(window);
|
||||
if (!url){
|
||||
return undef;
|
||||
}
|
||||
var error = new Error();
|
||||
if (checkStack(error.stack)){
|
||||
return original;
|
||||
}
|
||||
var funcStatus = changedFunction.getStatus(this, siteStatus);
|
||||
|
||||
if (funcStatus.active){
|
||||
if (funcStatus.mode === "ask"){
|
||||
funcStatus.mode = ask({window: window, type: changedFunction.type, canvas: this, errorStack: error.stack});
|
||||
var constructor = window.wrappedJSObject[object];
|
||||
if (constructor){
|
||||
var original = constructor.prototype[name];
|
||||
|
||||
Object.defineProperty(
|
||||
constructor.prototype,
|
||||
name,
|
||||
{
|
||||
enumerable: true,
|
||||
configureable: false,
|
||||
get: function(){
|
||||
var url = getURL(window);
|
||||
if (!url){
|
||||
return undef;
|
||||
}
|
||||
switch (funcStatus.mode){
|
||||
case "allow":
|
||||
return original;
|
||||
case "fake":
|
||||
setRandomSupplyByType(prefs("rng"));
|
||||
var fake = changedFunction.fakeGenerator(prefs, function(messageId){
|
||||
notify({url, errorStack: error.stack, messageId});
|
||||
}, original);
|
||||
switch (fake){
|
||||
case true:
|
||||
return original;
|
||||
case false:
|
||||
return undef;
|
||||
default:
|
||||
return exportFunction(fake, window.wrappedJSObject);
|
||||
}
|
||||
//case "block":
|
||||
default:
|
||||
return undef;
|
||||
var error = new Error();
|
||||
if (checkStack(error.stack)){
|
||||
return original;
|
||||
}
|
||||
var funcStatus = changedFunction.getStatus(this, siteStatus);
|
||||
|
||||
if (funcStatus.active){
|
||||
if (funcStatus.mode === "ask"){
|
||||
funcStatus.mode = ask({window: window, type: changedFunction.type, canvas: this, errorStack: error.stack});
|
||||
}
|
||||
switch (funcStatus.mode){
|
||||
case "allow":
|
||||
return original;
|
||||
case "fake":
|
||||
setRandomSupplyByType(prefs("rng"));
|
||||
var fake = changedFunction.fakeGenerator(prefs, function(messageId){
|
||||
notify({url, errorStack: error.stack, messageId});
|
||||
}, original);
|
||||
switch (fake){
|
||||
case true:
|
||||
return original;
|
||||
case false:
|
||||
return undef;
|
||||
default:
|
||||
return exportFunction(fake, window.wrappedJSObject);
|
||||
}
|
||||
//case "block":
|
||||
default:
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return original;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return original;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user