switch to closure-linter

This commit is contained in:
idk
2020-01-14 14:49:48 -05:00
parent 15a0e838b3
commit 55c800e048
15 changed files with 443 additions and 444 deletions

View File

@@ -1,43 +1,43 @@
function routerHost(url) {
let hostname = "";
let path = "";
let hostname = '';
let path = '';
function pathcheck(str) {
if (str != undefined) {
let final = str.split("/")[0];
if (final === "i2ptunnelmgr" || final === "i2ptunnel") {
console.log("(urlcheck) application path", final);
return "i2ptunnelmgr";
} else if (final === "i2psnark" || final === "torrents") {
console.log("(urlcheck) application path", final);
return "i2psnark";
} else if (final === "webmail" || final === "susimail") {
console.log("(urlcheck) application path", final);
return "webmail";
let final = str.split('/')[0];
if (final === 'i2ptunnelmgr' || final === 'i2ptunnel') {
console.log('(urlcheck) application path', final);
return 'i2ptunnelmgr';
} else if (final === 'i2psnark' || final === 'torrents') {
console.log('(urlcheck) application path', final);
return 'i2psnark';
} else if (final === 'webmail' || final === 'susimail') {
console.log('(urlcheck) application path', final);
return 'webmail';
} else if (
final === "home" ||
final === "console" ||
final === "dns" ||
final.startsWith("config")
final === 'home' ||
final === 'console' ||
final === 'dns' ||
final.startsWith('config')
) {
console.log("(urlcheck) application path", final);
return "routerconsole";
console.log('(urlcheck) application path', final);
return 'routerconsole';
}
}
return true;
}
if (url.indexOf("://") > -1) {
hostname = url.split("/")[2];
let prefix = url.substr(0, url.indexOf("://") + 3);
path = url.replace(prefix + hostname + "/", "");
if (url.indexOf('://') > -1) {
hostname = url.split('/')[2];
let prefix = url.substr(0, url.indexOf('://') + 3);
path = url.replace(prefix + hostname + '/', '');
} else if (identifyProtocolHandler(url)) {
let newurl = identifyProtocolHandler(url);
return routerHost(newurl);
} else {
hostname = url.split("/")[0];
path = url.replace(hostname + "/", "");
hostname = url.split('/')[0];
path = url.replace(hostname + '/', '');
}
if (hostname === control_host + ":" + control_port) {
console.log("(hostcheck) router console found on configured ports");
if (hostname === control_host + ':' + control_port) {
console.log('(hostcheck) router console found on configured ports');
return pathcheck(path);
}
@@ -47,28 +47,28 @@ function routerHost(url) {
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:", "");
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:")) {
} else if (url.includes('ext+rc:')) {
return url;
}
return false;
}
function trimHost(url) {
let hostname = "";
let prefix = "";
if (url.indexOf("://") > -1) {
prefix = url.substr(0, url.indexOf("://") + 3);
hostname = url.split("/")[2];
let hostname = '';
let prefix = '';
if (url.indexOf('://') > -1) {
prefix = url.substr(0, url.indexOf('://') + 3);
hostname = url.split('/')[2];
} else {
hostname = url.split("/")[0];
hostname = url.split('/')[0];
}
let path = url.replace(prefix + hostname, "");
console.log("(handler) path", prefix + hostname, path);
let path = url.replace(prefix + hostname, '');
console.log('(handler) path', prefix + hostname, path);
return path;
}
@@ -76,7 +76,7 @@ var handlerSetup = function(requestDetails) {
//console.log("checking protocol handler listener")
let rwurl = identifyProtocolHandler(requestDetails.url);
if (rwurl != false) {
console.log("(handler) rewrite URL requested", rwurl);
console.log('(handler) rewrite URL requested', rwurl);
requestDetails.redirectUrl = rwurl;
requestDetails.url = trimHost(rwurl);
requestDetails.originUrl = trimHost(rwurl);
@@ -86,6 +86,6 @@ var handlerSetup = function(requestDetails) {
browser.webRequest.onBeforeRequest.addListener(
handlerSetup,
{ urls: ["<all_urls>"] },
["blocking"]
{ urls: ['<all_urls>'] },
['blocking']
);