reuse less function names

This commit is contained in:
idk
2019-11-24 17:14:43 -05:00
parent 875fe8b86d
commit 2bbeed8385
2 changed files with 20 additions and 12 deletions

View File

@@ -11,7 +11,7 @@ var torrentprefpriv = chrome.i18n.getMessage("torrentPrefacePrivate");
var tunnelpref = chrome.i18n.getMessage("i2ptunnelPreface");
var tunnelprefpriv = chrome.i18n.getMessage("i2ptunnelPrefacePrivate");
function onGot(contexts) {
function onContextsGot(contexts) {
var ids = [];
for (let context of contexts) {
console.log(`Name: ${context.name}`);
@@ -82,7 +82,15 @@ function onError(e) {
console.error(e);
}
browser.contextualIdentities.query({}).then(onGot, onError);
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os == "android") {
} else {
browser.windows.onCreated.addListener(() => {
browser.contextualIdentities.query({}).then(onContextsGot, onError);
});
}
});
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
@@ -120,7 +128,7 @@ function themeWindowByTab(tabId) {
function themeWindow(window) {
// Check if the window is in private browsing
function logTabs(tabInfo) {
function onGot(context) {
function onContextGotTheme(context) {
if (context.name == titlepref) {
console.log("Active in I2P window");
if (window.incognito) {
@@ -217,7 +225,7 @@ function themeWindow(window) {
) {
browser.contextualIdentities
.get(tabInfo[0].cookieStoreId)
.then(onGot, onError);
.then(onContextGotTheme, onError);
} else {
browser.theme.reset(window.id);
}
@@ -234,7 +242,7 @@ function setTitle(window) {
function logTabs(tabInfo) {
console.log(tabInfo);
function onGot(context) {
function onContextGotTitle(context) {
if (context.name == titlepref) {
console.log("Active in I2P window");
@@ -315,7 +323,7 @@ function setTitle(window) {
) {
browser.contextualIdentities
.get(tabInfo[0].cookieStoreId)
.then(onGot, onError);
.then(onContextGotTitle, onError);
} else {
if (window.incognito) {
browser.windows.update(window.id, {

View File

@@ -256,28 +256,28 @@ function forgetBrowsingData(storedSettings) {
hostnames: [i2pHostName(item.url)],
since
})
.then(onGot);
.then(onContextGotLog);
console.log("cleared Passwords");
browser.browsingData
.removeDownloads({
hostnames: [i2pHostName(item.url)],
since
})
.then(onGot);
.then(onContextGotLog);
console.log("cleared Downloads");
browser.browsingData
.removeFormData({
hostnames: [i2pHostName(item.url)],
since
})
.then(onGot);
.then(onContextGotLog);
console.log("cleared Form Data");
browser.browsingData
.removeLocalStorage({
hostnames: [i2pHostName(item.url)],
since
})
.then(onGot);
.then(onContextGotLog);
console.log("cleared Local Storage");
contexts = browser.contextualIdentities.query({
@@ -291,7 +291,7 @@ function forgetBrowsingData(storedSettings) {
name: cookie.name,
url: item.url
});
removing.then(onGot, onError);
removing.then(onContextGotLog, onError);
}
console.log("Cleared cookies");
}
@@ -338,7 +338,7 @@ function i2pHost(url) {
return hostname.endsWith(".i2p");
}
function onGot(contexts) {
function onContextGotLog(contexts) {
if (contexts != null) {
for (let context of contexts) {
console.log(context);