mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-23 05:10:27 +01:00
Fixed bug with webgl-canvas.
This commit is contained in:
parent
0904d8e2a6
commit
0640008459
Binary file not shown.
@ -7,11 +7,26 @@
|
|||||||
|
|
||||||
function getFakeCanvas(window, original){
|
function getFakeCanvas(window, original){
|
||||||
var context = window.HTMLCanvasElement.prototype.getContext.call(original, "2d");
|
var context = window.HTMLCanvasElement.prototype.getContext.call(original, "2d");
|
||||||
var imageData = window.CanvasRenderingContext2D.prototype.getImageData.call(context, 0, 0, original.width, original.height);
|
var imageData, data, source;
|
||||||
|
if (context){
|
||||||
|
imageData = window.CanvasRenderingContext2D.prototype.getImageData.call(context, 0, 0, original.width, original.height);
|
||||||
|
source = imageData.data;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
context = window.HTMLCanvasElement.prototype.getContext.call(original, "webgl");
|
||||||
|
imageData = new window.wrappedJSObject.ImageData(original.width, original.height);
|
||||||
|
source = new window.wrappedJSObject.Uint8Array(imageData.data.length);
|
||||||
|
window.WebGLRenderingContext.prototype.readPixels.call(
|
||||||
|
context,
|
||||||
|
0, 0, original.width, original.height,
|
||||||
|
context.RGBA, context.UNSIGNED_BYTE,
|
||||||
|
source
|
||||||
|
);
|
||||||
|
}
|
||||||
var data = imageData.data;
|
var data = imageData.data;
|
||||||
|
|
||||||
for (var i = 0, l = data.length; i < l; i += 1){
|
for (var i = 0, l = data.length; i < l; i += 1){
|
||||||
var value = data[i];
|
var value = source[i];
|
||||||
if (value >= 0x80){
|
if (value >= 0x80){
|
||||||
value = value ^ Math.floor(Math.random() * 0x20);
|
value = value ^ Math.floor(Math.random() * 0x20);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user