Files
I2P_in_Private_Browsing_Mod…/background.js
2019-03-15 21:45:59 -04:00

72 lines
1.9 KiB
JavaScript

chrome.windows.onCreated.addListener(themeWindow);
// Theme all currently open windows
//browser.windows.getAll().then(wins => wins.forEach(themeWindow));
var titlepref = chrome.i18n.getMessage("titlePreface");
var titleprefpriv = chrome.i18n.getMessage("titlePrefacePrivate");
function themeWindow(window) {
// Check if the window is in private browsing
if (window.incognito) {
chrome.theme.update(window.id, {
images: {
headerURL: "icons/toopie.png",
},
colors: {
accentcolor: "#A0A0DE",
textcolor: "white",
toolbar: "#A0A0DE",
toolbar_text: "white"
}
});
chrome.windows.update(window.id, {
titlePreface: titleprefpriv
});
}
else {
chrome.theme.update(window.id, {
images: {
headerURL: "icons/toopie.png",
},
colors: {
accentcolor: "#BFA0DE",
textcolor: "white",
toolbar: "#BFA0DE",
toolbar_text: "white"
}
});
chrome.windows.update(window.id, {
titlePreface: titlepref
});
}
}
function setTitle(window){
if (window.incognito) {
chrome.windows.update(window.id, {
titlePreface: titleprefpriv
});
}
else {
chrome.windows.update(window.id, {
titlePreface: titlepref
});
}
}
function setTitleError(window){
alert("plugin error setting title on", window.id)
}
chrome.windows.onCreated.addListener(() => {
const gettingStoredSettings = chrome.storage.local.get();
gettingStoredSettings.then(setupProxy, onError);
});
chrome.tabs.onCreated.addListener(() => {
const getting = chrome.windows.getCurrent({populate: true});
getting.then(setTitle, setTitleError);
});