Merge pull request #55 from eyedeekay/android
Fixes encountered on the way to understanding Android
This commit is contained in:
3
Makefile
3
Makefile
@@ -176,7 +176,8 @@ upload-deb:
|
||||
fmt:
|
||||
cleancss -O1 all -O2 all --format beautify home.css -o .home.css && mv .home.css home.css
|
||||
cleancss -O1 all -O2 all --format beautify info.css -o .info.css && mv .info.css info.css
|
||||
find . -path ./node_modules -prune -o -name '*.js*' -exec prettier --write {} \;
|
||||
find . -path ./node_modules -prune -o -name '*.js' -exec prettier --write {} \;
|
||||
find . -path ./node_modules -prune -o -name '*.json' -exec prettier --write {} \;
|
||||
|
||||
lint:
|
||||
eslint --color *.js
|
||||
|
||||
@@ -11,7 +11,7 @@ var torrentprefpriv = chrome.i18n.getMessage("torrentPrefacePrivate");
|
||||
var tunnelpref = chrome.i18n.getMessage("i2ptunnelPreface");
|
||||
var tunnelprefpriv = chrome.i18n.getMessage("i2ptunnelPrefacePrivate");
|
||||
var localpref = chrome.i18n.getMessage("localPreface");
|
||||
var localpref = chrome.i18n.getMessage("localPrefacePrivate");
|
||||
var localprefpriv = chrome.i18n.getMessage("localPrefacePrivate");
|
||||
|
||||
function onContextsGot(contexts) {
|
||||
var ids = [];
|
||||
|
||||
11
platform.js
11
platform.js
@@ -11,7 +11,7 @@ var torrentprefpriv = chrome.i18n.getMessage("torrentPrefacePrivate");
|
||||
var tunnelpref = chrome.i18n.getMessage("i2ptunnelPreface");
|
||||
var tunnelprefpriv = chrome.i18n.getMessage("i2ptunnelPrefacePrivate");
|
||||
|
||||
var android = false;
|
||||
var android; // = false;
|
||||
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then(got => {
|
||||
@@ -21,10 +21,19 @@ gettingInfo.then(got => {
|
||||
return true;
|
||||
} else {
|
||||
console.log("Running in Desktop detected");
|
||||
android = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
function isDroid() {
|
||||
console.log("android?", android);
|
||||
if (android == undefined) {
|
||||
return false;
|
||||
}
|
||||
return android;
|
||||
}
|
||||
|
||||
function notClosable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
41
proxy.js
41
proxy.js
@@ -46,14 +46,9 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
};
|
||||
console.log(
|
||||
"(proxy)",
|
||||
context.name,
|
||||
"Using",
|
||||
proxy.type,
|
||||
"proxy ",
|
||||
proxy.host + ":" + proxy.port
|
||||
);
|
||||
console.log("(proxy)", context.name);
|
||||
console.log("Using", proxy.type);
|
||||
console.log("proxy ", proxy.host + ":" + proxy.port);
|
||||
return proxy;
|
||||
} else if (context.name == routerpref) {
|
||||
if (routerHost(requestDetails.url)) {
|
||||
@@ -70,14 +65,9 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
};
|
||||
console.log(
|
||||
"(proxy)",
|
||||
context.name,
|
||||
"Using",
|
||||
proxy.type,
|
||||
"proxy ",
|
||||
proxy.host + ":" + proxy.port
|
||||
);
|
||||
console.log("(proxy)", context.name);
|
||||
console.log("Using", proxy.type);
|
||||
console.log("proxy ", proxy.host + ":" + proxy.port);
|
||||
return proxy;
|
||||
} else if (context.name == webpref) {
|
||||
if (localHost(requestDetails.url)) {
|
||||
@@ -89,14 +79,9 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
};
|
||||
}
|
||||
}
|
||||
console.log(
|
||||
"(proxy)",
|
||||
context.name,
|
||||
"Using",
|
||||
proxy.type,
|
||||
"proxy ",
|
||||
proxy.host + ":" + proxy.port
|
||||
);
|
||||
console.log("(proxy)", context.name);
|
||||
console.log("Using", proxy.type);
|
||||
console.log("proxy ", proxy.host + ":" + proxy.port);
|
||||
return proxy;
|
||||
}
|
||||
}
|
||||
@@ -127,7 +112,7 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
context = await browser.contextualIdentities.get(tabInfo.cookieStoreId);
|
||||
return context;
|
||||
} catch (error) {
|
||||
return "firefox-default";
|
||||
return; //"firefox-default";
|
||||
}
|
||||
};
|
||||
var tabGet = async function(tabId) {
|
||||
@@ -333,12 +318,6 @@ function getControlPort() {
|
||||
}
|
||||
|
||||
function setupProxy() {
|
||||
/* var controlHost = getControlHost();
|
||||
var controlPort = getControlPort();
|
||||
var Host = getHost();
|
||||
var Port = getPort();
|
||||
var Scheme = getScheme(); */
|
||||
|
||||
/**/
|
||||
console.log("Setting up Firefox WebExtension proxy");
|
||||
browser.proxy.onRequest.addListener(handleContextProxyRequest, {
|
||||
|
||||
170
scrub.js
170
scrub.js
@@ -10,14 +10,15 @@ var torrentpref = chrome.i18n.getMessage("torrentPreface");
|
||||
var torrentprefpriv = chrome.i18n.getMessage("torrentPrefacePrivate");
|
||||
var tunnelpref = chrome.i18n.getMessage("i2ptunnelPreface");
|
||||
var tunnelprefpriv = chrome.i18n.getMessage("i2ptunnelPrefacePrivate");
|
||||
var localpref = chrome.i18n.getMessage("i2ptunnelPreface");
|
||||
var localpref = chrome.i18n.getMessage("localPreface");
|
||||
var localprefpriv = chrome.i18n.getMessage("localPrefacePrivate");
|
||||
|
||||
var contextScrub = async function(requestDetails) {
|
||||
console.log("(scrub)Scrubbing info from contextualized request");
|
||||
try {
|
||||
var headerScrub = function(context) {
|
||||
if (!context) {
|
||||
console.error("Context not found", context);
|
||||
console.log("Context not found", context);
|
||||
} else if (context.name == titlepref) {
|
||||
var ua = "MYOB/6.66 (AN/ON)";
|
||||
if (i2pHost(requestDetails.url)) {
|
||||
@@ -50,10 +51,12 @@ var contextScrub = async function(requestDetails) {
|
||||
var contextGet = async function(tabInfo) {
|
||||
try {
|
||||
console.log("(scrub)Tab info from Function", tabInfo);
|
||||
context = await browser.contextualIdentities.get(tabInfo.cookieStoreId);
|
||||
let context = await browser.contextualIdentities.get(
|
||||
tabInfo.cookieStoreId
|
||||
);
|
||||
return context;
|
||||
} catch (error) {
|
||||
return "firefox-default";
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
var tabGet = async function(tabId) {
|
||||
@@ -62,8 +65,7 @@ var contextScrub = async function(requestDetails) {
|
||||
let tabInfo = await browser.tabs.get(tabId);
|
||||
return tabInfo;
|
||||
} catch (error) {
|
||||
let tabInfo = await browser.tabs.getCurrent();
|
||||
return tabInfo;
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
if (requestDetails.tabId > 0) {
|
||||
@@ -100,12 +102,21 @@ var contextSetup = async function(requestDetails) {
|
||||
name: titlepref
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log("(isolate) I2P context", context[0].cookieStoreId);
|
||||
console.log("tab context", tabId.cookieStoreId);
|
||||
function Create(currentTab) {
|
||||
function onCreated(tab) {
|
||||
if (tabId.id != tab.id) {
|
||||
console.log("(isolate) Closing old, un-isolated tab");
|
||||
browser.tabs.remove(tabId.id);
|
||||
function closeOldTab(tab) {
|
||||
if (!notClosable()) {
|
||||
if (tabId.id != tab.id) {
|
||||
console.log("(isolate) Closing un-isolated tab", tabId.id);
|
||||
console.log("in favor of", tab.id);
|
||||
console.log("with context", tab.cookieStoreId);
|
||||
browser.tabs.remove(tabId.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
closeOldTab(tab);
|
||||
}
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
@@ -114,8 +125,8 @@ var contextSetup = async function(requestDetails) {
|
||||
});
|
||||
created.then(onCreated, onError);
|
||||
}
|
||||
var getting = browser.tabs.getCurrent();
|
||||
getting.then(Create, onError);
|
||||
var gettab = browser.tabs.get(tabId.id);
|
||||
gettab.then(Create, onError);
|
||||
return tabId;
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -128,12 +139,21 @@ var contextSetup = async function(requestDetails) {
|
||||
name: routerpref
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log("(isolate) I2P context", context[0].cookieStoreId);
|
||||
console.log("tab context", tabId.cookieStoreId);
|
||||
function Create(currentTab) {
|
||||
function onCreated(tab) {
|
||||
if (tabId.id != tab.id) {
|
||||
console.log("(isolate) Closing old, un-isolated tab");
|
||||
browser.tabs.remove(tabId.id);
|
||||
function closeOldTab(tab) {
|
||||
if (!notClosable()) {
|
||||
if (tabId.id != tab.id) {
|
||||
console.log("(isolate) Closing un-isolated tab", tabId.id);
|
||||
console.log("in favor of", tab.id);
|
||||
console.log("with context", tab.cookieStoreId);
|
||||
browser.tabs.remove(tabId.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
closeOldTab(tab);
|
||||
}
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
@@ -142,8 +162,8 @@ var contextSetup = async function(requestDetails) {
|
||||
});
|
||||
created.then(onCreated, onError);
|
||||
}
|
||||
var getting = browser.tabs.getCurrent();
|
||||
getting.then(Create, onError);
|
||||
var gettab = browser.tabs.get(tabId.id);
|
||||
gettab.then(Create, onError);
|
||||
return tabId;
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -156,12 +176,21 @@ var contextSetup = async function(requestDetails) {
|
||||
name: tunnelpref
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log("(isolate) I2P context", context[0].cookieStoreId);
|
||||
console.log("tab context", tabId.cookieStoreId);
|
||||
function Create(currentTab) {
|
||||
function onCreated(tab) {
|
||||
if (tabId.id != tab.id) {
|
||||
console.log("(isolate) Closing old, un-isolated tab");
|
||||
browser.tabs.remove(tabId.id);
|
||||
function closeOldTab(tab) {
|
||||
if (!notClosable()) {
|
||||
if (tabId.id != tab.id) {
|
||||
console.log("(isolate) Closing un-isolated tab", tabId.id);
|
||||
console.log("in favor of", tab.id);
|
||||
console.log("with context", tab.cookieStoreId);
|
||||
browser.tabs.remove(tabId.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
closeOldTab(tab);
|
||||
}
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
@@ -170,8 +199,8 @@ var contextSetup = async function(requestDetails) {
|
||||
});
|
||||
created.then(onCreated, onError);
|
||||
}
|
||||
var getting = browser.tabs.getCurrent();
|
||||
getting.then(Create, onError);
|
||||
var gettab = browser.tabs.get(tabId.id);
|
||||
gettab.then(Create, onError);
|
||||
return tabId;
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -184,12 +213,21 @@ var contextSetup = async function(requestDetails) {
|
||||
name: torrentpref
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log("(isolate) I2P context", context[0].cookieStoreId);
|
||||
console.log("tab context", tabId.cookieStoreId);
|
||||
function Create(currentTab) {
|
||||
function onCreated(tab) {
|
||||
if (tabId.id != tab.id) {
|
||||
console.log("(isolate) Closing old, un-isolated tab");
|
||||
browser.tabs.remove(tabId.id);
|
||||
function closeOldTab(tab) {
|
||||
if (!notClosable()) {
|
||||
if (tabId.id != tab.id) {
|
||||
console.log("(isolate) Closing un-isolated tab", tabId.id);
|
||||
console.log("in favor of", tab.id);
|
||||
console.log("with context", tab.cookieStoreId);
|
||||
browser.tabs.remove(tabId.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
closeOldTab(tab);
|
||||
}
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
@@ -198,8 +236,8 @@ var contextSetup = async function(requestDetails) {
|
||||
});
|
||||
created.then(onCreated, onError);
|
||||
}
|
||||
var getting = browser.tabs.getCurrent();
|
||||
getting.then(Create, onError);
|
||||
var gettab = browser.tabs.get(tabId.id);
|
||||
gettab.then(Create, onError);
|
||||
return tabId;
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -212,12 +250,21 @@ var contextSetup = async function(requestDetails) {
|
||||
name: mailpref
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log("(isolate) I2P context", context[0].cookieStoreId);
|
||||
console.log("tab context", tabId.cookieStoreId);
|
||||
function Create(currentTab) {
|
||||
function onCreated(tab) {
|
||||
if (tabId.id != tab.id) {
|
||||
console.log("(isolate) Closing old, un-isolated tab");
|
||||
browser.tabs.remove(tabId.id);
|
||||
function closeOldTab(tab) {
|
||||
if (!notClosable()) {
|
||||
if (tabId.id != tab.id) {
|
||||
console.log("(isolate) Closing un-isolated tab", tabId.id);
|
||||
console.log("in favor of", tab.id);
|
||||
console.log("with context", tab.cookieStoreId);
|
||||
browser.tabs.remove(tabId.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
closeOldTab(tab);
|
||||
}
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
@@ -226,8 +273,8 @@ var contextSetup = async function(requestDetails) {
|
||||
});
|
||||
created.then(onCreated, onError);
|
||||
}
|
||||
var getting = browser.tabs.getCurrent();
|
||||
getting.then(Create, onError);
|
||||
var gettab = browser.tabs.get(tabId.id);
|
||||
gettab.then(Create, onError);
|
||||
return tabId;
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -240,12 +287,21 @@ var contextSetup = async function(requestDetails) {
|
||||
name: localpref
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log("(isolate) I2P context", context[0].cookieStoreId);
|
||||
console.log("tab context", tabId.cookieStoreId);
|
||||
function Create(currentTab) {
|
||||
function onCreated(tab) {
|
||||
if (tabId.id != tab.id) {
|
||||
console.log("(isolate) Closing old, un-isolated tab");
|
||||
browser.tabs.remove(tabId.id);
|
||||
function closeOldTab(tab) {
|
||||
if (!notClosable()) {
|
||||
if (tabId.id != tab.id) {
|
||||
console.log("(isolate) Closing un-isolated tab", tabId.id);
|
||||
console.log("in favor of", tab.id);
|
||||
console.log("with context", tab.cookieStoreId);
|
||||
browser.tabs.remove(tabId.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
closeOldTab(tab);
|
||||
}
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
@@ -254,8 +310,8 @@ var contextSetup = async function(requestDetails) {
|
||||
});
|
||||
created.then(onCreated, onError);
|
||||
}
|
||||
var getting = browser.tabs.getCurrent();
|
||||
getting.then(Create, onError);
|
||||
var gettab = browser.tabs.get(tabId.id);
|
||||
gettab.then(Create, onError);
|
||||
return tabId;
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -273,12 +329,22 @@ var contextSetup = async function(requestDetails) {
|
||||
tabId.cookieStoreId == "firefox-private"
|
||||
) {
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log("(isolate) I2P context", context[0].cookieStoreId);
|
||||
console.log("tab context", tabId.cookieStoreId);
|
||||
function Create(currentTab) {
|
||||
function onCreated(tab) {
|
||||
if (tabId.id != tab.id) {
|
||||
console.log("(isolate) Closing old, un-isolated tab");
|
||||
browser.tabs.remove(tabId.id);
|
||||
function closeOldTab(tab) {
|
||||
if (!notClosable()) {
|
||||
if (tabId.id != tab.id) {
|
||||
let o = tabId.id;
|
||||
console.log("(isolate) Closing un-isolated tab", o);
|
||||
console.log("in favor of", tab.id);
|
||||
console.log("with context", tab.cookieStoreId);
|
||||
browser.tabs.remove(tabId.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
closeOldTab(tab);
|
||||
}
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
@@ -287,8 +353,8 @@ var contextSetup = async function(requestDetails) {
|
||||
});
|
||||
created.then(onCreated, onError);
|
||||
}
|
||||
var getting = browser.tabs.getCurrent();
|
||||
getting.then(Create, onError);
|
||||
var gettab = browser.tabs.get(tabId.id);
|
||||
gettab.then(Create, onError);
|
||||
return tabId;
|
||||
}
|
||||
}
|
||||
@@ -337,10 +403,12 @@ var contextSetup = async function(requestDetails) {
|
||||
}
|
||||
let localhost = localHost(requestDetails.url);
|
||||
let routerhost = routerHost(requestDetails.url);
|
||||
if (localhost && !routerhost) {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
var mtab = tab.then(localTabFind, onError);
|
||||
return requestDetails;
|
||||
if (!routerhost) {
|
||||
if (localhost) {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
var mtab = tab.then(localTabFind, onError);
|
||||
return requestDetails;
|
||||
}
|
||||
}
|
||||
if (routerhost) {
|
||||
if (routerhost === "i2ptunnelmgr") {
|
||||
@@ -361,21 +429,9 @@ var contextSetup = async function(requestDetails) {
|
||||
return requestDetails;
|
||||
}
|
||||
} else {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
var mtab = tab.then(anyTabFind, onError);
|
||||
return requestDetails;
|
||||
}
|
||||
}
|
||||
if (typeof requestDetails == "number") {
|
||||
tab = tabGet(requestDetails);
|
||||
var mtab = tab.then(anyTabFind);
|
||||
} else if (typeof requestDetails != undefined) {
|
||||
if (typeof requestDetails.tabId > 0) {
|
||||
tab = tabGet(requestDetails.tabId);
|
||||
var mtab = tab.then(anyTabFind);
|
||||
}
|
||||
}
|
||||
return requestDetails;
|
||||
} catch (error) {
|
||||
console.log("(isolate)Not an I2P request, blackholing", error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user