start a contextual identity aware branch
This commit is contained in:
119
background.js
119
background.js
@@ -1,4 +1,31 @@
|
||||
|
||||
function onGot(contexts) {
|
||||
var ids = []
|
||||
console.log("CONTEXT")
|
||||
for (let context of contexts) {
|
||||
console.log(`Name: ${context.name}`);
|
||||
ids.push(context.name)
|
||||
}
|
||||
if (ids.indexOf("i2pbrowser") == -1) {
|
||||
function onCreated(context) {
|
||||
console.log(`New identity's ID: ${context.cookieStoreId}.`);
|
||||
}
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
}
|
||||
browser.contextualIdentities.create({
|
||||
name: "i2pbrowser",
|
||||
color: "purple",
|
||||
icon: "fingerprint"
|
||||
}).then(onCreated, onError);
|
||||
}
|
||||
}
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
}
|
||||
browser.contextualIdentities.query({}).then(onGot, onError);
|
||||
|
||||
|
||||
function getChrome() {
|
||||
if (browser.runtime.getBrowserInfo == undefined) {
|
||||
return true
|
||||
@@ -24,6 +51,7 @@ function isDroid() {
|
||||
|
||||
if (!isDroid()) {
|
||||
chrome.windows.onCreated.addListener(themeWindow);
|
||||
chrome.tabs.onActivated.addListener(themeWindow);
|
||||
}
|
||||
|
||||
var titlepref = chrome.i18n.getMessage("titlePreface");
|
||||
@@ -31,39 +59,78 @@ 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, {
|
||||
colors: {
|
||||
frame: "#2D4470",
|
||||
toolbar: "#2D4470",
|
||||
function logTabs(tabInfo) {
|
||||
console.log(tabInfo)
|
||||
if (tabInfo[0].cookieStoreId == "i2pbrowser") {
|
||||
console.log("Active in I2P window")
|
||||
if (window.incognito) {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#2D4470",
|
||||
toolbar: "#2D4470",
|
||||
}
|
||||
});
|
||||
} else {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#9DABD5",
|
||||
toolbar: "#9DABD5",
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv
|
||||
});
|
||||
} else {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#9DABD5",
|
||||
toolbar: "#9DABD5",
|
||||
}else{
|
||||
console.log("Not active in I2P window")
|
||||
if (window.incognito) {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: undefined,
|
||||
toolbar: undefined,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: undefined,
|
||||
toolbar: undefined,
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titlepref
|
||||
});
|
||||
}
|
||||
}
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
var querying = browser.tabs.query({
|
||||
currentWindow: true,
|
||||
active: true
|
||||
});
|
||||
querying.then(logTabs, onError);
|
||||
}
|
||||
|
||||
function setTitle(window) {
|
||||
if (window.incognito) {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv
|
||||
});
|
||||
} else {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titlepref
|
||||
});
|
||||
function logTabs(tabInfo) {
|
||||
console.log(tabInfo)
|
||||
if (tabInfo[0].cookieStoreId == "firefox-container-1") {
|
||||
console.log("Active in I2P window")
|
||||
if (window.incognito) {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv
|
||||
});
|
||||
} else {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titlepref
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
var querying = browser.tabs.query({
|
||||
currentWindow: true,
|
||||
active: true
|
||||
});
|
||||
querying.then(logTabs, onError);
|
||||
}
|
||||
|
||||
function setTitleError(window) {
|
||||
|
@@ -15,3 +15,4 @@ newsMessage.textContent = chrome.i18n.getMessage("newsMessage");
|
||||
|
||||
var clearData = document.getElementById("clear-browser-data")
|
||||
clearData.textContent = chrome.i18n.getMessage("clearData");
|
||||
|
||||
|
6
info.css
6
info.css
@@ -10,3 +10,9 @@ a {
|
||||
.panel {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
span.identity {
|
||||
width: 100px;
|
||||
display: inline-block;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@
|
||||
"storage",
|
||||
"webRequest",
|
||||
"contextualIdentities",
|
||||
"cookies",
|
||||
"tabs",
|
||||
"<all_urls>"
|
||||
],
|
||||
"manifest_version": 2,
|
||||
|
4
proxy.js
4
proxy.js
@@ -123,8 +123,8 @@ function setupProxy() {
|
||||
var Scheme = getScheme()
|
||||
if (!getChrome()) {
|
||||
function handleProxyRequest(requestInfo) {
|
||||
console.log("proxying request via listener")
|
||||
console.log(" ", Scheme, Host, ":", Port,)
|
||||
// console.log("proxying request via listener")
|
||||
// console.log(" ", Scheme, Host, ":", Port,)
|
||||
return {
|
||||
type: Scheme,
|
||||
host: Host,
|
||||
|
@@ -26,15 +26,21 @@
|
||||
<!-- This is where I'll eventually put the tunnel control panel -->
|
||||
<!-- <a href="#" id="generate-fresh-tunnel> Generate a Fresh Tunnel</a>"-->
|
||||
<!-- -->
|
||||
<strong><a href="#" id="clear-browser-data">Clear all browsing data</a></strong><br>
|
||||
<strong><a href="#" id="clear-browser-data">Clear all browsing data</a></strong><br>
|
||||
<!--<strong><a href="#" id="temp-enable-webrtc">Temporarily enable WebRTC</a></strong><br>-->
|
||||
<div class="panel-section-separator"></div>
|
||||
<a href="http://i2pforum.i2p" id="window-create-forum-panel">Visit the I2P Forums</a><br>
|
||||
<a href="http://i2p-projekt.i2p/blog" id="window-create-news-panel">Get the latest I2P News</a><br>
|
||||
<div class="panel-section-separator"></div>
|
||||
|
||||
<div class="panel-section-identity">
|
||||
<div id="identity-list"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<script src="context.js"></script>
|
||||
<script src="privacy.js"></script>
|
||||
<script src="info.js"></script>
|
||||
<script src="content.js"></script>
|
||||
|
Reference in New Issue
Block a user