1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-07-02 15:48:55 +02:00
This commit is contained in:
kkapsner 2019-05-24 18:29:45 +02:00
parent f72f8f67ae
commit b6e5384945

View File

@ -4,14 +4,7 @@
(function(){ (function(){
"use strict"; "use strict";
var scope; const scope = ((typeof exports) !== "undefined")? exports: require.register("./modifiedCanvasAPI");
if ((typeof exports) !== "undefined"){
scope = exports;
}
else {
scope = require.register("./modifiedCanvasAPI", {});
}
const colorStatistics = require("./colorStatistics"); const colorStatistics = require("./colorStatistics");
const logging = require("./logging"); const logging = require("./logging");
const {copyCanvasToWebgl} = require("./webgl"); const {copyCanvasToWebgl} = require("./webgl");
@ -30,8 +23,8 @@
var imageData; var imageData;
var source; var source;
if ((context.canvas.width || 0) * (context.canvas.height || 0) === 0){ if ((context.canvas.width || 0) * (context.canvas.height || 0) === 0){
imageData = new (getWrapped(window).ImageData)(0, 0); imageData = new (getWrapped(window).ImageData)(0, 0);
source = new (getWrapped(window).ImageData)(0, 0); source = new (getWrapped(window).ImageData)(0, 0);
} }
else if (context instanceof window.CanvasRenderingContext2D){ else if (context instanceof window.CanvasRenderingContext2D){
imageData = window.CanvasRenderingContext2D.prototype.getImageData.call( imageData = window.CanvasRenderingContext2D.prototype.getImageData.call(
@ -42,7 +35,7 @@
source = imageData.data; source = imageData.data;
} }
else { else {
imageData = new (getWrapped(window).ImageData)(context.canvas.width, context.canvas.height); imageData = new (getWrapped(window).ImageData)(context.canvas.width, context.canvas.height);
source = new Uint8Array(imageData.data.length); source = new Uint8Array(imageData.data.length);
( (
context instanceof window.WebGLRenderingContext? context instanceof window.WebGLRenderingContext?
@ -152,7 +145,7 @@
var size = canvas.height * canvas.width; var size = canvas.height * canvas.width;
var maxSize = prefs("maxFakeSize") || Number.POSITIVE_INFINITY; var maxSize = prefs("maxFakeSize") || Number.POSITIVE_INFINITY;
var minSize = prefs("minFakeSize") || 0; var minSize = prefs("minFakeSize") || 0;
return size > minSize & size <= maxSize; return size > minSize && size <= maxSize;
} }
else { else {
return true; return true;