Skip to content

Commit 57eaa94

Browse files
committed
Backport dynamic script injection to Tor Browser / Fx ESR60.
1 parent 8ae9513 commit 57eaa94

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/bg/RequestUtil.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@
3939
let filter = browser.webRequest.filterResponseData(requestId);
4040
let buffer = [];
4141
let content = this.getContentMetaData(request);
42-
filter.onstart = async event => {
43-
if (/ml$/i.test(content.type)) {
44-
filter.write(new Uint8Array()); // work-around for https://bugzilla.mozilla.org/show_bug.cgi?id=1410755
45-
}
42+
let first = true;
43+
let execute = async () => {
4644
for (let details of scripts.values()) {
4745
details = Object.assign({
4846
runAt: "document_start",
@@ -64,7 +62,17 @@
6462
buffer = null;
6563
}
6664
};
65+
filter.onstart = event => {
66+
if (/ml$/i.test(content.type)) {
67+
filter.write(new Uint8Array()); // work-around for https://bugzilla.mozilla.org/show_bug.cgi?id=1410755
68+
}
69+
}
6770
filter.ondata = event => {
71+
if (first) {
72+
execute();
73+
first = false;
74+
}
75+
6876
if (buffer) {
6977
buffer.push(event.data);
7078
return;

0 commit comments

Comments
 (0)