2020-01-14 14:49:48 -05:00
|
|
|
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 localpref = chrome.i18n.getMessage('localPreface');
|
|
|
|
var localprefpriv = chrome.i18n.getMessage('localPrefacePrivate');
|
|
|
|
var extensionpref = chrome.i18n.getMessage('extensionPreface');
|
2019-11-11 23:31:37 -05:00
|
|
|
|
2019-11-24 17:14:43 -05:00
|
|
|
function onContextsGot(contexts) {
|
2019-10-06 15:18:10 -04:00
|
|
|
var ids = [];
|
|
|
|
for (let context of contexts) {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log(`Name : ${context.name}`);
|
2019-10-06 15:18:10 -04:00
|
|
|
ids.push(context.name);
|
|
|
|
}
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Checking new contexts');
|
2019-11-11 23:31:37 -05:00
|
|
|
if (ids.indexOf(titlepref) == -1) {
|
2019-12-24 16:51:38 -05:00
|
|
|
browser.contextualIdentities
|
|
|
|
.create({
|
2019-11-11 23:31:37 -05:00
|
|
|
name: titlepref,
|
2020-01-14 14:49:48 -05:00
|
|
|
color: 'orange',
|
|
|
|
icon: 'fingerprint'
|
2019-12-24 16:51:38 -05:00
|
|
|
})
|
2020-01-02 13:59:21 -05:00
|
|
|
.then(onCreated, onNotCreated);
|
2019-10-06 15:18:10 -04:00
|
|
|
}
|
2019-11-11 23:31:37 -05:00
|
|
|
if (ids.indexOf(webpref) == -1) {
|
2019-12-24 16:51:38 -05:00
|
|
|
browser.contextualIdentities
|
|
|
|
.create({
|
2019-11-11 23:31:37 -05:00
|
|
|
name: webpref,
|
2020-01-14 14:49:48 -05:00
|
|
|
color: 'red',
|
|
|
|
icon: 'circle'
|
2019-12-24 16:51:38 -05:00
|
|
|
})
|
2020-01-02 13:59:21 -05:00
|
|
|
.then(onCreated, onNotCreated);
|
2019-11-11 00:03:24 -05:00
|
|
|
}
|
2019-11-11 23:31:37 -05:00
|
|
|
if (ids.indexOf(routerpref) == -1) {
|
2019-12-24 16:51:38 -05:00
|
|
|
browser.contextualIdentities
|
|
|
|
.create({
|
2019-11-11 23:31:37 -05:00
|
|
|
name: routerpref,
|
2020-01-14 14:49:48 -05:00
|
|
|
color: 'blue',
|
|
|
|
icon: 'briefcase'
|
2019-12-24 16:51:38 -05:00
|
|
|
})
|
2020-01-02 13:59:21 -05:00
|
|
|
.then(onCreated, onNotCreated);
|
2019-10-06 22:11:23 -04:00
|
|
|
}
|
2019-11-11 23:31:37 -05:00
|
|
|
if (ids.indexOf(tunnelpref) == -1) {
|
2019-12-24 16:51:38 -05:00
|
|
|
browser.contextualIdentities
|
|
|
|
.create({
|
2019-11-11 23:31:37 -05:00
|
|
|
name: tunnelpref,
|
2020-01-14 14:49:48 -05:00
|
|
|
color: 'green',
|
|
|
|
icon: 'tree'
|
2019-12-24 16:51:38 -05:00
|
|
|
})
|
2020-01-02 13:59:21 -05:00
|
|
|
.then(onCreated, onNotCreated);
|
2019-11-11 16:34:41 -05:00
|
|
|
}
|
2019-11-11 23:31:37 -05:00
|
|
|
if (ids.indexOf(mailpref) == -1) {
|
2019-12-24 16:51:38 -05:00
|
|
|
browser.contextualIdentities
|
|
|
|
.create({
|
2019-11-11 23:31:37 -05:00
|
|
|
name: mailpref,
|
2020-01-14 14:49:48 -05:00
|
|
|
color: 'yellow',
|
|
|
|
icon: 'briefcase'
|
2019-12-24 16:51:38 -05:00
|
|
|
})
|
2020-01-02 13:59:21 -05:00
|
|
|
.then(onCreated, onNotCreated);
|
2019-11-11 16:34:41 -05:00
|
|
|
}
|
2019-11-11 23:31:37 -05:00
|
|
|
if (ids.indexOf(torrentpref) == -1) {
|
2019-12-24 16:51:38 -05:00
|
|
|
browser.contextualIdentities
|
|
|
|
.create({
|
2019-11-11 23:31:37 -05:00
|
|
|
name: torrentpref,
|
2020-01-14 14:49:48 -05:00
|
|
|
color: 'purple',
|
|
|
|
icon: 'chill'
|
2019-12-24 16:51:38 -05:00
|
|
|
})
|
2020-01-02 13:59:21 -05:00
|
|
|
.then(onCreated, onNotCreated);
|
2019-11-11 16:34:41 -05:00
|
|
|
}
|
2019-12-24 18:31:44 -05:00
|
|
|
if (ids.indexOf(localpref) == -1) {
|
|
|
|
browser.contextualIdentities
|
|
|
|
.create({
|
|
|
|
name: localpref,
|
2020-01-14 14:49:48 -05:00
|
|
|
color: 'red',
|
|
|
|
icon: 'fence'
|
2019-12-24 18:31:44 -05:00
|
|
|
})
|
2020-01-02 13:59:21 -05:00
|
|
|
.then(onCreated, onNotCreated);
|
2019-12-24 18:31:44 -05:00
|
|
|
}
|
2019-07-10 00:47:30 -04:00
|
|
|
}
|
2019-07-13 22:07:24 -04:00
|
|
|
|
2020-01-02 13:59:21 -05:00
|
|
|
function onContextsError() {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Error finding contextual identities, is the API enabled?');
|
2020-01-02 13:59:21 -05:00
|
|
|
}
|
|
|
|
|
2019-10-28 01:11:16 -04:00
|
|
|
function onCreated(context) {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log(' ID:', context.cookieStoreId, 'created.');
|
2019-10-28 01:11:16 -04:00
|
|
|
}
|
|
|
|
|
2020-01-02 13:59:21 -05:00
|
|
|
function onNotCreated(context) {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('ID:', context.cookieStoreId, 'not created.');
|
2020-01-02 13:59:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
browser.contextualIdentities.query({}).then(onContextsGot, onContextsError);
|
2019-06-17 19:17:11 -04:00
|
|
|
|
2019-11-24 04:13:12 -05:00
|
|
|
var gettingInfo = browser.runtime.getPlatformInfo();
|
|
|
|
gettingInfo.then(got => {
|
2020-01-14 14:49:48 -05:00
|
|
|
if (got.os != 'android') {
|
2019-11-24 04:13:12 -05:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
2019-02-05 10:53:26 -05:00
|
|
|
|
2019-10-28 01:11:16 -04:00
|
|
|
function themeWindowByTab(tabId) {
|
|
|
|
function tabWindow(tab) {
|
2020-01-02 13:59:21 -05:00
|
|
|
var gettingPlatformInfo = browser.runtime.getPlatformInfo();
|
|
|
|
gettingPlatformInfo.then(got => {
|
2020-01-14 14:49:48 -05:00
|
|
|
if (got.os == 'android') {
|
2020-01-02 13:59:21 -05:00
|
|
|
let getwindow = browser.tabs.get(tab.tabId);
|
2019-11-24 04:13:12 -05:00
|
|
|
getwindow.then(themeWindow);
|
|
|
|
} else {
|
2020-01-02 13:59:21 -05:00
|
|
|
let getwindow = browser.windows.get(tab.windowId);
|
2019-11-24 04:13:12 -05:00
|
|
|
getwindow.then(themeWindow);
|
|
|
|
}
|
|
|
|
});
|
2019-10-28 01:11:16 -04:00
|
|
|
}
|
2020-01-14 14:49:48 -05:00
|
|
|
if (typeof tabId === 'number') {
|
2020-01-02 13:59:21 -05:00
|
|
|
let tab = browser.tabs.get(tabId);
|
2019-10-28 01:11:16 -04:00
|
|
|
tab.then(tabWindow);
|
|
|
|
} else {
|
|
|
|
tabWindow(tabId);
|
|
|
|
}
|
2019-10-07 22:51:53 -04:00
|
|
|
}
|
|
|
|
|
2019-12-24 18:31:44 -05:00
|
|
|
function isEmpty(obj) {
|
2020-01-02 13:59:21 -05:00
|
|
|
if (obj === undefined || obj === null) {
|
|
|
|
return true;
|
|
|
|
}
|
2019-12-24 18:31:44 -05:00
|
|
|
for (var key in obj) {
|
2020-01-02 13:59:21 -05:00
|
|
|
if (obj.hasOwnProperty(key)) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-12-24 18:31:44 -05:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-01-02 13:59:21 -05:00
|
|
|
var oldtheme = null;
|
2019-12-24 18:31:44 -05:00
|
|
|
|
|
|
|
var getOldTheme = async function getOldTheme() {
|
2020-01-02 13:59:21 -05:00
|
|
|
let foundtheme = await browser.theme.getCurrent();
|
2019-12-24 18:31:44 -05:00
|
|
|
if (!isEmpty(foundtheme)) {
|
|
|
|
oldtheme = foundtheme;
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Found old theme', oldtheme);
|
2019-12-24 18:31:44 -05:00
|
|
|
}
|
|
|
|
return oldtheme;
|
2020-01-14 14:49:48 -05:00
|
|
|
}
|
2019-12-24 18:31:44 -05:00
|
|
|
|
|
|
|
getOldTheme();
|
|
|
|
|
2019-02-05 10:53:26 -05:00
|
|
|
function themeWindow(window) {
|
2019-10-06 15:18:10 -04:00
|
|
|
// Check if the window is in private browsing
|
2019-12-24 18:31:44 -05:00
|
|
|
function onThemeError() {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('got theme', oldtheme);
|
2019-12-24 18:31:44 -05:00
|
|
|
browser.theme.update(oldtheme);
|
|
|
|
}
|
2019-10-06 15:18:10 -04:00
|
|
|
function logTabs(tabInfo) {
|
2019-11-24 17:14:43 -05:00
|
|
|
function onContextGotTheme(context) {
|
2019-11-11 23:31:37 -05:00
|
|
|
if (context.name == titlepref) {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Active in I2P window');
|
2019-10-06 15:18:10 -04:00
|
|
|
if (window.incognito) {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.theme.update(window.id, {
|
2019-10-06 15:18:10 -04:00
|
|
|
colors: {
|
2020-01-14 14:49:48 -05:00
|
|
|
frame: '#FFC56D',
|
|
|
|
toolbar: '#FFC56D'
|
2019-10-06 15:18:10 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.theme.update(window.id, {
|
2019-10-06 15:18:10 -04:00
|
|
|
colors: {
|
2020-01-14 14:49:48 -05:00
|
|
|
frame: '#FFC56D',
|
|
|
|
toolbar: '#FFC56D'
|
2019-07-13 22:07:24 -04:00
|
|
|
}
|
2019-10-06 15:18:10 -04:00
|
|
|
});
|
2019-07-10 02:29:38 -04:00
|
|
|
}
|
2019-11-11 23:31:37 -05:00
|
|
|
} else if (context.name == routerpref) {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Active in Router Console window');
|
2019-10-08 19:10:13 -04:00
|
|
|
if (window.incognito) {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.theme.update(window.id, {
|
2019-10-08 19:10:13 -04:00
|
|
|
colors: {
|
2020-01-14 14:49:48 -05:00
|
|
|
frame: '#A4C8E1',
|
|
|
|
toolbar: '#A4C8E1'
|
2019-10-08 19:10:13 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.theme.update(window.id, {
|
2019-10-08 19:10:13 -04:00
|
|
|
colors: {
|
2020-01-14 14:49:48 -05:00
|
|
|
frame: '#A4C8E1',
|
|
|
|
toolbar: '#A4C8E1'
|
2019-10-08 19:10:13 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-11-11 23:31:37 -05:00
|
|
|
} else if (context.name == tunnelpref) {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Active in Hidden Services Manager window');
|
2019-11-11 16:34:41 -05:00
|
|
|
if (window.incognito) {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.theme.update(window.id, {
|
2019-11-11 16:34:41 -05:00
|
|
|
colors: {
|
2020-01-14 14:49:48 -05:00
|
|
|
frame: '#D9D9D6',
|
|
|
|
toolbar: '#D9D9D6'
|
2019-11-11 16:34:41 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.theme.update(window.id, {
|
2019-11-11 16:34:41 -05:00
|
|
|
colors: {
|
2020-01-14 14:49:48 -05:00
|
|
|
frame: '#D9D9D6',
|
|
|
|
toolbar: '#D9D9D6'
|
2019-11-11 16:34:41 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-11-11 23:31:37 -05:00
|
|
|
} else if (context.name == mailpref) {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Active in Web Mail window');
|
2019-11-11 16:34:41 -05:00
|
|
|
if (window.incognito) {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.theme.update(window.id, {
|
2019-11-11 16:34:41 -05:00
|
|
|
colors: {
|
2020-01-14 14:49:48 -05:00
|
|
|
frame: '#F7E59A',
|
|
|
|
toolbar: '#F7E59A'
|
2019-11-11 16:34:41 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.theme.update(window.id, {
|
2019-11-11 16:34:41 -05:00
|
|
|
colors: {
|
2020-01-14 14:49:48 -05:00
|
|
|
frame: '#F7E59A',
|
|
|
|
toolbar: '#F7E59A'
|
2019-11-11 16:34:41 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-11-11 23:31:37 -05:00
|
|
|
} else if (context.name == torrentpref) {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Active in Bittorrent window');
|
2019-11-11 16:34:41 -05:00
|
|
|
if (window.incognito) {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.theme.update(window.id, {
|
2019-11-11 16:34:41 -05:00
|
|
|
colors: {
|
2020-01-14 14:49:48 -05:00
|
|
|
frame: '#A48FE1',
|
|
|
|
toolbar: '#A48FE1'
|
2019-11-11 16:34:41 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.theme.update(window.id, {
|
2019-11-11 16:34:41 -05:00
|
|
|
colors: {
|
2020-01-14 14:49:48 -05:00
|
|
|
frame: '#A48FE1',
|
|
|
|
toolbar: '#A48FE1'
|
2019-11-11 16:34:41 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-10-06 15:18:10 -04:00
|
|
|
} else {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Not active in I2P window');
|
2020-01-02 13:59:21 -05:00
|
|
|
if (isEmpty(oldtheme)) {
|
|
|
|
browser.theme.reset();
|
|
|
|
} else {
|
|
|
|
browser.theme.update(window.id, oldtheme);
|
|
|
|
}
|
2019-10-06 15:18:10 -04:00
|
|
|
}
|
2019-07-10 02:29:38 -04:00
|
|
|
}
|
2019-11-10 20:28:31 -05:00
|
|
|
if (
|
2020-01-14 14:49:48 -05:00
|
|
|
tabInfo[0].cookieStoreId != 'firefox-default' &&
|
|
|
|
tabInfo[0].cookieStoreId != 'firefox-private'
|
2019-11-10 20:28:31 -05:00
|
|
|
) {
|
2019-12-24 16:51:38 -05:00
|
|
|
browser.contextualIdentities
|
|
|
|
.get(tabInfo[0].cookieStoreId)
|
2019-12-24 18:31:44 -05:00
|
|
|
.then(onContextGotTheme, onThemeError);
|
2020-01-04 10:29:41 -05:00
|
|
|
} else if (isEmpty(oldtheme)) {
|
|
|
|
browser.theme.reset();
|
2019-10-08 19:10:13 -04:00
|
|
|
} else {
|
2020-01-04 10:29:41 -05:00
|
|
|
browser.theme.update(window.id, oldtheme);
|
2019-10-07 22:51:53 -04:00
|
|
|
}
|
2019-10-06 15:18:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
var querying = browser.tabs.query({
|
|
|
|
currentWindow: true,
|
|
|
|
active: true
|
|
|
|
});
|
2020-01-02 13:59:21 -05:00
|
|
|
querying.then(logTabs, onThemeError);
|
2019-02-05 10:53:26 -05:00
|
|
|
}
|
2019-02-07 20:14:57 -05:00
|
|
|
|
2019-06-27 15:40:43 -04:00
|
|
|
function setTitle(window) {
|
2020-01-02 13:59:21 -05:00
|
|
|
// Check if the window is in private browsing
|
|
|
|
function onContextError() {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Context Error');
|
2020-01-02 13:59:21 -05:00
|
|
|
}
|
2019-10-06 15:18:10 -04:00
|
|
|
function logTabs(tabInfo) {
|
2019-11-24 17:14:43 -05:00
|
|
|
function onContextGotTitle(context) {
|
2019-11-11 23:31:37 -05:00
|
|
|
if (context.name == titlepref) {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Active in I2P window');
|
2019-11-11 16:34:41 -05:00
|
|
|
|
|
|
|
if (window.incognito) {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.windows.update(window.id, {
|
2020-01-14 14:49:48 -05:00
|
|
|
titlePreface: titleprefpriv + ': '
|
2019-11-11 16:34:41 -05:00
|
|
|
});
|
|
|
|
} else {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.windows.update(window.id, {
|
2020-01-14 14:49:48 -05:00
|
|
|
titlePreface: titlepref + ': '
|
2019-11-11 16:34:41 -05:00
|
|
|
});
|
|
|
|
}
|
2019-11-11 23:31:37 -05:00
|
|
|
} else if (context.name == webpref) {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Active in Web window');
|
2019-11-11 16:34:41 -05:00
|
|
|
if (window.incognito) {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.windows.update(window.id, {
|
2020-01-14 14:49:48 -05:00
|
|
|
titlePreface: webprefpriv + ' - '
|
2019-11-11 16:34:41 -05:00
|
|
|
});
|
|
|
|
} else {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.windows.update(window.id, {
|
2020-01-14 14:49:48 -05:00
|
|
|
titlePreface: webpref + ' - '
|
2019-11-11 16:34:41 -05:00
|
|
|
});
|
|
|
|
}
|
2019-11-11 23:31:37 -05:00
|
|
|
} else if (context.name == routerpref) {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Active in Router Console window');
|
2019-11-11 16:34:41 -05:00
|
|
|
if (window.incognito) {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.windows.update(window.id, {
|
2020-01-14 14:49:48 -05:00
|
|
|
titlePreface: titleprefpriv + ' - ' + routerprefpriv + ': '
|
2019-11-11 16:34:41 -05:00
|
|
|
});
|
|
|
|
} else {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.windows.update(window.id, {
|
2020-01-14 14:49:48 -05:00
|
|
|
titlePreface: titlepref + ' - ' + routerpref + ': '
|
2019-11-11 16:34:41 -05:00
|
|
|
});
|
|
|
|
}
|
2019-11-11 23:31:37 -05:00
|
|
|
} else if (context.name == tunnelpref) {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Active in Hidden Services Manager window');
|
2019-11-11 16:34:41 -05:00
|
|
|
|
|
|
|
if (window.incognito) {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.windows.update(window.id, {
|
2020-01-14 14:49:48 -05:00
|
|
|
titlePreface: titleprefpriv + ' - ' + tunnelprefpriv + ': '
|
2019-11-11 16:34:41 -05:00
|
|
|
});
|
|
|
|
} else {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.windows.update(window.id, {
|
2020-01-14 14:49:48 -05:00
|
|
|
titlePreface: titlepref + ' - ' + tunnelpref + ': '
|
2019-11-11 16:34:41 -05:00
|
|
|
});
|
|
|
|
}
|
2019-11-11 23:31:37 -05:00
|
|
|
} else if (context.name == mailpref) {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Active in I2P Web Mail window');
|
2019-11-11 16:34:41 -05:00
|
|
|
|
|
|
|
if (window.incognito) {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.windows.update(window.id, {
|
2020-01-14 14:49:48 -05:00
|
|
|
titlePreface: titleprefpriv + ' - ' + mailprefpriv + ': '
|
2019-11-11 16:34:41 -05:00
|
|
|
});
|
|
|
|
} else {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.windows.update(window.id, {
|
2020-01-14 14:49:48 -05:00
|
|
|
titlePreface: titlepref + ' - ' + mailpref + ': '
|
2019-11-11 16:34:41 -05:00
|
|
|
});
|
|
|
|
}
|
2019-11-11 23:31:37 -05:00
|
|
|
} else if (context.name == torrentpref) {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Active in I2P Torrent window');
|
2019-10-06 15:18:10 -04:00
|
|
|
|
|
|
|
if (window.incognito) {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.windows.update(window.id, {
|
2020-01-14 14:49:48 -05:00
|
|
|
titlePreface: titleprefpriv + ' - ' + torrentprefpriv + ': '
|
2019-10-06 15:18:10 -04:00
|
|
|
});
|
|
|
|
} else {
|
2019-11-24 04:13:12 -05:00
|
|
|
browser.windows.update(window.id, {
|
2020-01-14 14:49:48 -05:00
|
|
|
titlePreface: titlepref + ' - ' + torrentpref + ': '
|
2019-10-06 15:18:10 -04:00
|
|
|
});
|
2019-07-13 22:07:24 -04:00
|
|
|
}
|
2019-12-24 18:44:58 -05:00
|
|
|
} else if (context.name == localpref) {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Active in Localhost window');
|
2019-12-24 18:44:58 -05:00
|
|
|
|
|
|
|
if (window.incognito) {
|
|
|
|
browser.windows.update(window.id, {
|
2020-01-14 14:49:48 -05:00
|
|
|
titlePreface: localprefpriv + ' - ' + localprefpriv + ': '
|
2019-12-24 18:44:58 -05:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
browser.windows.update(window.id, {
|
2020-01-14 14:49:48 -05:00
|
|
|
titlePreface: localpref + ' - ' + localpref + ': '
|
2019-12-24 18:44:58 -05:00
|
|
|
});
|
|
|
|
}
|
2019-10-06 15:18:10 -04:00
|
|
|
}
|
2019-07-10 02:29:38 -04:00
|
|
|
}
|
2019-07-13 22:07:24 -04:00
|
|
|
|
2019-11-10 20:28:31 -05:00
|
|
|
if (
|
2020-01-14 14:49:48 -05:00
|
|
|
tabInfo[0].cookieStoreId != 'firefox-default' &&
|
|
|
|
tabInfo[0].cookieStoreId != 'firefox-private'
|
2019-11-10 20:28:31 -05:00
|
|
|
) {
|
2019-12-24 16:51:38 -05:00
|
|
|
browser.contextualIdentities
|
|
|
|
.get(tabInfo[0].cookieStoreId)
|
2020-01-02 13:59:21 -05:00
|
|
|
.then(onContextGotTitle, onContextError);
|
2019-12-24 11:21:07 -05:00
|
|
|
} else if (window.incognito) {
|
2019-12-24 16:51:38 -05:00
|
|
|
browser.windows.update(window.id, {
|
2020-01-14 14:49:48 -05:00
|
|
|
titlePreface: ''
|
2019-12-24 16:51:38 -05:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
browser.windows.update(window.id, {
|
2020-01-14 14:49:48 -05:00
|
|
|
titlePreface: ''
|
2019-12-24 16:51:38 -05:00
|
|
|
});
|
|
|
|
}
|
2019-10-06 15:18:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
var querying = browser.tabs.query({
|
|
|
|
currentWindow: true,
|
|
|
|
active: true
|
|
|
|
});
|
2020-01-02 13:59:21 -05:00
|
|
|
querying.then(logTabs, onContextError);
|
2019-02-19 11:43:44 -05:00
|
|
|
}
|
2019-02-07 20:14:57 -05:00
|
|
|
|
2020-01-02 13:59:21 -05:00
|
|
|
var gettingListenerInfo = browser.runtime.getPlatformInfo();
|
|
|
|
gettingListenerInfo.then(got => {
|
|
|
|
function onPlatformError() {
|
2020-01-14 14:49:48 -05:00
|
|
|
console.log('Error finding platform info');
|
2020-01-02 13:59:21 -05:00
|
|
|
}
|
2020-01-14 14:49:48 -05:00
|
|
|
if (got.os != 'android') {
|
2020-01-02 13:59:21 -05:00
|
|
|
browser.tabs.onCreated.addListener(() => {
|
|
|
|
var getting = browser.windows.getCurrent({
|
|
|
|
populate: true
|
|
|
|
});
|
|
|
|
getting.then(setTitle, onPlatformError);
|
|
|
|
});
|
|
|
|
browser.tabs.onActivated.addListener(() => {
|
|
|
|
var getting = browser.windows.getCurrent({
|
|
|
|
populate: true
|
|
|
|
});
|
|
|
|
getting.then(setTitle, onPlatformError);
|
|
|
|
});
|
2019-11-24 04:32:35 -05:00
|
|
|
}
|
2019-02-07 20:14:57 -05:00
|
|
|
});
|
2020-01-13 15:22:02 -05:00
|
|
|
|
2019-11-11 23:31:37 -05:00
|
|
|
function handleUpdated(updateInfo) {
|
2019-12-24 18:31:44 -05:00
|
|
|
if (updateInfo.theme) {
|
2019-11-11 23:31:37 -05:00
|
|
|
console.log(`Theme was applied: ${updateInfo.theme}`);
|
|
|
|
} else {
|
2019-12-24 11:21:07 -05:00
|
|
|
console.log("Theme was removed");
|
2019-11-11 23:31:37 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-20 17:44:01 -05:00
|
|
|
browser.theme.onUpdated.addListener(handleUpdated);
|