restore manifest.json to desktop version, android still doesn't have the required APIs
This commit is contained in:
212
background.js
212
background.js
@@ -1,28 +1,28 @@
|
||||
var titlepref = chrome.i18n.getMessage("titlePreface");
|
||||
var titleprefpriv = chrome.i18n.getMessage("titlePrefacePrivate");
|
||||
var webpref = chrome.i18n.getMessage("webPreface");
|
||||
var webprefpriv = chrome.i18n.getMessage("webPrefacePrivate");
|
||||
var routerpref = chrome.i18n.getMessage("routerPreface");
|
||||
var routerprefpriv = chrome.i18n.getMessage("routerPrefacePrivate");
|
||||
var mailpref = chrome.i18n.getMessage("mailPreface");
|
||||
var mailprefpriv = chrome.i18n.getMessage("mailPrefacePrivate");
|
||||
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 ircpref = chrome.i18n.getMessage("ircPreface");
|
||||
var ircprefpriv = chrome.i18n.getMessage("ircPrefacePrivate");
|
||||
var extensionpref = chrome.i18n.getMessage("extensionPreface");
|
||||
var muwirepref = chrome.i18n.getMessage("muwirePreface");
|
||||
var muwireprefpriv = chrome.i18n.getMessage("muwirePrefacePrivate");
|
||||
var botepref = chrome.i18n.getMessage("botePreface");
|
||||
var blogpref = chrome.i18n.getMessage("blogPreface");
|
||||
var blogprefpriv = chrome.i18n.getMessage("blogPrefacePrivate");
|
||||
var torpref = chrome.i18n.getMessage("torPreface");
|
||||
var torprefpriv = chrome.i18n.getMessage("torPrefacePrivate");
|
||||
var titlepref = chrome.i18n.getMessage('titlePreface');
|
||||
var titleprefpriv = chrome.i18n.getMessage('titlePrefacePrivate');
|
||||
var webpref = chrome.i18n.getMessage('webPreface');
|
||||
var webprefpriv = chrome.i18n.getMessage('webPrefacePrivate');
|
||||
var routerpref = chrome.i18n.getMessage('routerPreface');
|
||||
var routerprefpriv = chrome.i18n.getMessage('routerPrefacePrivate');
|
||||
var mailpref = chrome.i18n.getMessage('mailPreface');
|
||||
var mailprefpriv = chrome.i18n.getMessage('mailPrefacePrivate');
|
||||
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 ircpref = chrome.i18n.getMessage('ircPreface');
|
||||
var ircprefpriv = chrome.i18n.getMessage('ircPrefacePrivate');
|
||||
var extensionpref = chrome.i18n.getMessage('extensionPreface');
|
||||
var muwirepref = chrome.i18n.getMessage('muwirePreface');
|
||||
var muwireprefpriv = chrome.i18n.getMessage('muwirePrefacePrivate');
|
||||
var botepref = chrome.i18n.getMessage('botePreface');
|
||||
var blogpref = chrome.i18n.getMessage('blogPreface');
|
||||
var blogprefpriv = chrome.i18n.getMessage('blogPrefacePrivate');
|
||||
var torpref = chrome.i18n.getMessage('torPreface');
|
||||
var torprefpriv = chrome.i18n.getMessage('torPrefacePrivate');
|
||||
|
||||
function onError(err) {
|
||||
console.log("(background)", err);
|
||||
console.log('(background)', err);
|
||||
}
|
||||
|
||||
function onContextGotLog(contexts) {
|
||||
@@ -37,13 +37,13 @@ function onContextsGot(contexts) {
|
||||
console.log(`Name : ${context.name}`);
|
||||
ids.push(context.name);
|
||||
}
|
||||
console.log("Checking new contexts");
|
||||
console.log('Checking new contexts');
|
||||
if (ids.indexOf(titlepref) == -1) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: titlepref,
|
||||
color: "orange",
|
||||
icon: "fingerprint",
|
||||
color: 'orange',
|
||||
icon: 'fingerprint'
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@@ -51,8 +51,8 @@ function onContextsGot(contexts) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: blogpref,
|
||||
color: "pink",
|
||||
icon: "pet",
|
||||
color: 'pink',
|
||||
icon: 'pet'
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@@ -60,8 +60,8 @@ function onContextsGot(contexts) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: webpref,
|
||||
color: "red",
|
||||
icon: "circle",
|
||||
color: 'red',
|
||||
icon: 'circle'
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@@ -69,8 +69,8 @@ function onContextsGot(contexts) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: routerpref,
|
||||
color: "blue",
|
||||
icon: "briefcase",
|
||||
color: 'blue',
|
||||
icon: 'briefcase'
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@@ -78,8 +78,8 @@ function onContextsGot(contexts) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: tunnelpref,
|
||||
color: "green",
|
||||
icon: "tree",
|
||||
color: 'green',
|
||||
icon: 'tree'
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@@ -87,8 +87,8 @@ function onContextsGot(contexts) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: mailpref,
|
||||
color: "yellow",
|
||||
icon: "briefcase",
|
||||
color: 'yellow',
|
||||
icon: 'briefcase'
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@@ -96,8 +96,8 @@ function onContextsGot(contexts) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: torrentpref,
|
||||
color: "purple",
|
||||
icon: "chill",
|
||||
color: 'purple',
|
||||
icon: 'chill'
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@@ -105,8 +105,8 @@ function onContextsGot(contexts) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: ircpref,
|
||||
color: "red",
|
||||
icon: "vacation",
|
||||
color: 'red',
|
||||
icon: 'vacation'
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@@ -114,8 +114,8 @@ function onContextsGot(contexts) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: torpref,
|
||||
color: "purple",
|
||||
icon: "circle",
|
||||
color: 'purple',
|
||||
icon: 'circle'
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@@ -123,8 +123,8 @@ function onContextsGot(contexts) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: muwirepref,
|
||||
color: "turquoise",
|
||||
icon: "gift",
|
||||
color: 'turquoise',
|
||||
icon: 'gift'
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@@ -132,30 +132,30 @@ function onContextsGot(contexts) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: botepref,
|
||||
color: "blue",
|
||||
icon: "fence",
|
||||
color: 'blue',
|
||||
icon: 'fence'
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
}
|
||||
|
||||
function onContextsError() {
|
||||
console.log("Error finding contextual identities, is the API enabled?");
|
||||
console.log('Error finding contextual identities, is the API enabled?');
|
||||
}
|
||||
|
||||
function onCreated(context) {
|
||||
console.log(" ID:", context.cookieStoreId, "created.");
|
||||
console.log(' ID:', context.cookieStoreId, 'created.');
|
||||
}
|
||||
|
||||
function onNotCreated(context) {
|
||||
console.log("ID:", context.cookieStoreId, "not created.");
|
||||
console.log('ID:', context.cookieStoreId, 'not created.');
|
||||
}
|
||||
|
||||
browser.contextualIdentities.query({}).then(onContextsGot, onContextsError);
|
||||
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os != "android") {
|
||||
if (got.os != 'android') {
|
||||
browser.windows.onCreated.addListener(themeWindow);
|
||||
browser.windows.onFocusChanged.addListener(themeWindow);
|
||||
browser.windows.onRemoved.addListener(themeWindow);
|
||||
@@ -168,7 +168,7 @@ function themeWindowByTab(tabId) {
|
||||
function tabWindow(tab) {
|
||||
var gettingPlatformInfo = browser.runtime.getPlatformInfo();
|
||||
gettingPlatformInfo.then((got) => {
|
||||
if (got.os == "android") {
|
||||
if (got.os == 'android') {
|
||||
let getwindow = browser.tabs.get(tab.tabId);
|
||||
getwindow.then(themeWindow);
|
||||
} else {
|
||||
@@ -177,7 +177,7 @@ function themeWindowByTab(tabId) {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (typeof tabId === "number") {
|
||||
if (typeof tabId === 'number') {
|
||||
let tab = browser.tabs.get(tabId);
|
||||
tab.then(tabWindow);
|
||||
} else {
|
||||
@@ -199,24 +199,24 @@ function isEmpty(obj) {
|
||||
|
||||
let btheme = {
|
||||
colors: {
|
||||
frame: "#363A68",
|
||||
toolbar: "#363A68",
|
||||
tab_text: "#ECF3FF",
|
||||
},
|
||||
frame: '#363A68',
|
||||
toolbar: '#363A68',
|
||||
tab_text: '#ECF3FF'
|
||||
}
|
||||
};
|
||||
|
||||
let dtheme = {
|
||||
colors: {
|
||||
frame: "#4456B7",
|
||||
toolbar: "#4456B7",
|
||||
tab_text: "#ECF3FF",
|
||||
},
|
||||
frame: '#4456B7',
|
||||
toolbar: '#4456B7',
|
||||
tab_text: '#ECF3FF'
|
||||
}
|
||||
};
|
||||
|
||||
function themeWindow(window) {
|
||||
// Check if the window is in private browsing
|
||||
function onThemeError() {
|
||||
console.log("(theme) color set error");
|
||||
console.log('(theme) color set error');
|
||||
browserTheme();
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ function themeWindow(window) {
|
||||
}
|
||||
|
||||
function browserTheme() {
|
||||
console.log("(theme)Active in I2P window");
|
||||
console.log('(theme)Active in I2P window');
|
||||
if (window.incognito) {
|
||||
browser.theme.update(window.id, btheme);
|
||||
} else {
|
||||
@@ -262,18 +262,18 @@ function themeWindow(window) {
|
||||
return false;
|
||||
}
|
||||
let gotTheme = await browser.theme.getCurrent();
|
||||
let check = checkTheme(gotTheme)
|
||||
let check = checkTheme(gotTheme);
|
||||
console.warn(check);
|
||||
return check;
|
||||
}
|
||||
|
||||
async function unsetTheme() {
|
||||
console.log("(theme)Resetting theme window to stored theme");
|
||||
console.log('(theme)Resetting theme window to stored theme');
|
||||
if (unsetting) {
|
||||
return;
|
||||
}
|
||||
let mine = await isMyTheme();
|
||||
console.warn(mine)
|
||||
console.warn(mine);
|
||||
if (!mine) {
|
||||
return;
|
||||
}
|
||||
@@ -282,15 +282,15 @@ function themeWindow(window) {
|
||||
|
||||
function gotAllThemes(infoArray) {
|
||||
for (const info of infoArray) {
|
||||
if (info.type === "theme") {
|
||||
if (info.type === 'theme') {
|
||||
if (info.enabled) {
|
||||
console.log("(theme) found enabled theme in list", info.id);
|
||||
console.log('(theme) found enabled theme in list', info.id);
|
||||
|
||||
async function resetEnabled() {
|
||||
console.log("(theme) disabled theme temporarily", info.id);
|
||||
console.log('(theme) disabled theme temporarily', info.id);
|
||||
|
||||
function logReset(prom) {
|
||||
console.log("(theme) re-enabled:", info.id);
|
||||
console.log('(theme) re-enabled:', info.id);
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
@@ -321,53 +321,53 @@ function themeWindow(window) {
|
||||
browserTheme();
|
||||
browser.pageAction.show(tabInfo[0].id);
|
||||
} else if (context.name == routerpref) {
|
||||
console.log("(theme) Active in Router Console window");
|
||||
console.log('(theme) Active in Router Console window');
|
||||
dynamicTheme();
|
||||
} else if (context.name == tunnelpref) {
|
||||
console.log("(theme) Active in Hidden Services Manager window");
|
||||
console.log('(theme) Active in Hidden Services Manager window');
|
||||
dynamicTheme();
|
||||
} else if (context.name == mailpref) {
|
||||
console.log("(theme) Active in Web Mail window");
|
||||
console.log('(theme) Active in Web Mail window');
|
||||
dynamicTheme();
|
||||
} else if (context.name == torrentpref) {
|
||||
console.log("(theme) Active in Bittorrent window");
|
||||
console.log('(theme) Active in Bittorrent window');
|
||||
dynamicTheme();
|
||||
} else if (context.name == botepref) {
|
||||
console.log("(theme) Active in Bote window");
|
||||
console.log('(theme) Active in Bote window');
|
||||
dynamicTheme();
|
||||
} else if (context.name == ircpref) {
|
||||
console.log("(theme) Active in IRC window");
|
||||
console.log('(theme) Active in IRC window');
|
||||
dynamicTheme();
|
||||
} else if (context.name == torpref) {
|
||||
console.log("(theme) Active in Tor Manager window");
|
||||
console.log('(theme) Active in Tor Manager window');
|
||||
dynamicTheme();
|
||||
} else if (context.name == blogpref) {
|
||||
console.log("(theme) (theme) Active in Blog window");
|
||||
console.log('(theme) (theme) Active in Blog window');
|
||||
dynamicTheme();
|
||||
} else if (context.name == muwirepref) {
|
||||
console.log("(theme) Active in MuWire window");
|
||||
console.log('(theme) Active in MuWire window');
|
||||
dynamicTheme();
|
||||
} else {
|
||||
console.log("(theme) Not active in I2P Window");
|
||||
console.log('(theme) Not active in I2P Window');
|
||||
unsetTheme();
|
||||
}
|
||||
}
|
||||
if (
|
||||
tabInfo[0].cookieStoreId != "firefox-default" &&
|
||||
tabInfo[0].cookieStoreId != "firefox-private"
|
||||
tabInfo[0].cookieStoreId != 'firefox-default' &&
|
||||
tabInfo[0].cookieStoreId != 'firefox-private'
|
||||
) {
|
||||
browser.contextualIdentities
|
||||
.get(tabInfo[0].cookieStoreId)
|
||||
.then(onContextGotTheme, onThemeError);
|
||||
} else {
|
||||
console.log("(theme) Not active in I2P window");
|
||||
console.log('(theme) Not active in I2P window');
|
||||
unsetTheme();
|
||||
}
|
||||
}
|
||||
|
||||
var querying = browser.tabs.query({
|
||||
currentWindow: true,
|
||||
active: true,
|
||||
active: true
|
||||
});
|
||||
querying.then(logTabs, onThemeError);
|
||||
}
|
||||
@@ -375,17 +375,17 @@ function themeWindow(window) {
|
||||
function setTitle(window) {
|
||||
// Check if the window is in private browsing
|
||||
function onContextError() {
|
||||
console.log("Context Error");
|
||||
console.log('Context Error');
|
||||
}
|
||||
|
||||
function setTitle(title, privtitle) {
|
||||
if (window.incognito) {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: privtitle + ": ",
|
||||
titlePreface: privtitle + ': '
|
||||
});
|
||||
} else {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: title + ": ",
|
||||
titlePreface: title + ': '
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -393,59 +393,59 @@ function setTitle(window) {
|
||||
function logTabs(tabInfo) {
|
||||
function onContextGotTitle(context) {
|
||||
if (context.name == titlepref) {
|
||||
console.log("Active in I2P window");
|
||||
console.log('Active in I2P window');
|
||||
setTitle(titlepref, titleprefpriv);
|
||||
} else if (context.name == muwirepref) {
|
||||
console.log("Active in MuWire window");
|
||||
console.log('Active in MuWire window');
|
||||
setTitle(muwirepref, muwireprefpriv);
|
||||
} else if (context.name == routerpref) {
|
||||
console.log("Active in Router Console window");
|
||||
console.log('Active in Router Console window');
|
||||
setTitle(routerpref, routerprefpriv);
|
||||
} else if (context.name == botepref) {
|
||||
console.log("Active in Bote window");
|
||||
console.log('Active in Bote window');
|
||||
setTitle(botepref, boteprefpriv);
|
||||
} else if (context.name == tunnelpref) {
|
||||
console.log("Active in Hidden Services Manager window");
|
||||
console.log('Active in Hidden Services Manager window');
|
||||
setTitle(tunnelpref, tunnelprefpriv);
|
||||
} else if (context.name == mailpref) {
|
||||
console.log("Active in I2P Web Mail window");
|
||||
console.log('Active in I2P Web Mail window');
|
||||
setTitle(mailpref, mailprefpriv);
|
||||
} else if (context.name == blogpref) {
|
||||
console.log("Active in I2P Blog window");
|
||||
console.log('Active in I2P Blog window');
|
||||
setTitle(blogpref, blogprefpriv);
|
||||
} else if (context.name == torrentpref) {
|
||||
console.log("Active in I2P Torrent window");
|
||||
console.log('Active in I2P Torrent window');
|
||||
setTitle(torrentpref, torrentprefpriv);
|
||||
} else if (context.name == ircpref) {
|
||||
console.log("Active in IRC window");
|
||||
console.log('Active in IRC window');
|
||||
setTitle(ircpref, ircprefpriv);
|
||||
} else if (context.name == torpref) {
|
||||
console.log("Active in Tor Manager window");
|
||||
console.log('Active in Tor Manager window');
|
||||
setTitle(torpref, torprefpriv);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
tabInfo[0].cookieStoreId != "firefox-default" &&
|
||||
tabInfo[0].cookieStoreId != "firefox-private"
|
||||
tabInfo[0].cookieStoreId != 'firefox-default' &&
|
||||
tabInfo[0].cookieStoreId != 'firefox-private'
|
||||
) {
|
||||
browser.contextualIdentities
|
||||
.get(tabInfo[0].cookieStoreId)
|
||||
.then(onContextGotTitle, onContextError);
|
||||
} else if (window.incognito) {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: "",
|
||||
titlePreface: ''
|
||||
});
|
||||
} else {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: "",
|
||||
titlePreface: ''
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var querying = browser.tabs.query({
|
||||
currentWindow: true,
|
||||
active: true,
|
||||
active: true
|
||||
});
|
||||
querying.then(logTabs, onContextError);
|
||||
}
|
||||
@@ -453,18 +453,18 @@ function setTitle(window) {
|
||||
var gettingListenerInfo = browser.runtime.getPlatformInfo();
|
||||
gettingListenerInfo.then((got) => {
|
||||
function onPlatformError() {
|
||||
console.log("Error finding platform info");
|
||||
console.log('Error finding platform info');
|
||||
}
|
||||
if (got.os != "android") {
|
||||
if (got.os != 'android') {
|
||||
browser.tabs.onCreated.addListener(() => {
|
||||
var getting = browser.windows.getCurrent({
|
||||
populate: true,
|
||||
populate: true
|
||||
});
|
||||
getting.then(setTitle, onPlatformError);
|
||||
});
|
||||
browser.tabs.onActivated.addListener(() => {
|
||||
var getting = browser.windows.getCurrent({
|
||||
populate: true,
|
||||
populate: true
|
||||
});
|
||||
getting.then(setTitle, onPlatformError);
|
||||
});
|
||||
@@ -561,4 +561,4 @@ if (browser.windows != undefined) {
|
||||
console.log("windows unavailable on android", browser.runtime.PlatformOs);
|
||||
browser.windows.onRemoved.addListener(onClosedWindowCheck);
|
||||
browser.windows.onCreated.addListener(onOpenedWindowCheck);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user