mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-30 23:38:47 +01:00
Introduced maxFakeSize.
This commit is contained in:
parent
8240bf6007
commit
b8ba76300e
Binary file not shown.
@ -34,17 +34,18 @@
|
||||
token
|
||||
)[0];
|
||||
},
|
||||
prefs: function(name){
|
||||
return sendSyncMessage(
|
||||
"canvasBlocker-pref-get",
|
||||
name
|
||||
)[0];
|
||||
}
|
||||
prefs
|
||||
});
|
||||
}
|
||||
function notify(data){
|
||||
sendAsyncMessage("canvasBlocker-notify", data);
|
||||
}
|
||||
function prefs(name){
|
||||
return sendSyncMessage(
|
||||
"canvasBlocker-pref-get",
|
||||
name
|
||||
)[0];
|
||||
}
|
||||
|
||||
function interceptWrapper(ev){
|
||||
if (enabled){
|
||||
@ -55,7 +56,7 @@
|
||||
var window = ev.target.defaultView;
|
||||
intercept(
|
||||
{subject: window},
|
||||
{check, ask: askWrapper, notify}
|
||||
{check, ask: askWrapper, notify, prefs}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
var apiNames = Object.keys(changedFunctions);
|
||||
var undef;
|
||||
|
||||
exports.intercept = function intercept({subject: window}, {check, ask, notify}){
|
||||
exports.intercept = function intercept({subject: window}, {check, ask, notify, prefs}){
|
||||
apiNames.forEach(function(name){
|
||||
var changedFunction = changedFunctions[name];
|
||||
var original = window.wrappedJSObject[changedFunction.object].prototype[name];
|
||||
@ -35,7 +35,7 @@
|
||||
return original;
|
||||
case "fake":
|
||||
notify({url: window.location.href, errorStack: error.stack}, window);
|
||||
return changedFunction.fake || undef;
|
||||
return changedFunction.fake || changedFunction.fakeGenerator(prefs) || undef;
|
||||
//case "block":
|
||||
default:
|
||||
return undef;
|
||||
|
@ -93,21 +93,24 @@
|
||||
getImageData: {
|
||||
type: "readout",
|
||||
object: "CanvasRenderingContext2D",
|
||||
fake: function getImageData(sx, sy, sw, sh){
|
||||
var window = getWindow(this.canvas);
|
||||
var context = (sw * sh > 300 * 400)?
|
||||
this:
|
||||
window.HTMLCanvasElement.prototype.getContext.call(
|
||||
getFakeCanvas(window, this.canvas),
|
||||
"2d"
|
||||
);
|
||||
var data = window.CanvasRenderingContext2D.prototype.getImageData.apply(context, arguments).data;
|
||||
|
||||
var imageData = new window.wrappedJSObject.ImageData(sw, sh);
|
||||
for (var i = 0, l = data.length; i < l; i += 1){
|
||||
imageData.data[i] = data[i];
|
||||
fakeGenerator: function(prefs){
|
||||
var maxSize = prefs("maxFakeSize") || Number.POSITIVE_INFINITY;
|
||||
return function getImageData(sx, sy, sw, sh){
|
||||
var window = getWindow(this.canvas);
|
||||
var context = (sw * sh > maxSize)?
|
||||
this:
|
||||
window.HTMLCanvasElement.prototype.getContext.call(
|
||||
getFakeCanvas(window, this.canvas),
|
||||
"2d"
|
||||
);
|
||||
var data = window.CanvasRenderingContext2D.prototype.getImageData.apply(context, arguments).data;
|
||||
|
||||
var imageData = new window.wrappedJSObject.ImageData(sw, sh);
|
||||
for (var i = 0, l = data.length; i < l; i += 1){
|
||||
imageData.data[i] = data[i];
|
||||
}
|
||||
return imageData;
|
||||
}
|
||||
return imageData;
|
||||
}
|
||||
},
|
||||
readPixels: {
|
||||
|
@ -21,6 +21,8 @@
|
||||
"blockMode_options.block readout API": "Auslese-API blockieren",
|
||||
"blockMode_options.fake readout API": "Auslese-API vortäuschen",
|
||||
"blockMode_title": "Blockiermodus",
|
||||
"maxFakeSize_description": "Maximale Vortäuschgröße",
|
||||
"maxFakeSize_": "Canvas, die eine größe Fläche als die hier angegeben Zahl haben, werden nicht vorgetäuscht. (Null eingeben, um es zu deaktivieren.)",
|
||||
"disableNotifications": "Benachrichtigungen deaktivieren",
|
||||
"displayCallingStack": "Aufrufestack anzeigen",
|
||||
"displayFullURL": "URL anzeigen",
|
||||
|
@ -21,6 +21,8 @@
|
||||
"blockMode_options.block readout API": "block readout API",
|
||||
"blockMode_options.fake readout API": "fake readout API",
|
||||
"blockMode_title": "Block mode",
|
||||
"maxFakeSize_description": "Maximal fake size",
|
||||
"maxFakeSize_": "Canvas with a bigger area than this number will not be faked. (Enter zero to disable.)",
|
||||
"disableNotifications": "disable notifications",
|
||||
"displayCallingStack": "display calling stack",
|
||||
"displayFullURL": "display full URL",
|
||||
|
@ -62,6 +62,12 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "maxFakeSize",
|
||||
"title": "Maximal fake size",
|
||||
"type": "integer",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"name": "askOnlyOnce",
|
||||
"title": "Ask only once",
|
||||
|
Loading…
x
Reference in New Issue
Block a user