diff --git a/Makefile b/Makefile index 3150e13..3ce0e52 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/background.js b/background.js index 230db28..bee4126 100644 --- a/background.js +++ b/background.js @@ -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) { diff --git a/context.js b/context.js index ad4a8b0..5df468b 100644 --- a/context.js +++ b/context.js @@ -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 diff --git a/debian/changelog b/debian/changelog index 11b6f36..b2e9217 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +i2psetproxy.js (0.49-1) UNRELEASED; urgency=low + + * fix tabs + + -- idk Sat, 23 NOV 2019 22:51:11 -0400 + i2psetproxy.js (0.47-1) UNRELEASED; urgency=low * Improve android compatibility diff --git a/handler.js b/handler.js index 0666be8..379d77d 100644 --- a/handler.js +++ b/handler.js @@ -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) { diff --git a/info.js b/info.js index 6f54122..d7ae4cd 100644 --- a/info.js +++ b/info.js @@ -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"); diff --git a/manifest.json b/manifest.json index 6341866..973556c 100644 --- a/manifest.json +++ b/manifest.json @@ -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": { diff --git a/scrub.js b/scrub.js index e8b500e..689f855 100644 --- a/scrub.js +++ b/scrub.js @@ -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) {