Microsoft is acquiring GitHub. Decentraleyes is leaving GitHub. Welcome to its new home!

To participate, please register, or sign in with an existing GitLab.com, Bitbucket, or GitHub account.

Past contributions on GitHub? Be sure to reclaim your Comments, Issues, and Pull Requests.

Commit 52347f11 authored by Alaska's avatar Alaska

Upload New File

parent e2aac58c
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/StreamFilter/ondata
function listener(details) { // todo simply return, if attribute 'crossorigin' doesn't appear
let filter = browser.webRequest.filterResponseData(details.requestId);
let decoder = new TextDecoder("utf-8"); // can be reused?
let encoder = new TextEncoder(); // can be reused?
filter.ondata = event => {
console.log(event.data);
let str = decoder.decode(event.data, {
stream : true
});
//////////////// regex needs work!!!!!!
str = str.replace(/(?!<script .*?)crossorigin(?=.*>)/gi, 'noop'); // todo replace with ''?
filter.write(encoder.encode(str));
filter.disconnect();
}
return {}; // not needed
}
browser.webRequest.onBeforeRequest.addListener(
listener, {
urls : ["<all_urls>"],
types : ["main_frame"]
},
["blocking"]);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment