1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-04 20:46:39 +02:00

Code cleanup.

This commit is contained in:
kkapsner 2017-10-05 19:00:00 +02:00
parent 289cea0fc0
commit 01c1145e28
9 changed files with 81 additions and 61 deletions

View file

@ -20,7 +20,9 @@
const logging = require("./logging");
scope.check = function check({url, errorStack}){
var match = checkBoth(errorStack, url, prefs.blockMode).match(/^(block|allow|fake|ask)(|Readout|Everything|Context|Input|Internal)$/);
var match = checkBoth(errorStack, url, prefs.blockMode).match(
/^(block|allow|fake|ask)(|Readout|Everything|Context|Input|Internal)$/
);
if (match){
return {
type: (match[2] === "Everything" || match[2] === "")?

View file

@ -60,7 +60,11 @@
apiNames.forEach(function(name){
var changedFunction = changedFunctions[name];
if (changedFunction.getStatus(undefined, siteStatus).active){
(Array.isArray(changedFunction.object)? changedFunction.object: [changedFunction.object]).forEach(function(object){
(
Array.isArray(changedFunction.object)?
changedFunction.object:
[changedFunction.object]
).forEach(function(object){
var constructor = window.wrappedJSObject[object];
if (constructor){
var original = constructor.prototype[name];
@ -84,7 +88,12 @@
if (funcStatus.active){
if (funcStatus.mode === "ask"){
funcStatus.mode = ask({window: window, type: changedFunction.type, canvas: this, errorStack: error.stack});
funcStatus.mode = ask({
window: window,
type: changedFunction.type,
canvas: this,
errorStack: error.stack
});
}
switch (funcStatus.mode){
case "allow":
@ -95,22 +104,22 @@
notify({
url,
errorStack: error.stack,
messageId, timestamp: new Date(),
messageId,
timestamp: new Date(),
functionName: name,
dataURL:
prefs("storeImageForInspection") &&
prefs("showNotifications")
?
(
this instanceof HTMLCanvasElement?
this.toDataURL():
prefs("showNotifications")?
(
this.canvas instanceof HTMLCanvasElement?
this.canvas.toDataURL():
false
)
):
false
this instanceof HTMLCanvasElement?
this.toDataURL():
(
this.canvas instanceof HTMLCanvasElement?
this.canvas.toDataURL():
false
)
):
false
});
}, window, original);
switch (fake){

View file

@ -49,13 +49,13 @@
};
});
list.match = function(url){
return this.some(function(entry){
return entry.match(url);
});
};
return list;
list.match = function(url){
return this.some(function(entry){
return entry.match(url);
});
};
return list;
}
var lists = {

View file

@ -59,10 +59,10 @@
}
}
function error (...args){performLog( 1, args);}
function warning(...args){performLog( 25, args);}
function message(...args){performLog( 50, args);}
function notice (...args){performLog( 75, args);}
function error (...args){performLog(1, args);}
function warning(...args){performLog(25, args);}
function message(...args){performLog(50, args);}
function notice (...args){performLog(75, args);}
function verbose(...args){performLog(100, args);}
function metaLog(...args){performLog(999, args);}

View file

@ -147,7 +147,7 @@
// old code
// const {when: unload} = require("sdk/system/unload");
// unload(function(){
// processes.port.emit("canvasBlocker-unload");
// processes.port.emit("canvasBlocker-unload");
// });
browser.runtime.onInstalled.addListener(function(){

View file

@ -69,12 +69,12 @@
var positionBuffer = context.createBuffer();
context.bindBuffer(context.ARRAY_BUFFER, positionBuffer);
context.bufferData(context.ARRAY_BUFFER, new Float32Array([
-1,-1,
-1, 1,
1,-1,
1, 1,
-1, 1,
1,-1
-1, -1,
-1, 1,
1, -1,
1, 1,
-1, 1,
1, -1
]), context.STATIC_DRAW);
@ -84,7 +84,7 @@
var normalize = false; // don't normalize the data
var stride = 0; // 0 = move forward size * sizeof(type) each iteration to get the next position
var offset = 0; // start at the beginning of the buffer
context.vertexAttribPointer( positionAttributeLocation, size, type, normalize, stride, offset);
context.vertexAttribPointer(positionAttributeLocation, size, type, normalize, stride, offset);
var texCoordLocation = context.getAttribLocation(program, "a_texCoord");