mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-15 14:09:36 +02:00
First implementation of the fakeInput mode. (And other improvements.)
This commit is contained in:
parent
b6d08459a5
commit
a2fa00fb98
5 changed files with 188 additions and 59 deletions
|
@ -10,6 +10,7 @@
|
|||
setRandomSupply(randomSupplies.nonPersistent);
|
||||
var apiNames = Object.keys(changedFunctions);
|
||||
var undef;
|
||||
var exportFunction;
|
||||
|
||||
function setRandomSupplyByType(type){
|
||||
switch (type){
|
||||
|
@ -38,28 +39,27 @@
|
|||
}
|
||||
var error = new Error();
|
||||
var status = check({url: window.location.href, errorStack: error.stack});
|
||||
if (status.type.indexOf(changedFunction.type) !== -1){
|
||||
if (status.mode === "ask"){
|
||||
status.mode = ask({window: window, type: changedFunction.type, canvas: this, errorStack: error.stack});
|
||||
var funcStatus = changedFunction.getStatus(this, status);
|
||||
|
||||
if (funcStatus.active){
|
||||
if (funcStatus.mode === "ask"){
|
||||
funcStatus.mode = ask({window: window, type: changedFunction.type, canvas: this, errorStack: error.stack});
|
||||
}
|
||||
switch (status.mode){
|
||||
switch (funcStatus.mode){
|
||||
case "allow":
|
||||
return original;
|
||||
case "fake":
|
||||
setRandomSupplyByType(prefs("rng"));
|
||||
if (changedFunction.fake){
|
||||
notify({url: window.location.href, errorStack: error.stack}, window);
|
||||
return changedFunction.fake;
|
||||
}
|
||||
else {
|
||||
if (changedFunction.fakeGenerator) {
|
||||
return changedFunction.fakeGenerator(prefs, function(){
|
||||
notify({url: window.location.href, errorStack: error.stack}, window);
|
||||
});
|
||||
}
|
||||
else {
|
||||
var fake = changedFunction.fakeGenerator(prefs, function(messageId){
|
||||
notify({url: window.location.href, errorStack: error.stack, messageId});
|
||||
});
|
||||
switch (fake){
|
||||
case true:
|
||||
return original;
|
||||
case false:
|
||||
return undef;
|
||||
}
|
||||
default:
|
||||
return exportFunction(fake, window.wrappedJSObject);
|
||||
}
|
||||
//case "block":
|
||||
default:
|
||||
|
@ -74,4 +74,7 @@
|
|||
);
|
||||
});
|
||||
};
|
||||
exports.setExportFunction = function(eFunc){
|
||||
exportFunction = eFunc;
|
||||
};
|
||||
}());
|
Loading…
Add table
Add a link
Reference in a new issue