mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 21:00:23 +01:00
WebExtension: added embedded WebExtension to store the preferences for the transition
This commit is contained in:
parent
a9c7d97708
commit
a6e1b05045
@ -15,6 +15,8 @@
|
|||||||
const preferences = require("sdk/simple-prefs");
|
const preferences = require("sdk/simple-prefs");
|
||||||
const prefs = preferences.prefs;
|
const prefs = preferences.prefs;
|
||||||
|
|
||||||
|
require("./webExtension");
|
||||||
|
|
||||||
const notificationPref = {
|
const notificationPref = {
|
||||||
doShow: function(){
|
doShow: function(){
|
||||||
return prefs.showNotifications;
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}());
|
@ -172,11 +172,12 @@
|
|||||||
"version": "0.3.8-Development",
|
"version": "0.3.8-Development",
|
||||||
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"firefox": ">=45.0a1",
|
"firefox": ">=50.0",
|
||||||
"fennec": ">=45.0"
|
"fennec": ">=50.0"
|
||||||
},
|
},
|
||||||
"permissions": {
|
"permissions": {
|
||||||
"private-browsing": true,
|
"private-browsing": true,
|
||||||
"multiprocess": true
|
"multiprocess": true
|
||||||
}
|
},
|
||||||
|
"hasEmbeddedWebExtension": true
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ Version 0.3.8:
|
|||||||
-
|
-
|
||||||
|
|
||||||
new features:
|
new features:
|
||||||
-
|
- added embedded WebExtension to store the preferences for the transition
|
||||||
|
|
||||||
fixes:
|
fixes:
|
||||||
- prevented error when canvas has size zero
|
- prevented error when canvas has size zero
|
||||||
|
18
webextension/background.js
Normal file
18
webextension/background.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/* 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(){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
browser.storage.local.set({
|
||||||
|
storageVersion: 0.1
|
||||||
|
});
|
||||||
|
|
||||||
|
var port = browser.runtime.connect();
|
||||||
|
port.onMessage.addListener(function(data){
|
||||||
|
if (data){
|
||||||
|
browser.storage.local.set(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}());
|
11
webextension/manifest.json
Normal file
11
webextension/manifest.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"manifest_version": 2,
|
||||||
|
"name": "embeddedCanvasBlocker@kkapsner.de",
|
||||||
|
"version": "0.1",
|
||||||
|
"background": {
|
||||||
|
"scripts": ["background.js"]
|
||||||
|
},
|
||||||
|
"permissions": [
|
||||||
|
"storage"
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user