diff options
author | hackademix | 2018-08-26 17:43:01 +0200 |
---|---|---|
committer | hackademix | 2018-08-27 18:55:00 +0200 |
commit | 6e80d3f130773fc9a9123c5c4c2e97d63e90fa2a (patch) | |
tree | ed610783c9f36b5625179bff318194bd118c53f0 /src/content/content.js | |
parent | e82e961dd75401cd78c5b46c7dde4e197557b385 (diff) | |
download | noscript-6e80d3f130773fc9a9123c5c4c2e97d63e90fa2a.tar.gz noscript-6e80d3f130773fc9a9123c5c4c2e97d63e90fa2a.tar.xz noscript-6e80d3f130773fc9a9123c5c4c2e97d63e90fa2a.zip |
Let content script inject failsafe CSP in the DOM.
Diffstat (limited to 'src/content/content.js')
-rw-r--r-- | src/content/content.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/content/content.js b/src/content/content.js index 8ab3654..a5d996d 100644 --- a/src/content/content.js +++ b/src/content/content.js @@ -61,14 +61,21 @@ if (!this.perms.DEFAULT || this.perms.tabInfo.unrestricted) { this.allows = () => true; + this.capabilities = Object.assign( + new Set(["script"]), { has() { return true; } }); + } else { + let perms = this.perms.CURRENT || this.perms.DEFAULT; + this.capabilities = new Set(perms.capabilities); + new DocumentCSP(document).apply(this.capabilities); } ns.fire("perms"); }, perms: { DEFAULT: null, CURRENT: null, tabInfo: {}, MARKER: "" }, + allows(cap) { - let perms = this.perms.CURRENT; - return perms && perms.capabilities.includes(cap); + return this.capabilities && this.capabilities.has(cap); }, + getWindowName() { return top !== window || !this.perms.MARKER ? window.name : window.name.split(this.perms.MARKER + ",").pop(); |