mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 12:36:37 +02:00
Version 0.2.0
Reenabled notifications Code cleanup.
This commit is contained in:
parent
97e0c6b9cd
commit
c10b382c93
7 changed files with 106 additions and 83 deletions
|
@ -5,50 +5,48 @@
|
|||
"use strict";
|
||||
|
||||
function getFakeCanvas(window, original){
|
||||
var canvas = original.cloneNode(true);
|
||||
var context = window.HTMLCanvasElement.prototype.getContext.call(canvas, "2d");
|
||||
var imageData = window.CanvasRenderingContext2D.prototype.getImageData.call(context, 0, 0, canvas.width, canvas.height);
|
||||
var context = window.HTMLCanvasElement.prototype.getContext.call(original, "2d");
|
||||
var imageData = window.CanvasRenderingContext2D.prototype.getImageData.call(context, 0, 0, original.width, original.height);
|
||||
var data = imageData.data;
|
||||
|
||||
for (var i = 0, l = data.length; i < l; i += 1){
|
||||
var value = 0xFF - data[i];
|
||||
if (value > 0x80){
|
||||
value = value ^ Math.floor(Math.random() * 0x40);
|
||||
}
|
||||
else if (value > 0x40){
|
||||
var value = data[i];
|
||||
if (value >= 0x80){
|
||||
value = value ^ Math.floor(Math.random() * 0x20);
|
||||
}
|
||||
else if (value > 0x20){
|
||||
else if (value >= 0x40){
|
||||
value = value ^ Math.floor(Math.random() * 0x10);
|
||||
}
|
||||
else if (value > 0x10){
|
||||
else if (value >= 0x20){
|
||||
value = value ^ Math.floor(Math.random() * 0x08);
|
||||
}
|
||||
else if (value > 0x08){
|
||||
else if (value >= 0x10){
|
||||
value = value ^ Math.floor(Math.random() * 0x04);
|
||||
}
|
||||
else if (value > 0x04){
|
||||
else if (value >= 0x08){
|
||||
value = value ^ Math.floor(Math.random() * 0x02);
|
||||
}
|
||||
else if (value > 0x02){
|
||||
else if (value >= 0x04){
|
||||
value = value ^ Math.floor(Math.random() * 0x01);
|
||||
}
|
||||
data[i] = 0xFF - value;
|
||||
data[i] = value;
|
||||
}
|
||||
var canvas = original.cloneNode(true);
|
||||
var context = window.HTMLCanvasElement.prototype.getContext.call(canvas, "2d");
|
||||
context.putImageData(imageData, 0, 0);
|
||||
return canvas;
|
||||
}
|
||||
function getWindow(canvas){
|
||||
console.log(canvas);
|
||||
return canvas.ownerDocument.defaultView;
|
||||
}
|
||||
// changed functions and their fakes
|
||||
exports.changedFunctions = {
|
||||
getContext: {
|
||||
mode: "block",
|
||||
type: "context",
|
||||
object: "HTMLCanvasElement"
|
||||
},
|
||||
toDataURL: {
|
||||
mode: "fakeReadout",
|
||||
type: "readout",
|
||||
object: "HTMLCanvasElement",
|
||||
fake: function toDataURL(){
|
||||
var window = getWindow(this);
|
||||
|
@ -56,7 +54,7 @@
|
|||
}
|
||||
},
|
||||
toBlob: {
|
||||
mode: "fakeReadout",
|
||||
type: "readout",
|
||||
object: "HTMLCanvasElement",
|
||||
fake: function toBlob(callback){
|
||||
var window = getWindow(this);
|
||||
|
@ -65,7 +63,7 @@
|
|||
exportOptions: {allowCallbacks: true}
|
||||
},
|
||||
mozGetAsFile: {
|
||||
mode: "fakeReadout",
|
||||
type: "readout",
|
||||
object: "HTMLCanvasElement",
|
||||
mozGetAsFile: function mozGetAsFile(callbak){
|
||||
var window = getWindow(this);
|
||||
|
@ -73,7 +71,7 @@
|
|||
}
|
||||
},
|
||||
getImageData: {
|
||||
mode: "fakeReadout",
|
||||
type: "readout",
|
||||
object: "CanvasRenderingContext2D",
|
||||
fake: function getImageData(sx, sy, sw, sh){
|
||||
var window = getWindow(this.canvas);
|
||||
|
@ -88,7 +86,7 @@
|
|||
}
|
||||
},
|
||||
readPixels: {
|
||||
mode: "fakeReadout",
|
||||
type: "readout",
|
||||
object: "WebGLRenderingContext",
|
||||
fake: function readPixels(x, y, width, height, format, type, pixels){
|
||||
var window = getWindow(this.canvas);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue