mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +01:00
Added better logging to frame.js and separated settings update from defaultSettings.js
This commit is contained in:
parent
97c9f1c94b
commit
18a2e32044
@ -1,14 +1,4 @@
|
||||
"use strict";
|
||||
|
||||
var settings = {
whiteList: "",
blackList: "",
blockMode: "fakeReadout",
maxFakeSize: 0,
rng: "nonPersistent",
persistentRndStorage: "",
storePersistentRnd: false,
askOnlyOnce: true,
showNotifications: true,
notificationDisplayTime: 30,
ignoreList: "",
showCallingFile: false,
showCompleteCallingStack: false,
enableStackList: false,
stackList: ""
|
||||
};
|
||||
|
||||
(function(){
|
||||
browser.storage.onChanged.addListener(function(change, area){
|
||||
if (area === "local"){
|
||||
Object.keys(change).forEach(function(key){
|
||||
settings[key] = change[key].newValue;
|
||||
});
|
||||
}
|
||||
});
|
||||
}());
|
||||
};
|
41
lib/frame.js
41
lib/frame.js
@ -4,6 +4,25 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
(function(){
|
||||
"use strict";
|
||||
function log(...args){
|
||||
function leftPad(str, char, pad){
|
||||
str = "" + str;
|
||||
return char.repeat(pad - str.length) + str;
|
||||
}
|
||||
args.unshift("frame script:");
|
||||
var now = new Date();
|
||||
args.unshift(
|
||||
now.getFullYear() + "-" +
|
||||
leftPad(now.getMonth() + 1, "0", 2) + "-" +
|
||||
leftPad(now.getDate(), "0", 2) + " " +
|
||||
leftPad(now.getHours(), "0", 2) + ":" +
|
||||
leftPad(now.getMinutes(), "0", 2) + ":" +
|
||||
leftPad(now.getSeconds(), "0", 2) + "." +
|
||||
leftPad(now.getMilliseconds(), "0", 3)
|
||||
);
|
||||
console.log.apply(console, args);
|
||||
}
|
||||
|
||||
const {intercept} = require("./intercept.js");
|
||||
const {ask} = require("./askForPermission.js");
|
||||
const {check: originalCheck, checkStack: originalCheckStack} = require("./check.js");
|
||||
@ -11,7 +30,7 @@
|
||||
// Variable to "unload" the script
|
||||
var enabled = true;
|
||||
|
||||
|
||||
log("starting", location.href);
|
||||
|
||||
function check(message){
|
||||
if (enabled){
|
||||
@ -40,7 +59,7 @@
|
||||
var tabId;
|
||||
port.onMessage.addListener(function(data){
|
||||
if (data.hasOwnProperty("tabId")){
|
||||
console.log("my tab id is", data.tabId);
|
||||
log("my tab id is", data.tabId);
|
||||
tabId = data.tabId;
|
||||
}
|
||||
});
|
||||
@ -50,7 +69,6 @@
|
||||
port.postMessage({"canvasBlocker-notify": data});
|
||||
}
|
||||
|
||||
|
||||
const preferences = require("sdk/simple-prefs");
|
||||
function prefs(name){
|
||||
return preferences.prefs[name];
|
||||
@ -59,7 +77,7 @@
|
||||
|
||||
var interceptedWindows = new WeakMap();
|
||||
function interceptWindow(window){
|
||||
if (interceptedWindows.get(window)){
|
||||
if (!enabled || interceptedWindows.get(window)){
|
||||
return false;
|
||||
}
|
||||
intercept(
|
||||
@ -102,10 +120,8 @@
|
||||
return true;
|
||||
};
|
||||
|
||||
if (enabled){
|
||||
interceptWindow(window);
|
||||
}
|
||||
|
||||
interceptWindow(window);
|
||||
|
||||
browser.runtime.onMessage.addListener(function(data){
|
||||
if (data["canvasBlocker-unload"]){
|
||||
enabled = false;
|
||||
@ -117,4 +133,13 @@
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
browser.storage.onChanged.addListener(function(change, area){
|
||||
if (area === "local"){
|
||||
Object.keys(change).forEach(function(key){
|
||||
settings[key] = change[key].newValue;
|
||||
});
|
||||
}
|
||||
});
|
||||
}());
|
Loading…
x
Reference in New Issue
Block a user