1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 12:50:36 +01:00

Ping back after the port opening to the background script now also returns the settings and the persistentRnd data.

This commit is contained in:
kkapsner 2017-09-23 23:37:46 +02:00
parent e5e38e148e
commit a4a92fc2f9
2 changed files with 27 additions and 2 deletions

View File

@ -7,9 +7,11 @@
const {intercept} = require("./intercept.js");
const {ask} = require("./askForPermission.js");
const lists = require("./lists.js");
const {check: originalCheck, checkStack: originalCheckStack} = require("./check.js");
const {error, warning, message, notice, verbose, setPrefix: setLogPrefix} = require("./logging");
const logging = require("./logging");
const {error, warning, message, notice, verbose, setPrefix: setLogPrefix} = logging;
setLogPrefix("frame script");
// Variable to "unload" the script
@ -49,6 +51,23 @@
notice("my tab id is", data.tabId);
tabId = data.tabId;
}
if (data.hasOwnProperty("persistentRnd")){
notice("got persistent random data", data.persistentRnd);
const {persistent: persistentRnd} = require("./randomSupplies.js");
Object.keys(data.persistentRnd).forEach(function(domain){
verbose("random data for", domain, data.persistentRnd[domain]);
persistentRnd.setDomainRnd(domain, data.persistentRnd[domain]);
});
}
if (settings.isStillDefault && data.hasOwnProperty("settings")){
notice("got settings from background script");
Object.keys(data.settings).forEach(function(key){
settings[key] = data.settings[key];
});
settings.isStillDefault = false;
logging.clearQueue();
lists.updateAll();
}
});
var notifications = [];
function notify(data){

View File

@ -82,7 +82,13 @@
browser.runtime.onConnect.addListener(function(port){
notice("got port", port);
verbose("send back the tab id", port.sender.tab.id);
port.postMessage({tabId: port.sender.tab.id});
verbose("send back the persistend random seeds", persistentRnd);
verbose("send back the settings", settings);
port.postMessage({
tabId: port.sender.tab.id,
persistentRnd: persistentRnd,
settings: settings
});
var url = new URL(port.sender.url);
port.onMessage.addListener(function(data){
browser.storage.local.get("showNotifications").then(function(data){