summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhackademix2019-12-25 23:09:56 +0100
committerhackademix2019-12-25 23:09:56 +0100
commite2f7de8fea002f15c7cc66ea0d3b565919ec4de3 (patch)
tree1a949668ac20d81e8aca3281a78bdbcc06a845a9 /src
parent98aff587716024deff8ba5a6de6247ac44063611 (diff)
downloadnoscript-e2f7de8fea002f15c7cc66ea0d3b565919ec4de3.tar.gz
noscript-e2f7de8fea002f15c7cc66ea0d3b565919ec4de3.tar.xz
noscript-e2f7de8fea002f15c7cc66ea0d3b565919ec4de3.zip
Added "ping" (beacon/ping) capability control.
Diffstat (limited to 'src')
-rw-r--r--src/_locales/en/messages.json3
-rw-r--r--src/bg/main.js15
-rw-r--r--src/common/Policy.js3
-rw-r--r--src/ui/ui.js2
4 files changed, 20 insertions, 3 deletions
diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json
index 722eb00..a9a18a7 100644
--- a/src/_locales/en/messages.json
+++ b/src/_locales/en/messages.json
@@ -567,6 +567,9 @@
"cap_fetch": {
"message": "fetch"
},
+ "cap_ping": {
+ "message": "ping"
+ },
"cap_other": {
"message": "other"
},
diff --git a/src/bg/main.js b/src/bg/main.js
index fa58b3a..b1874f4 100644
--- a/src/bg/main.js
+++ b/src/bg/main.js
@@ -1,6 +1,19 @@
{
'use strict';
-
+ {
+ let onInstalled = async details => {
+ browser.runtime.onInstalled.removeListener(onInstalled);
+ let {reason, previousVersion} = details;
+ if (reason !== "update") return;
+ let v = previousVersion.split(".").map(n => parseInt(n));
+ if (v[0] > 11 || v[1] > 0 || v[2] > 10) return;
+ log(`Upgrading from 11.0.10 or below (${previousVersion}): configure the "ping" capability.`);
+ await ns.initializing;
+ ns.policy.TRUSTED.capabilities.add("ping")
+ await ns.savePolicy();
+ };
+ browser.runtime.onInstalled.addListener(onInstalled);
+ }
let popupURL = browser.extension.getURL("/ui/popup.html");
let popupFor = tabId => `${popupURL}#tab${tabId}`;
diff --git a/src/common/Policy.js b/src/common/Policy.js
index e7818d9..4720532 100644
--- a/src/common/Policy.js
+++ b/src/common/Policy.js
@@ -274,7 +274,7 @@ var {Permissions, Policy, Sites} = (() => {
}
- Permissions.ALL = ["script", "object", "media", "frame", "font", "webgl", "fetch", "other"];
+ Permissions.ALL = ["script", "object", "media", "frame", "font", "webgl", "fetch", "ping", "other"];
Permissions.IMMUTABLE = {
UNTRUSTED: {
"script": false,
@@ -282,6 +282,7 @@ var {Permissions, Policy, Sites} = (() => {
"webgl": false,
"fetch": false,
"other": false,
+ "ping": false,
},
TRUSTED: {
"script": true,
diff --git a/src/ui/ui.js b/src/ui/ui.js
index 7025ce6..dafba4f 100644
--- a/src/ui/ui.js
+++ b/src/ui/ui.js
@@ -304,7 +304,7 @@ var UI = (() => {
capInput.id = `capability-${capability}-${idSuffix}`
capLabel.setAttribute("for", capInput.id);
capInput.value = capability;
- capInput.title = capLabel.textContent = _(`cap_${capability}`);
+ capInput.title = capLabel.textContent = _(`cap_${capability}`) || capability;
let clone = capParent.appendChild(cap.cloneNode(true));
clone.classList.add(capability);
}