mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +01:00
parent
2c141277e8
commit
2e91f85d8f
@ -84,6 +84,9 @@
|
||||
const forEachFunction = function(windowToProcess, callback){
|
||||
apiNames.forEach(function(name){
|
||||
const changedFunction = changedFunctions[name];
|
||||
if (changedFunction.name){
|
||||
name = changedFunction.name;
|
||||
}
|
||||
getAllFunctionObjects(windowToProcess, changedFunction).forEach(function(object){
|
||||
if (object){
|
||||
callback({name, object: object, changedFunction});
|
||||
@ -317,6 +320,9 @@
|
||||
function interceptFunctions(windowToProcess, siteStatus, {checkStack, ask, notify, prefs}){
|
||||
apiNames.forEach(function(name){
|
||||
const changedFunction = changedFunctions[name];
|
||||
if (changedFunction.name){
|
||||
name = changedFunction.name;
|
||||
}
|
||||
const functionStatus = changedFunction.getStatus(undefined, siteStatus, prefs);
|
||||
logging.verbose("status for", name, ":", functionStatus);
|
||||
if (!functionStatus.active) return;
|
||||
|
@ -244,6 +244,34 @@
|
||||
}
|
||||
}
|
||||
|
||||
function offscreenToBlobCallback(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
if (canvasSizeShouldBeFaked(this, prefs)){
|
||||
try {
|
||||
const options = args[0];
|
||||
const canvas = window.document.createElement("canvas");
|
||||
canvas.width = this.width;
|
||||
canvas.height = this.height;
|
||||
const context = canvas.getContext("2d");
|
||||
context.drawImage(this.transferToImageBitmap(), 0, 0);
|
||||
const fakeCanvas = getFakeCanvas(window, canvas, prefs);
|
||||
if (fakeCanvas !== canvas){
|
||||
notify("fakedReadout");
|
||||
}
|
||||
return new window.Promise(function(resolve){
|
||||
fakeCanvas.toBlob(resolve, options && options.type, options && options.quality);
|
||||
});
|
||||
}
|
||||
catch (error){
|
||||
logging.warning("Error while faking:", error);
|
||||
return original.call(this, ...args);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return original.call(this, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
const isPointCache = Object.create(null);
|
||||
function getIsPointCacheIndex(x, y, values){
|
||||
return String.fromCodePoint(...values, x, y);
|
||||
@ -496,7 +524,28 @@
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
convertToBlob: {
|
||||
type: "readout",
|
||||
getStatus: createGetStatus("readout"),
|
||||
object: ["OffscreenCanvas"],
|
||||
fakeGenerator: function(checker){
|
||||
return function convertToBlob(){
|
||||
return checkerWrapper(checker, this, arguments, offscreenToBlobCallback);
|
||||
};
|
||||
}
|
||||
},
|
||||
offscreenToBlob: {
|
||||
name: "toBlob",
|
||||
type: "readout",
|
||||
getStatus: createGetStatus("readout"),
|
||||
object: ["OffscreenCanvas"],
|
||||
fakeGenerator: function(checker){
|
||||
return function toBlob(){
|
||||
return checkerWrapper(checker, this, arguments, offscreenToBlobCallback);
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
Object.keys(scope.changedFunctions).forEach(function(key){
|
||||
scope.changedFunctions[key].api = "canvas";
|
||||
|
@ -93,7 +93,9 @@
|
||||
{name: "Canvas-API", level: 1},
|
||||
"getContext @ canvas",
|
||||
{message: "readout", level: 2},
|
||||
"toDataURL @ canvas", "toBlob @ canvas", "mozGetAsFile @ canvas", "getImageData @ canvas",
|
||||
"toDataURL @ canvas",
|
||||
"toBlob @ canvas", "convertToBlob @ canvas", "mozGetAsFile @ canvas",
|
||||
"getImageData @ canvas",
|
||||
"isPointInPath @ canvas", "isPointInStroke @ canvas",
|
||||
{message: "input", level: 2},
|
||||
"fillText @ canvas", "strokeText @ canvas",
|
||||
|
@ -4,6 +4,7 @@ Version 1.3:
|
||||
|
||||
new features:
|
||||
- added link to FAQ
|
||||
- added offscreen canvas protection
|
||||
|
||||
fixes:
|
||||
-
|
||||
|
Loading…
x
Reference in New Issue
Block a user