Files
I2P_in_Private_Browsing_Mod…/handler.js

31 lines
852 B
JavaScript
Raw Normal View History

2019-11-23 22:17:20 -05:00
function trimHost(url) {
2022-10-24 19:57:51 -04:00
let hostname = "";
let prefix = "";
if (url.indexOf("://") > -1) {
prefix = url.substr(0, url.indexOf("://") + 3);
hostname = url.split("/")[2];
2022-10-07 19:32:52 -04:00
} else {
2022-10-24 19:57:51 -04:00
hostname = url.split("/")[0];
2022-10-07 19:32:52 -04:00
}
2022-10-24 19:57:51 -04:00
let path = url.replace(prefix + hostname, "");
console.log("(handler) path", prefix + hostname, path);
2022-10-07 19:32:52 -04:00
return path;
2019-11-23 22:17:20 -05:00
}
function handlerSetup(requestDetails) {
2022-10-07 19:32:52 -04:00
//console.log("checking protocol handler listener")
let rwurl = identifyProtocolHandler(requestDetails.url);
if (rwurl != false) {
2022-10-24 19:57:51 -04:00
console.log("(handler) rewrite URL requested", rwurl);
2022-10-07 19:32:52 -04:00
requestDetails.redirectUrl = rwurl;
requestDetails.url = trimHost(rwurl);
requestDetails.originUrl = trimHost(rwurl);
}
return requestDetails;
}
2020-12-09 17:49:36 -05:00
/*
browser.webRequest.onBeforeRequest.addListener(handlerSetup, {
urls: ['<all_urls>'],
});
2022-05-08 17:52:14 -04:00
*/