mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-03 12:06:31 +02:00
WebExtension: added embedded WebExtension to store the preferences for the transition
This commit is contained in:
parent
a9c7d97708
commit
a6e1b05045
6 changed files with 63 additions and 4 deletions
|
@ -15,6 +15,8 @@
|
|||
const preferences = require("sdk/simple-prefs");
|
||||
const prefs = preferences.prefs;
|
||||
|
||||
require("./webExtension");
|
||||
|
||||
const notificationPref = {
|
||||
doShow: function(){
|
||||
return prefs.showNotifications;
|
||||
|
|
27
lib/webExtension.js
Normal file
27
lib/webExtension.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* jslint moz: true */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
(function(){
|
||||
const webExtension = require("sdk/webextension");
|
||||
const preferences = require("sdk/simple-prefs");
|
||||
const prefs = preferences.prefs;
|
||||
// console.log("starting webExtension");
|
||||
webExtension.startup().then(function(api){
|
||||
api.browser.runtime.onConnect.addListener(function(port){
|
||||
var prefNames = Object.keys(prefs);
|
||||
// console.log("syncing prefs", prefNames);
|
||||
prefNames.forEach(function(name){
|
||||
if (!name.startsWith("sdk.")){
|
||||
var obj = {};
|
||||
obj[name] = prefs[name];
|
||||
port.postMessage(obj);
|
||||
preferences.on(name, function(){
|
||||
obj[name] = prefs[name];
|
||||
port.postMessage(obj);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}());
|
Loading…
Add table
Add a link
Reference in a new issue