1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-06-04 12:27:51 +02:00

Added better logging to frame.js and separated settings update from defaultSettings.js

This commit is contained in:
kkapsner 2017-07-07 08:49:12 +02:00
parent 97c9f1c94b
commit 18a2e32044
2 changed files with 34 additions and 19 deletions

View File

@ -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;
});
}
});
}());
};

View File

@ -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;
});
}
});
}());