so close!
This commit is contained in:
@@ -1,13 +1,39 @@
|
||||
function handle(requestDetails) {
|
||||
let b64 = btoa(requestDetails.url)
|
||||
if (!requestDetails.url.startsWith("http://localhost")) {
|
||||
console.log(`Loading: ${requestDetails.url} || ${b64}`);
|
||||
function handle_header(req) {
|
||||
// Headers
|
||||
// let x = req.requestHeaders;
|
||||
// if (!x) {
|
||||
x = new Headers()
|
||||
// }
|
||||
x.append("og", old)
|
||||
|
||||
console.log(x)
|
||||
|
||||
// appending header of the original url so that relative urls can be built into
|
||||
// absolute urls
|
||||
// TODO This doesn't work yet
|
||||
return {
|
||||
requestHeaders: x,
|
||||
}
|
||||
}
|
||||
|
||||
let old = ""
|
||||
|
||||
function url_redirect (req) {
|
||||
let b64 = btoa(req.url)
|
||||
if (!req.url.startsWith("http://localhost")) {
|
||||
old = req.url
|
||||
// console.debug(`Loading: ${req.url} || ${b64}`);
|
||||
return {
|
||||
redirectUrl: `http://localhost:4433/s3/${b64}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
browser.webRequest.onBeforeRequest.addListener(
|
||||
handle, { urls: ["<all_urls>"] }, ["blocking"]
|
||||
browser.webRequest.onBeforeSendHeaders.addListener(
|
||||
handle_header, { urls: ["<all_urls>"] }, ["blocking", "requestHeaders"]
|
||||
);
|
||||
|
||||
browser.webRequest.onBeforeRequest.addListener(
|
||||
url_redirect, { urls: ["<all_urls>"] }, ["blocking"]
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user