summaryrefslogtreecommitdiff
path: root/src/bg/ChildPolicies.js
diff options
context:
space:
mode:
authorhackademix2018-10-13 10:08:37 +0200
committerhackademix2018-10-13 10:08:37 +0200
commit808fd652be324098b3083302bc3218e47a11aba5 (patch)
treee6c53d53ad578f871c0cbca8126921045b4d5e07 /src/bg/ChildPolicies.js
parente44fce3ebd6c348b9e09304d8b79e90f3867bd60 (diff)
downloadnoscript-808fd652be324098b3083302bc3218e47a11aba5.tar.gz
noscript-808fd652be324098b3083302bc3218e47a11aba5.tar.xz
noscript-808fd652be324098b3083302bc3218e47a11aba5.zip
Use cookie instead of window.name as a tab-configuration hack.
Diffstat (limited to 'src/bg/ChildPolicies.js')
-rw-r--r--src/bg/ChildPolicies.js27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/bg/ChildPolicies.js b/src/bg/ChildPolicies.js
index f3845bd..b6904f8 100644
--- a/src/bg/ChildPolicies.js
+++ b/src/bg/ChildPolicies.js
@@ -1,6 +1,6 @@
"use strict";
{
- let marker = JSON.stringify(uuid());
+ let marker = uuid();
let allUrls = ["<all_urls>"];
let Scripts = {
@@ -47,7 +47,7 @@
if (typeof perms !== "string") {
perms = JSON.stringify(perms);
}
- return `ns.setup(${perms}, ${marker});`
+ return `ns.setup(${perms}, "${marker}");`
}
};
@@ -104,18 +104,17 @@
: [];
var ChildPolicies = {
- async storeTabInfo(tabId, info) {
- try {
- let preamble = info ? `${marker} + ${JSON.stringify(JSON.stringify([info]))} + ${marker} + "," + ` : "";
- await browser.tabs.executeScript(tabId, {
- code: `window.name = ${preamble}window.name.split(${marker} + ",").pop();`,
- allFrames: true,
- matchAboutBlank: true,
- runAt: "document_start",
- });
- } catch (e) {
- error(e);
+ addTabInfoCookie(request, info) {
+ let h = {
+ name: "Set-Cookie",
+ value: `${marker}=${JSON.stringify(info)}`
+ };
+ let {responseHeaders} = request;
+ if (responseHeaders.some(({value, name}) => h.value === value && h.name === name)) {
+ return false;
}
+ responseHeaders.push(h);
+ return true;
},
async update(policy, tracing) {
if (tracing !== "undefined") Scripts.debug = tracing;
@@ -123,7 +122,7 @@
await Scripts.init();
if (!policy.enforced) {
- await Scripts.register(`ns.setup(null, ${marker});`, allUrls);
+ await Scripts.register(Scripts.buildPerms("null"), allUrls);
return;
}