-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
28 lines (25 loc) · 946 Bytes
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function listener(details) {
let filter = browser.webRequest.filterResponseData(details.requestId);
let decoder = new TextDecoder("utf-8");
let encoder = new TextEncoder();
filter.ondata = (event) => {
let str = decoder.decode(event.data, { stream: true });
// Just change any instance of Example in the HTTP response
// to WebExtension Example.
// str = str.replace(/Example/g, "WebExtension Example");
str = str
.replace(
"return (unpackr || globalRibbonUnpackr).unpack(packet);",
"let catchInLog=((unpackr || globalRibbonUnpackr).unpack(packet)); console.log('in',catchInLog); return catchInLog;"
)
.replace("return merged;", "console.log('out', packet); return merged;");
filter.write(encoder.encode(str));
filter.disconnect();
};
return {};
}
browser.webRequest.onBeforeRequest.addListener(
listener,
{ urls: ["*://tetr.io/js/tetrio.js*"] },
["blocking"]
);