From 57eaa94dde7f2a2865c74dbb6c895fdf93162cab Mon Sep 17 00:00:00 2001 From: hackademix Date: Tue, 3 Jul 2018 19:36:39 +0200 Subject: Backport dynamic script injection to Tor Browser / Fx ESR60. --- src/bg/RequestUtil.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/bg') diff --git a/src/bg/RequestUtil.js b/src/bg/RequestUtil.js index a62f139..13a017e 100644 --- a/src/bg/RequestUtil.js +++ b/src/bg/RequestUtil.js @@ -39,10 +39,8 @@ let filter = browser.webRequest.filterResponseData(requestId); let buffer = []; let content = this.getContentMetaData(request); - filter.onstart = async event => { - if (/ml$/i.test(content.type)) { - filter.write(new Uint8Array()); // work-around for https://bugzilla.mozilla.org/show_bug.cgi?id=1410755 - } + let first = true; + let execute = async () => { for (let details of scripts.values()) { details = Object.assign({ runAt: "document_start", @@ -64,7 +62,17 @@ buffer = null; } }; + filter.onstart = event => { + if (/ml$/i.test(content.type)) { + filter.write(new Uint8Array()); // work-around for https://bugzilla.mozilla.org/show_bug.cgi?id=1410755 + } + } filter.ondata = event => { + if (first) { + execute(); + first = false; + } + if (buffer) { buffer.push(event.data); return; -- cgit v1.2.3