Files
I2P_in_Private_Browsing_Mod…/background.js

84 lines
1.8 KiB
JavaScript
Raw Normal View History

2019-06-17 19:17:11 -04:00
2019-06-19 10:44:03 -04:00
function getChrome() {
2019-06-29 00:49:59 -04:00
if (browser.runtime.getBrowserInfo == undefined) {
return true
2019-06-19 10:44:03 -04:00
}
2019-06-29 00:49:59 -04:00
return false
2019-06-19 10:44:03 -04:00
}
2019-06-17 19:17:11 -04:00
function isDroid() {
if (!getChrome()) {
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then((got) => {
if (got.os == "android") {
console.log("android detected")
return true
} else {
console.log("desktop detected")
return false
}
});
}
return false
2019-06-17 19:17:11 -04:00
}
if (!isDroid()) {
chrome.windows.onCreated.addListener(themeWindow);
2019-06-17 19:17:11 -04:00
}
2019-02-05 10:53:26 -05:00
2019-03-15 21:45:59 -04:00
var titlepref = chrome.i18n.getMessage("titlePreface");
var titleprefpriv = chrome.i18n.getMessage("titlePrefacePrivate");
2019-02-05 10:53:26 -05:00
function themeWindow(window) {
// Check if the window is in private browsing
if (window.incognito) {
chrome.theme.update(window.id, {
colors: {
frame: "#2D4470",
toolbar: "#2D4470",
}
});
chrome.windows.update(window.id, {
titlePreface: titleprefpriv
});
} else {
chrome.theme.update(window.id, {
colors: {
frame: "#9DABD5",
toolbar: "#9DABD5",
}
});
chrome.windows.update(window.id, {
titlePreface: titlepref
});
}
2019-02-05 10:53:26 -05:00
}
2019-02-07 20:14:57 -05:00
function setTitle(window) {
if (window.incognito) {
chrome.windows.update(window.id, {
titlePreface: titleprefpriv
});
} else {
chrome.windows.update(window.id, {
titlePreface: titlepref
});
}
}
2019-02-07 20:14:57 -05:00
function setTitleError(window) {
alert("plugin error setting title on", window.id)
}
2019-02-07 20:14:57 -05:00
2019-03-15 21:45:59 -04:00
chrome.windows.onCreated.addListener(() => {
const gettingStoredSettings = chrome.storage.local.get();
gettingStoredSettings.then(setupProxy, onError);
2019-02-07 20:14:57 -05:00
});
2019-03-15 21:45:59 -04:00
chrome.tabs.onCreated.addListener(() => {
const getting = browser.windows.getCurrent({
populate: true
});
getting.then(setTitle, setTitleError);
});