2024-12-13 22:59:08 +00:00
|
|
|
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}`);
|
2024-12-13 21:05:08 +00:00
|
|
|
return {
|
|
|
|
redirectUrl: `http://localhost:4433/s3/${b64}`
|
|
|
|
}
|
2024-12-13 20:16:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-13 22:59:08 +00:00
|
|
|
browser.webRequest.onBeforeSendHeaders.addListener(
|
|
|
|
handle_header, { urls: ["<all_urls>"] }, ["blocking", "requestHeaders"]
|
2024-12-13 20:16:24 +00:00
|
|
|
);
|
2024-12-13 22:59:08 +00:00
|
|
|
|
|
|
|
browser.webRequest.onBeforeRequest.addListener(
|
|
|
|
url_redirect, { urls: ["<all_urls>"] }, ["blocking"]
|
|
|
|
)
|
|
|
|
|