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