mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 04:40:20 +01:00
parent
1f1d7052a1
commit
945c2716c9
@ -227,24 +227,25 @@
|
||||
notify("fakedInput");
|
||||
let oldImageData;
|
||||
let x, y, width, height;
|
||||
const getImageData = window.CanvasRenderingContext2D.prototype.getImageData;
|
||||
const border = 4;
|
||||
try {
|
||||
// "this" is not trustable - it may be not a context
|
||||
const measurement = window.CanvasRenderingContext2D.prototype.measureText.call(this, args[0]);
|
||||
width = Math.ceil(measurement.actualBoundingBoxRight + measurement.actualBoundingBoxLeft) + border;
|
||||
height = Math.ceil(measurement.actualBoundingBoxDescent + measurement.actualBoundingBoxAscent) + border;
|
||||
x = Math.max(0, args[1] - width);
|
||||
y = Math.max(0, args[2] - height);
|
||||
width = Math.min(3 * width, this.canvas.width - x);
|
||||
height = Math.min(3 * height, this.canvas.height - y);
|
||||
oldImageData = window.CanvasRenderingContext2D.prototype.getImageData.call(this, x, y, width, height);
|
||||
const left = Math.max(0, measurement.actualBoundingBoxLeft);
|
||||
const top = Math.max(0, measurement.actualBoundingBoxAscent);
|
||||
width = Math.ceil(measurement.actualBoundingBoxRight + left) + 2 * border;
|
||||
height = Math.ceil(measurement.actualBoundingBoxDescent + top) + 2 * border;
|
||||
x = args[1] - border - left;
|
||||
y = args[2] - border - top;
|
||||
oldImageData = getImageData.call(this, x, y, width, height);
|
||||
}
|
||||
catch (error){
|
||||
// nothing to do here
|
||||
}
|
||||
// if "this" is not a correct context the next line will throw an error
|
||||
const ret = original.call(this, ...args);
|
||||
const newImageData = window.CanvasRenderingContext2D.prototype.getImageData.call(this, x, y, width, height);
|
||||
const newImageData = getImageData.call(this, x, y, width, height);
|
||||
this.putImageData(randomMixImageData(window, oldImageData, newImageData), x, y);
|
||||
return ret;
|
||||
}
|
||||
|
@ -161,6 +161,10 @@
|
||||
{
|
||||
"version": "1.5Alpha20210104",
|
||||
"update_link": "https://canvasblocker.kkapsner.de/versions/canvasblocker_beta-1.5Alpha20210104-an+fx.xpi"
|
||||
},
|
||||
{
|
||||
"version": "1.5Alpha20210112",
|
||||
"update_link": "https://canvasblocker.kkapsner.de/versions/canvasblocker_beta-1.5Alpha20210112-an+fx.xpi"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user