diff options
author | hackademix | 2018-08-18 03:16:54 +0200 |
---|---|---|
committer | hackademix | 2018-08-18 03:20:33 +0200 |
commit | 2f9c5299afe0d612deff7f89c948bb44332f2abf (patch) | |
tree | 343fe4435bef995b4029656563ce6194829ea641 /src/content | |
parent | e959accb70ea00f99fa611c9f1af40e1be5bde92 (diff) | |
download | noscript-2f9c5299afe0d612deff7f89c948bb44332f2abf.tar.gz noscript-2f9c5299afe0d612deff7f89c948bb44332f2abf.tar.xz noscript-2f9c5299afe0d612deff7f89c948bb44332f2abf.zip |
Removed all references to RequestUtil.js and dependancies.
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/content.js | 27 | ||||
-rw-r--r-- | src/content/media.js | 6 | ||||
-rw-r--r-- | src/content/webglHook.js | 3 |
3 files changed, 20 insertions, 16 deletions
diff --git a/src/content/content.js b/src/content/content.js index 2f10d5a..8f772b1 100644 --- a/src/content/content.js +++ b/src/content/content.js @@ -3,23 +3,30 @@ // debug = () => {}; // REL_ONLY { let listenersMap = new Map(); + let backlog = new Set(); var ns = { on(eventName, listener) { let listeners = listenersMap.get(eventName); if (!listeners) listenersMap.set(eventName, listeners = new Set()); listeners.add(listener); + if (backlog.has(eventName)) this.fire(eventName, listener); }, detach(eventName, listener) { let listeners = listenersMap.get(eventName); if (listeners) listeners.delete(listener); }, - fire(eventName) { + fire(eventName, listener = null) { + if (listener) { + listener({type:eventName, source: this}); + return; + } let listeners = listenersMap.get(eventName); if (listeners) { for (let l of listeners) { - l(this); + this.fire(eventName, l); } } + backlog.add(eventName); }, setup(DEFAULT, MARKER) { this.perms.DEFAULT = DEFAULT; @@ -36,10 +43,10 @@ let tabInfoRx = new RegExp(`^${MARKER}\\[([^]*?)\\]${MARKER},`); if (top === window) { // wrap to hide Reflect.defineProperty(top.wrappedJSObject, "name", { - get: exportFunction(() => _name.replace(eraseTabInfoRx, ""), top.wrappedJSObject), + get: exportFunction(() => top.name.replace(eraseTabInfoRx, ""), top.wrappedJSObject), set: exportFunction(value => { - let preamble = _name.match(tabInfoRx); - _name = `${preamble && preamble[0] || ""}${value}`; + let preamble = top.name.match(tabInfoRx); + top.name = `${preamble && preamble[0] || ""}${value}`; return value; }, top.wrappedJSObject) }); @@ -57,14 +64,14 @@ } ns.fire("perms"); }, - storeTabInfo(info) { - let {MARKER} = this.perms; - window.name = `${MARKER}${JSON.stringify([info])}${MARKER},${window.name.split(marker).pop()}`; - }, - perms: { DEFAULT: null, CURRENT: null, tabInfo: {} }, + perms: { DEFAULT: null, CURRENT: null, tabInfo: {}, MARKER: "" }, allows(cap) { let perms = this.perms.CURRENT; return perms && perms.capabilities.includes(cap); + }, + getWindowName() { + return top !== window || !this.perms.MARKER ? window.name + : window.name.split(this.perms.MARKER + ",").pop(); } } } diff --git a/src/content/media.js b/src/content/media.js index 5da239f..910fd27 100644 --- a/src/content/media.js +++ b/src/content/media.js @@ -1,4 +1,4 @@ -ns.on("perms", ns => { +ns.on("perms", event => { debug("Media Hook", document.URL, document.documentElement && document.documentElement.innerHTML, ns.perms.CURRENT); // DEV_ONLY let mediaBlocker = !ns.allows("media"); let unpatched = new Map(); @@ -54,6 +54,4 @@ ns.on("perms", ns => { return unpatched.get(window.MediaSource.prototype).addSourceBuffer.call(ms, mime, ...args); }); - -})(); -document.URL; +}); diff --git a/src/content/webglHook.js b/src/content/webglHook.js index 67f31eb..efafcd5 100644 --- a/src/content/webglHook.js +++ b/src/content/webglHook.js @@ -1,4 +1,4 @@ -ns.on("perms", ns => { +ns.on("perms", event => { debug("WebGL Hook", document.URL, document.documentElement && document.documentElement.innerHTML, ns.perms.CURRENT); // DEV_ONLY if (ns.allows("webgl")) return; let proto = HTMLCanvasElement.prototype; @@ -26,4 +26,3 @@ ns.on("perms", ns => { return getContext.call(this, type, ...rest); }, proto, {defineAs: "getContext"}); }); -document.URL; |