mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-04-18 08:08:28 +02:00
Code cleanup.
This commit is contained in:
parent
289cea0fc0
commit
01c1145e28
@ -17,19 +17,24 @@
|
|||||||
"settings": false
|
"settings": false
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"brace-style": ["warn", "stroustrup", {"allowSingleLine": true}],
|
"brace-style": ["error", "stroustrup", {"allowSingleLine": true}],
|
||||||
"eqeqeq": "warn",
|
"comma-spacing": ["error", { "before": false, "after": true }],
|
||||||
|
"constructor-super": "warn",
|
||||||
|
"eqeqeq": "error",
|
||||||
|
"max-len": ["warn", 120],
|
||||||
|
"max-lines": ["warn", 200],
|
||||||
"no-const-assign": "warn",
|
"no-const-assign": "warn",
|
||||||
"no-this-before-super": "warn",
|
"no-this-before-super": "warn",
|
||||||
"no-undef": "warn",
|
"no-undef": "error",
|
||||||
"no-unreachable": "warn",
|
"no-unreachable": "warn",
|
||||||
"no-unused-vars": "off",
|
"no-unused-vars": "off",
|
||||||
"no-trailing-spaces": ["warn", {"skipBlankLines": true}],
|
"no-trailing-spaces": ["error", {"skipBlankLines": true}],
|
||||||
"no-mixed-spaces-and-tabs": ["warn", "smart-tabs"],
|
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
|
||||||
"constructor-super": "warn",
|
"indent": ["error", "tab", {"SwitchCase": 1}],
|
||||||
|
"space-in-parens": ["error", "never"],
|
||||||
"valid-typeof": "warn",
|
"valid-typeof": "warn",
|
||||||
"quotes": ["error", "double"],
|
"quotes": ["error", "double"],
|
||||||
"semi": ["error", "always"],
|
"semi": ["error", "always"],
|
||||||
"strict": ["warn", "function"]
|
"strict": ["error", "function"]
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,7 +20,9 @@
|
|||||||
const logging = require("./logging");
|
const logging = require("./logging");
|
||||||
|
|
||||||
scope.check = function check({url, errorStack}){
|
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){
|
if (match){
|
||||||
return {
|
return {
|
||||||
type: (match[2] === "Everything" || match[2] === "")?
|
type: (match[2] === "Everything" || match[2] === "")?
|
||||||
|
@ -60,7 +60,11 @@
|
|||||||
apiNames.forEach(function(name){
|
apiNames.forEach(function(name){
|
||||||
var changedFunction = changedFunctions[name];
|
var changedFunction = changedFunctions[name];
|
||||||
if (changedFunction.getStatus(undefined, siteStatus).active){
|
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];
|
var constructor = window.wrappedJSObject[object];
|
||||||
if (constructor){
|
if (constructor){
|
||||||
var original = constructor.prototype[name];
|
var original = constructor.prototype[name];
|
||||||
@ -84,7 +88,12 @@
|
|||||||
|
|
||||||
if (funcStatus.active){
|
if (funcStatus.active){
|
||||||
if (funcStatus.mode === "ask"){
|
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){
|
switch (funcStatus.mode){
|
||||||
case "allow":
|
case "allow":
|
||||||
@ -95,22 +104,22 @@
|
|||||||
notify({
|
notify({
|
||||||
url,
|
url,
|
||||||
errorStack: error.stack,
|
errorStack: error.stack,
|
||||||
messageId, timestamp: new Date(),
|
messageId,
|
||||||
|
timestamp: new Date(),
|
||||||
functionName: name,
|
functionName: name,
|
||||||
dataURL:
|
dataURL:
|
||||||
prefs("storeImageForInspection") &&
|
prefs("storeImageForInspection") &&
|
||||||
prefs("showNotifications")
|
prefs("showNotifications")?
|
||||||
?
|
|
||||||
(
|
|
||||||
this instanceof HTMLCanvasElement?
|
|
||||||
this.toDataURL():
|
|
||||||
(
|
(
|
||||||
this.canvas instanceof HTMLCanvasElement?
|
this instanceof HTMLCanvasElement?
|
||||||
this.canvas.toDataURL():
|
this.toDataURL():
|
||||||
false
|
(
|
||||||
)
|
this.canvas instanceof HTMLCanvasElement?
|
||||||
):
|
this.canvas.toDataURL():
|
||||||
false
|
false
|
||||||
|
)
|
||||||
|
):
|
||||||
|
false
|
||||||
});
|
});
|
||||||
}, window, original);
|
}, window, original);
|
||||||
switch (fake){
|
switch (fake){
|
||||||
|
12
lib/lists.js
12
lib/lists.js
@ -49,13 +49,13 @@
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
list.match = function(url){
|
list.match = function(url){
|
||||||
return this.some(function(entry){
|
return this.some(function(entry){
|
||||||
return entry.match(url);
|
return entry.match(url);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
var lists = {
|
var lists = {
|
||||||
|
@ -59,10 +59,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function error (...args){performLog( 1, args);}
|
function error (...args){performLog(1, args);}
|
||||||
function warning(...args){performLog( 25, args);}
|
function warning(...args){performLog(25, args);}
|
||||||
function message(...args){performLog( 50, args);}
|
function message(...args){performLog(50, args);}
|
||||||
function notice (...args){performLog( 75, args);}
|
function notice (...args){performLog(75, args);}
|
||||||
function verbose(...args){performLog(100, args);}
|
function verbose(...args){performLog(100, args);}
|
||||||
function metaLog(...args){performLog(999, args);}
|
function metaLog(...args){performLog(999, args);}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@
|
|||||||
// old code
|
// old code
|
||||||
// const {when: unload} = require("sdk/system/unload");
|
// const {when: unload} = require("sdk/system/unload");
|
||||||
// unload(function(){
|
// unload(function(){
|
||||||
// processes.port.emit("canvasBlocker-unload");
|
// processes.port.emit("canvasBlocker-unload");
|
||||||
// });
|
// });
|
||||||
|
|
||||||
browser.runtime.onInstalled.addListener(function(){
|
browser.runtime.onInstalled.addListener(function(){
|
||||||
|
14
lib/webgl.js
14
lib/webgl.js
@ -69,12 +69,12 @@
|
|||||||
var positionBuffer = context.createBuffer();
|
var positionBuffer = context.createBuffer();
|
||||||
context.bindBuffer(context.ARRAY_BUFFER, positionBuffer);
|
context.bindBuffer(context.ARRAY_BUFFER, positionBuffer);
|
||||||
context.bufferData(context.ARRAY_BUFFER, new Float32Array([
|
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);
|
]), context.STATIC_DRAW);
|
||||||
|
|
||||||
@ -84,7 +84,7 @@
|
|||||||
var normalize = false; // don't normalize the data
|
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 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
|
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");
|
var texCoordLocation = context.getAttribLocation(program, "a_texCoord");
|
||||||
|
|
||||||
|
@ -208,15 +208,6 @@
|
|||||||
"displayAdvancedSettings": [true]
|
"displayAdvancedSettings": [true]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// {
|
|
||||||
// "name": "notificationDisplayTime",
|
|
||||||
// "title": "notification display time",
|
|
||||||
// "type": "integer",
|
|
||||||
// "value": 30,
|
|
||||||
// "displayDependencies": {
|
|
||||||
// "blockMode": ["fakeReadout", "fakeInput"]
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
"name": "ignoreList",
|
"name": "ignoreList",
|
||||||
"title": "Ignore list",
|
"title": "Ignore list",
|
||||||
@ -253,7 +244,8 @@
|
|||||||
"displayAdvancedSettings": [true]
|
"displayAdvancedSettings": [true]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},{
|
},
|
||||||
|
{
|
||||||
"name": "enableStackList",
|
"name": "enableStackList",
|
||||||
"title": "Use file specific scoped white list",
|
"title": "Use file specific scoped white list",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
@ -316,8 +308,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
].forEach(function(pref){
|
].forEach(function(pref){
|
||||||
var html = "<td><div class=\"content\"><span class=\"title\">__MSG_" + pref.name + "_title__</span><div class=\"description\">__MSG_" + pref.name + "_description__</div></div></td><td><div class=\"content\">";
|
var html = "<td><div class=\"content\">" +
|
||||||
var inputAttributes = " data-storage-name=\"" + pref.name + "\" data-storage-type=\"" + pref.type + "\" class=\"setting\"";
|
"<span class=\"title\">__MSG_" + pref.name + "_title__</span>" +
|
||||||
|
"<div class=\"description\">__MSG_" + pref.name + "_description__</div>" +
|
||||||
|
"</div></td><td><div class=\"content\">";
|
||||||
|
var inputAttributes =
|
||||||
|
" data-storage-name=\"" + pref.name + "\"" +
|
||||||
|
" data-storage-type=\"" + pref.type + "\"" +
|
||||||
|
" class=\"setting\"";
|
||||||
switch (pref.type){
|
switch (pref.type){
|
||||||
case "integer":
|
case "integer":
|
||||||
html += "<input type=\"number\"" + inputAttributes + " value=\"" + pref.value + "\">";
|
html += "<input type=\"number\"" + inputAttributes + " value=\"" + pref.value + "\">";
|
||||||
@ -326,13 +324,20 @@
|
|||||||
html += "<input type=\"text\"" + inputAttributes + " value=\"" + pref.value + "\">";
|
html += "<input type=\"text\"" + inputAttributes + " value=\"" + pref.value + "\">";
|
||||||
break;
|
break;
|
||||||
case "bool":
|
case "bool":
|
||||||
html += "<input type=\"checkbox\" style=\"display: inline\"" + inputAttributes + (pref.value? " checked=\"checked\"": "") + ">";
|
html += "<input type=\"checkbox\" style=\"display: inline\"" +
|
||||||
|
inputAttributes +
|
||||||
|
(pref.value? " checked=\"checked\"": "") +
|
||||||
|
">";
|
||||||
break;
|
break;
|
||||||
case "menulist":
|
case "menulist":
|
||||||
html += "<select" + inputAttributes + "data-type=\"" + (typeof pref.value) + "\">" +
|
html += "<select" + inputAttributes + "data-type=\"" + (typeof pref.value) + "\">" +
|
||||||
pref.options.map(function(option){
|
pref.options.map(function(option){
|
||||||
if (option.value !== ""){
|
if (option.value !== ""){
|
||||||
return "<option value=\"" + option.value + "\"" + (option.value === pref.value? " selected": "") + ">__MSG_" + pref.name + "_options." + option.label + "__</option>";
|
return "<option value=\"" + option.value + "\"" +
|
||||||
|
(option.value === pref.value? " selected": "") +
|
||||||
|
">" +
|
||||||
|
"__MSG_" + pref.name + "_options." + option.label + "__" +
|
||||||
|
"</option>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "<option disabled>----------------</option>";
|
return "<option disabled>----------------</option>";
|
||||||
|
@ -74,11 +74,6 @@
|
|||||||
showReleaseNotes: function(){
|
showReleaseNotes: function(){
|
||||||
logging.verbose("open release notes");
|
logging.verbose("open release notes");
|
||||||
window.open("../releaseNotes.txt", "_blank");
|
window.open("../releaseNotes.txt", "_blank");
|
||||||
// would be nicer but is not supported in fennec
|
|
||||||
// browser.windows.create({
|
|
||||||
// url: "../releaseNotes.txt",
|
|
||||||
// type: "popup"
|
|
||||||
// });
|
|
||||||
},
|
},
|
||||||
clearPersistentRnd: function(){
|
clearPersistentRnd: function(){
|
||||||
logging.message("clear persistent rnd storage");
|
logging.message("clear persistent rnd storage");
|
||||||
@ -104,7 +99,11 @@
|
|||||||
var displayDependencies = row.setting.displayDependencies;
|
var displayDependencies = row.setting.displayDependencies;
|
||||||
if (displayDependencies){
|
if (displayDependencies){
|
||||||
row.classList[(
|
row.classList[(
|
||||||
(Array.isArray(displayDependencies)? displayDependencies: [displayDependencies]).some(function(displayDependency){
|
(
|
||||||
|
Array.isArray(displayDependencies)?
|
||||||
|
displayDependencies:
|
||||||
|
[displayDependencies]
|
||||||
|
).some(function(displayDependency){
|
||||||
return Object.keys(displayDependency).every(function(key){
|
return Object.keys(displayDependency).every(function(key){
|
||||||
return displayDependency[key].indexOf(settings[key]) !== -1;
|
return displayDependency[key].indexOf(settings[key]) !== -1;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user