Try some android stuff

This commit is contained in:
idk
2019-11-24 04:13:12 -05:00
parent fbaf1dca30
commit 1dd48e4344
8 changed files with 112 additions and 68 deletions

View File

@@ -36,8 +36,8 @@ clean:
## EVEN RELEASES are AMO RELEASES
## ODD RELEASES are SELFHOSTED RELEASES
MOZ_VERSION=0.46
VERSION=0.47
MOZ_VERSION=0.48
VERSION=0.49
#VERSION=$(MOZ_VERSION)
#VERSION=1.27
@@ -112,7 +112,8 @@ moz-sign: version
@echo "Using the 'sign' target to instantly sign an extension for self-distribution"
@echo "requires a JWT API Key and Secret from addons.mozilla.org to be made available"
@echo "to the Makefile under the variables WEB_EXT_API_KEY and WEB_EXT_API_SECRET."
web-ext sign --channel unlisted --config-discovery false --api-key $(WEB_EXT_API_KEY) --api-secret $(WEB_EXT_API_SECRET); true
web-ext-submit --channel unlisted --config-discovery false --api-key $(WEB_EXT_API_KEY) --api-secret $(WEB_EXT_API_SECRET); true
cp web-ext-artifacts/*.xpi ./i2ppb@eyedeekay.github.io.xpi
##EVEN NUMBERED, MOZILLA-DISTRIBUTED VERSIONS HERE!
moz-submit: moz-version

View File

@@ -84,19 +84,32 @@ function onError(e) {
browser.contextualIdentities.query({}).then(onGot, onError);
if (!isDroid()) {
chrome.windows.onCreated.addListener(themeWindow);
chrome.windows.onFocusChanged.addListener(themeWindow);
chrome.windows.onRemoved.addListener(themeWindow);
chrome.tabs.onUpdated.addListener(themeWindowByTab);
chrome.tabs.onActivated.addListener(themeWindowByTab);
} else {
}
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os == "android") {
console.log("Running in Android detected");
return true;
} else {
browser.windows.onCreated.addListener(themeWindow);
browser.windows.onFocusChanged.addListener(themeWindow);
browser.windows.onRemoved.addListener(themeWindow);
browser.tabs.onUpdated.addListener(themeWindowByTab);
browser.tabs.onActivated.addListener(themeWindowByTab);
}
});
function themeWindowByTab(tabId) {
function tabWindow(tab) {
getwindow = browser.windows.get(tab.windowId);
getwindow.then(themeWindow);
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os == "android") {
getwindow = browser.tabs.get(tab.tabId);
getwindow.then(themeWindow);
} else {
getwindow = browser.windows.get(tab.windowId);
getwindow.then(themeWindow);
}
});
}
if (typeof tabId === "number") {
tab = browser.tabs.get(tabId);
@@ -113,14 +126,14 @@ function themeWindow(window) {
if (context.name == titlepref) {
console.log("Active in I2P window");
if (window.incognito) {
chrome.theme.update(window.id, {
browser.theme.update(window.id, {
colors: {
frame: "#FFC56D",
toolbar: "#FFC56D"
}
});
} else {
chrome.theme.update(window.id, {
browser.theme.update(window.id, {
colors: {
frame: "#FFC56D",
toolbar: "#FFC56D"
@@ -130,14 +143,14 @@ function themeWindow(window) {
} else if (context.name == routerpref) {
console.log("Active in Router Console window");
if (window.incognito) {
chrome.theme.update(window.id, {
browser.theme.update(window.id, {
colors: {
frame: "#A4C8E1",
toolbar: "#A4C8E1"
}
});
} else {
chrome.theme.update(window.id, {
browser.theme.update(window.id, {
colors: {
frame: "#A4C8E1",
toolbar: "#A4C8E1"
@@ -147,14 +160,14 @@ function themeWindow(window) {
} else if (context.name == tunnelpref) {
console.log("Active in Hidden Services Manager window");
if (window.incognito) {
chrome.theme.update(window.id, {
browser.theme.update(window.id, {
colors: {
frame: "#D9D9D6",
toolbar: "#D9D9D6"
}
});
} else {
chrome.theme.update(window.id, {
browser.theme.update(window.id, {
colors: {
frame: "#D9D9D6",
toolbar: "#D9D9D6"
@@ -164,14 +177,14 @@ function themeWindow(window) {
} else if (context.name == mailpref) {
console.log("Active in Web Mail window");
if (window.incognito) {
chrome.theme.update(window.id, {
browser.theme.update(window.id, {
colors: {
frame: "#F7E59A",
toolbar: "#F7E59A"
}
});
} else {
chrome.theme.update(window.id, {
browser.theme.update(window.id, {
colors: {
frame: "#F7E59A",
toolbar: "#F7E59A"
@@ -181,14 +194,14 @@ function themeWindow(window) {
} else if (context.name == torrentpref) {
console.log("Active in Bittorrent window");
if (window.incognito) {
chrome.theme.update(window.id, {
browser.theme.update(window.id, {
colors: {
frame: "#A48FE1",
toolbar: "#A48FE1"
}
});
} else {
chrome.theme.update(window.id, {
browser.theme.update(window.id, {
colors: {
frame: "#A48FE1",
toolbar: "#A48FE1"
@@ -197,7 +210,7 @@ function themeWindow(window) {
}
} else {
console.log("Not active in I2P window");
chrome.theme.reset(window.id);
browser.theme.reset(window.id);
}
}
if (
@@ -208,7 +221,7 @@ function themeWindow(window) {
.get(tabInfo[0].cookieStoreId)
.then(onGot, onError);
} else {
chrome.theme.reset(window.id);
browser.theme.reset(window.id);
}
}
@@ -228,11 +241,11 @@ function setTitle(window) {
console.log("Active in I2P window");
if (window.incognito) {
chrome.windows.update(window.id, {
browser.windows.update(window.id, {
titlePreface: titleprefpriv
});
} else {
chrome.windows.update(window.id, {
browser.windows.update(window.id, {
titlePreface: titlepref
});
}
@@ -240,22 +253,22 @@ function setTitle(window) {
console.log("Active in Web window");
if (window.incognito) {
chrome.windows.update(window.id, {
browser.windows.update(window.id, {
titlePreface: ""
});
} else {
chrome.windows.update(window.id, {
browser.windows.update(window.id, {
titlePreface: ""
});
}
} else if (context.name == routerpref) {
console.log("Active in Router Console window");
if (window.incognito) {
chrome.windows.update(window.id, {
browser.windows.update(window.id, {
titlePreface: routerprefpriv
});
} else {
chrome.windows.update(window.id, {
browser.windows.update(window.id, {
titlePreface: routerpref
});
}
@@ -263,11 +276,11 @@ function setTitle(window) {
console.log("Active in Hidden Services Manager window");
if (window.incognito) {
chrome.windows.update(window.id, {
browser.windows.update(window.id, {
titlePreface: tunnelprefpriv
});
} else {
chrome.windows.update(window.id, {
browser.windows.update(window.id, {
titlePreface: tunnelpref
});
}
@@ -275,11 +288,11 @@ function setTitle(window) {
console.log("Active in Web Mail window");
if (window.incognito) {
chrome.windows.update(window.id, {
browser.windows.update(window.id, {
titlePreface: mailprefpriv
});
} else {
chrome.windows.update(window.id, {
browser.windows.update(window.id, {
titlePreface: mailpref
});
}
@@ -287,11 +300,11 @@ function setTitle(window) {
console.log("Active in I2P window");
if (window.incognito) {
chrome.windows.update(window.id, {
browser.windows.update(window.id, {
titlePreface: torrentprefpriv
});
} else {
chrome.windows.update(window.id, {
browser.windows.update(window.id, {
titlePreface: torrentpref
});
}
@@ -307,11 +320,11 @@ function setTitle(window) {
.then(onGot, onError);
} else {
if (window.incognito) {
chrome.windows.update(window.id, {
browser.windows.update(window.id, {
titlePreface: ""
});
} else {
chrome.windows.update(window.id, {
browser.windows.update(window.id, {
titlePreface: ""
});
}
@@ -325,7 +338,7 @@ function setTitle(window) {
querying.then(logTabs, onError);
}
chrome.windows.onCreated.addListener(() => {
browser.windows.onCreated.addListener(() => {
/* var gettingStoredSettings = chrome.storage.local.get();
gettingStoredSettings.then(setupProxy, onError); */
chrome.storage.local.get(function(got) {
@@ -333,18 +346,34 @@ chrome.windows.onCreated.addListener(() => {
});
});
chrome.tabs.onCreated.addListener(() => {
var getting = browser.windows.getCurrent({
populate: true
});
getting.then(setTitle, onError);
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os == "android") {
console.log("Running in Android detected");
return true;
} else {
browser.tabs.onCreated.addListener(() => {
var getting = browser.windows.getCurrent({
populate: true
});
getting.then(setTitle, onError);
});
}
});
chrome.tabs.onActivated.addListener(() => {
var getting = browser.windows.getCurrent({
populate: true
});
getting.then(setTitle, onError);
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os == "android") {
console.log("Running in Android detected");
return true;
} else {
browser.tabs.onActivated.addListener(() => {
var getting = browser.windows.getCurrent({
populate: true
});
getting.then(setTitle, onError);
});
}
});
function handleUpdated(updateInfo) {

View File

@@ -1,19 +1,18 @@
//var windowIds = []
function onCreated(windowInfo) {
console.log(`Created window: ${windowInfo.id}`);
browser.tabs.create({
windowId: windowInfo.id,
url: "about:blank",
cookieStoreId: event.target.dataset.identity
});
}
function onError(error) {
console.log(`Error: ${error}`);
}
function eventHandler(event) {
function onCreated(windowInfo) {
console.log(`Created window: ${windowInfo.id}`);
browser.tabs.create({
windowId: windowInfo.id,
url: "about:blank",
cookieStoreId: event.target.dataset.identity
});
}
if (event.target.dataset.action == "create") {
var creating = browser.tabs.create({
cookieStoreId: event.target.dataset.identity

6
debian/changelog vendored
View File

@@ -1,3 +1,9 @@
i2psetproxy.js (0.49-1) UNRELEASED; urgency=low
* fix tabs
-- idk <hankhill19580@gmail.com> Sat, 23 NOV 2019 22:51:11 -0400
i2psetproxy.js (0.47-1) UNRELEASED; urgency=low
* Improve android compatibility

View File

@@ -21,9 +21,9 @@ function trimHost(url) {
} else {
hostname = url.split("/")[0];
}
let path = url.replace(prefix+hostname, "")
console.log("(handler) path", prefix+hostname, path)
return path
let path = url.replace(prefix + hostname, "");
console.log("(handler) path", prefix + hostname, path);
return path;
}
var handlerSetup = async function(requestDetails) {

View File

@@ -1,6 +1,6 @@
document.addEventListener("click", e => {
function getCurrentWindow() {
return chrome.windows.getCurrent();
return browser.windows.getCurrent();
}
if (e.target.id === "window-create-help-panel") {
@@ -38,7 +38,7 @@ document.addEventListener("click", e => {
let updateInfo = {
titlePreface: "I2P Help | "
};
chrome.windows.update(currentWindow.id, updateInfo);
browser.windows.update(currentWindow.id, updateInfo);
});
} else if (e.target.id === "window-visit-homepage") {
console.log("attempting to create homepage tab");

View File

@@ -24,7 +24,7 @@
],
"manifest_version": 2,
"name": "__MSG_extensionName__",
"version": "0.46",
"version": "0.48",
"description": "__MSG_extensionDescription__",
"homepage_url": "https://github.com/eyedeekay/i2psetproxy.js",
"icons": {

View File

@@ -333,9 +333,18 @@ var contextSetup = async function(requestDetails) {
});
created.then(onCreated, onError);
}
var getting = browser.windows.getCurrent();
getting.then(Create);
return tabId;
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os == "android") {
var getting = browser.tabs.getCurrent();
getting.then(Create);
return tabId;
} else {
var getting = browser.windows.getCurrent();
getting.then(Create);
return tabId;
}
});
}
}
} catch (error) {