Files
I2P_in_Private_Browsing_Mod…/handler.js

31 lines
863 B
JavaScript
Raw Normal View History

2019-11-23 18:41:18 -05:00
function identifyProtocolHandler(url) {
//console.log("looking for handler-able requests")
if (routerHost(url)) {
if (url.includes(encodeURIComponent("ext+rc:"))) {
return url.replace(encodeURIComponent("ext+rc:"), "");
} else if (url.includes("ext+rc:")) {
return url.replace("ext+rc:", "");
}
} else if (url.includes("ext+rc:")) {
return url;
}
return false;
}
var handlerSetup = async function(requestDetails) {
//console.log("checking protocol handler listener")
var rwurl = identifyProtocolHandler(requestDetails.url);
if (rwurl != false) {
console.log("handler rewrite URL requested", rwurl);
requestDetails.redirectUrl = rwurl;
requestDetails.url = rwurl;
}
return requestDetails;
};
browser.webRequest.onBeforeRequest.addListener(
handlerSetup,
{ urls: ["<all_urls>"] },
["blocking"]
);