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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// Default settings. If there is nothing in storage, use these values.
const defaultSettings = {
reclaim_alive: false,
};
chrome.storage.local.set(defaultSettings);
const authzSettings = {
search: null,
request: false
};
chrome.storage.local.set(authzSettings, function() {});
function handle_onbefore_request(request)
{
console.log(request)
var url = new URL(request.url);
if(url.hostname == "ui.reclaim") {
authzSettings.search = decodeURIComponent(request.url).split("?")[1];
authzSettings.request = true;
chrome.storage.local.set(authzSettings, function() {});
console.log(authzSettings);
//browser.runtime.openOptionsPage();
//return {};
return {"redirectUrl": chrome.runtime.getURL("/index.html") + "?" + decodeURIComponent(request.url).split("?")[1]}
}
if (url.hostname == "api.reclaim") {
return {"redirectUrl": "http://localhost:7776" + url.pathname + url.search};
}
}
chrome.webRequest.onBeforeRequest.addListener(handle_onbefore_request,
{
urls: ["*://*.reclaim/*"],
//types: ["beacon", "csp_report", "font", "image", "imageset", "main_frame", "media", "object", "ping", "speculative", "stylesheet", "sub_frame", "web_manifest", "websocket", "xbl", "xml_dtd", "xslt", "other", "script", "xmlhttprequest"]
types: ["csp_report", "font", "image", "main_frame", "media", "object", "ping", "stylesheet", "sub_frame", "websocket", "other", "script", "xmlhttprequest"]
},
["blocking"]
);
|