diff options
author | hackademix | 2018-07-02 01:50:32 +0200 |
---|---|---|
committer | hackademix | 2018-07-02 01:50:32 +0200 |
commit | 81bd93a72d0b49fd78908f7c467ae9f324791e23 (patch) | |
tree | daacfeb158f1f6512532d7e4ccafc6da68494aa4 /src/content | |
parent | 673c881559e4f9274be5b54ca35552e12cd8cd76 (diff) | |
download | noscript-81bd93a72d0b49fd78908f7c467ae9f324791e23.tar.gz noscript-81bd93a72d0b49fd78908f7c467ae9f324791e23.tar.xz noscript-81bd93a72d0b49fd78908f7c467ae9f324791e23.zip |
Simplified and apparently more reliable+flexible+efficient dynamic script injection method.
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/media.js | 27 | ||||
-rw-r--r-- | src/content/webglHook.js | 2 |
2 files changed, 17 insertions, 12 deletions
diff --git a/src/content/media.js b/src/content/media.js index 22bf014..4ca8942 100644 --- a/src/content/media.js +++ b/src/content/media.js @@ -1,4 +1,4 @@ -console.log("Media Hook", document.documentElement.innerHTML); +debug("Media Hook (blocked %s)", !!window.mediaBlocker, document.URL, document.documentElement && document.documentElement.innerHTML); try { (() => { let unpatched = new Map(); @@ -25,9 +25,6 @@ try { patch(window.MediaSource.prototype, "addSourceBuffer", function(mime, ...args) { let ms = this; let urls = urlMap.get(ms); - let me = Array.from(document.querySelectorAll("video,audio")) - .find(e => e.srcObject === ms || urls && urls.has(e.src)); - let exposedMime = `${mime} (MSE)`; let request = { id: "noscript-media", @@ -40,13 +37,21 @@ try { notifyPage(); if (window.mediaBlocker) { - try { - let ph = PlaceHolder.create("media", request); - ph.replace(me); - PlaceHolder.listen(); - } catch (e) { - error(e); - } + (async () => { + let me = Array.from(document.querySelectorAll("video,audio")) + .find(e => e.srcObject === ms || urls && urls.has(e.src)); + + if (!me) return; + let exposedMime = `${mime} (MSE)`; + + try { + let ph = PlaceHolder.create("media", request); + ph.replace(me); + PlaceHolder.listen(); + } catch (e) { + error(e); + } + })(); throw new Error(`${exposedMime} blocked by NoScript`); } diff --git a/src/content/webglHook.js b/src/content/webglHook.js index ba0d769..5b83025 100644 --- a/src/content/webglHook.js +++ b/src/content/webglHook.js @@ -1,4 +1,4 @@ -console.log("WebGL Hook", document.documentElement.innerHTML); +console.log("WebGL Hook", document.URL, document.documentElement && document.documentElement.innerHTML); try { let proto = HTMLCanvasElement.prototype; let getContext = proto.getContext; |