diff --git a/lib/main.js b/lib/main.js index 13abc32..43b95aa 100644 --- a/lib/main.js +++ b/lib/main.js @@ -15,6 +15,8 @@ const preferences = require("sdk/simple-prefs"); const prefs = preferences.prefs; + require("./webExtension"); + const notificationPref = { doShow: function(){ return prefs.showNotifications; diff --git a/lib/webExtension.js b/lib/webExtension.js new file mode 100644 index 0000000..2af9875 --- /dev/null +++ b/lib/webExtension.js @@ -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); + }); + } + }); + }); + }); +}()); \ No newline at end of file diff --git a/package.json b/package.json index 57ea37b..52073c3 100644 --- a/package.json +++ b/package.json @@ -172,11 +172,12 @@ "version": "0.3.8-Development", "engines": { - "firefox": ">=45.0a1", - "fennec": ">=45.0" + "firefox": ">=50.0", + "fennec": ">=50.0" }, "permissions": { "private-browsing": true, "multiprocess": true - } + }, + "hasEmbeddedWebExtension": true } diff --git a/releaseNotes.txt b/releaseNotes.txt index 5c97914..9943708 100644 --- a/releaseNotes.txt +++ b/releaseNotes.txt @@ -3,7 +3,7 @@ Version 0.3.8: - new features: - - + - added embedded WebExtension to store the preferences for the transition fixes: - prevented error when canvas has size zero diff --git a/webextension/background.js b/webextension/background.js new file mode 100644 index 0000000..cc1380c --- /dev/null +++ b/webextension/background.js @@ -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); + } + }); +}()); \ No newline at end of file diff --git a/webextension/manifest.json b/webextension/manifest.json new file mode 100644 index 0000000..d4673f6 --- /dev/null +++ b/webextension/manifest.json @@ -0,0 +1,11 @@ +{ + "manifest_version": 2, + "name": "embeddedCanvasBlocker@kkapsner.de", + "version": "0.1", + "background": { + "scripts": ["background.js"] + }, + "permissions": [ + "storage" + ] +} \ No newline at end of file