2019-11-25 20:19:44 -05:00
|
|
|
function checkPeerConnection() {
|
|
|
|
var getting = browser.privacy.network.peerConnectionEnabled.get({});
|
|
|
|
getting.then(got => {
|
|
|
|
webrtc = got.value;
|
|
|
|
console.log("checking webrtc", webrtc);
|
|
|
|
document.getElementById("enable-web-rtc").checked = webrtc;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
checkPeerConnection();
|
|
|
|
|
|
|
|
function checkHistory() {
|
|
|
|
var getting = browser.storage.local.get("disable_history");
|
|
|
|
getting.then(got => {
|
|
|
|
disable_history = got.disable_history;
|
2019-12-24 11:21:07 -05:00
|
|
|
if (disable_history == undefined) {
|
|
|
|
disable_history = false;
|
|
|
|
}
|
2019-11-25 20:19:44 -05:00
|
|
|
console.log("checking history", disable_history);
|
|
|
|
document.getElementById("disable-history").checked = disable_history;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
checkHistory();
|
|
|
|
|
2019-10-06 15:18:10 -04:00
|
|
|
document.addEventListener("click", e => {
|
2019-10-06 13:38:11 -04:00
|
|
|
if (e.target.id === "window-create-help-panel") {
|
|
|
|
let createData = {
|
|
|
|
type: "panel",
|
2019-10-06 15:18:10 -04:00
|
|
|
incognito: true
|
2019-10-06 13:38:11 -04:00
|
|
|
};
|
2019-11-23 14:24:56 -05:00
|
|
|
let creating = browser.tabs.create(createData);
|
2019-10-06 13:38:11 -04:00
|
|
|
creating.then(() => {
|
|
|
|
console.log("The help panel has been created");
|
|
|
|
});
|
|
|
|
} else if (e.target.id === "window-create-news-panel") {
|
|
|
|
let createData = {
|
|
|
|
type: "panel",
|
2019-10-06 15:18:10 -04:00
|
|
|
incognito: true
|
2019-10-06 13:38:11 -04:00
|
|
|
};
|
2019-11-23 14:24:56 -05:00
|
|
|
let creating = browser.tabs.create(createData);
|
2019-10-06 13:38:11 -04:00
|
|
|
creating.then(() => {
|
|
|
|
console.log("The news panel has been created");
|
|
|
|
});
|
|
|
|
} else if (e.target.id === "generate-fresh-tunnel") {
|
|
|
|
function RefreshIdentity() {
|
2019-10-06 15:18:10 -04:00
|
|
|
console.log("Generating new identity");
|
2019-10-06 13:38:11 -04:00
|
|
|
const Http = new XMLHttpRequest();
|
2019-10-06 15:18:10 -04:00
|
|
|
const url = "http://" + controlHost + ":" + controlPort;
|
2019-10-06 13:38:11 -04:00
|
|
|
Http.open("GET", url);
|
|
|
|
Http.send();
|
2019-10-06 15:18:10 -04:00
|
|
|
Http.onreadystatechange = e => {
|
|
|
|
console.log(Http.responseText);
|
|
|
|
};
|
2019-03-13 19:38:34 -04:00
|
|
|
}
|
2019-10-06 13:38:11 -04:00
|
|
|
RefreshIdentity();
|
|
|
|
} else if (e.target.id === "window-preface-title") {
|
2019-11-22 17:49:27 -05:00
|
|
|
} else if (e.target.id === "window-visit-homepage") {
|
2019-11-22 17:55:58 -05:00
|
|
|
console.log("attempting to create homepage tab");
|
|
|
|
goHome();
|
2019-11-22 17:49:27 -05:00
|
|
|
} else if (e.target.id === "window-visit-i2ptunnel") {
|
2019-11-22 17:55:58 -05:00
|
|
|
console.log("attempting to create i2ptunnel tab");
|
|
|
|
goTunnel();
|
2019-11-22 17:49:27 -05:00
|
|
|
} else if (e.target.id === "window-visit-susimail") {
|
2019-11-22 17:55:58 -05:00
|
|
|
console.log("attempting to create susimail tab");
|
|
|
|
goMail();
|
2019-11-22 17:49:27 -05:00
|
|
|
} else if (e.target.id === "window-visit-snark") {
|
2019-11-22 17:55:58 -05:00
|
|
|
console.log("attempting to create snark tab");
|
|
|
|
goSnark();
|
2019-10-06 13:38:11 -04:00
|
|
|
} else if (e.target.id === "clear-browser-data") {
|
2019-10-06 15:18:10 -04:00
|
|
|
forgetBrowsingData();
|
2019-10-16 15:31:30 -04:00
|
|
|
} else if (e.target.id === "check-i2p-control") {
|
|
|
|
echo("I2P Router Detected", "panel-section-i2pcontrol-check");
|
2019-10-28 01:11:16 -04:00
|
|
|
} else if (e.target.id === "enable-web-rtc") {
|
2019-10-28 01:12:40 -04:00
|
|
|
if (e.target.checked) {
|
2019-12-24 11:21:07 -05:00
|
|
|
browser.runtime.sendMessage({rtc: "enableWebRTC"});
|
2019-10-28 01:12:40 -04:00
|
|
|
} else {
|
2019-12-24 11:21:07 -05:00
|
|
|
browser.runtime.sendMessage({rtc: "disableWebRTC"});
|
2019-10-28 01:11:16 -04:00
|
|
|
}
|
2019-11-25 20:19:44 -05:00
|
|
|
//checkPeerConnection()
|
|
|
|
return;
|
|
|
|
} else if (e.target.id === "disable-history") {
|
|
|
|
if (e.target.checked) {
|
2019-12-24 11:21:07 -05:00
|
|
|
browser.runtime.sendMessage({history: "disableHistory"});
|
2019-11-25 20:19:44 -05:00
|
|
|
} else {
|
2019-12-24 11:21:07 -05:00
|
|
|
browser.runtime.sendMessage({history: "enableHistory"});
|
2019-11-25 20:19:44 -05:00
|
|
|
}
|
|
|
|
//checkHistory()
|
2019-10-28 01:12:40 -04:00
|
|
|
return;
|
2019-10-06 13:38:11 -04:00
|
|
|
}
|
2019-03-13 17:50:51 -04:00
|
|
|
|
2019-10-06 13:38:11 -04:00
|
|
|
e.preventDefault();
|
2019-10-06 15:18:10 -04:00
|
|
|
});
|
2019-11-10 22:24:10 -05:00
|
|
|
|
|
|
|
function proxyReadiness() {
|
|
|
|
console.log(this.responseText);
|
|
|
|
}
|
|
|
|
|
2019-11-26 23:26:33 -05:00
|
|
|
var gettingInfo = browser.runtime.getPlatformInfo();
|
|
|
|
gettingInfo.then(got => {
|
|
|
|
if (got.os != "android") {
|
|
|
|
browser.history.onVisited.addListener(onVisited);
|
|
|
|
}
|
|
|
|
});
|
2019-11-25 20:19:44 -05:00
|
|
|
|
2019-11-22 13:24:19 -05:00
|
|
|
function goHome() {
|
2019-11-23 14:24:56 -05:00
|
|
|
function gotProxyInfo(info) {
|
|
|
|
let host = info.value.http.split(":")[0];
|
|
|
|
let port = info.value.http.split(":")[1];
|
|
|
|
if (port == "7644") {
|
|
|
|
let createData = {
|
|
|
|
url: "about:I2p"
|
|
|
|
};
|
|
|
|
console.log("visiting homepage");
|
|
|
|
let creating = browser.tabs.create(createData);
|
|
|
|
} else {
|
|
|
|
let createData = {
|
|
|
|
url: "home.html"
|
|
|
|
};
|
|
|
|
console.log("visiting homepage");
|
|
|
|
let creating = browser.tabs.create(createData);
|
|
|
|
}
|
|
|
|
console.log("(bookmarks) adding home page bookmark");
|
|
|
|
}
|
|
|
|
console.log("(bookmarks) checking if we're running in an I2P Browser");
|
|
|
|
var gettingInfo = browser.proxy.settings.get({});
|
|
|
|
gettingInfo.then(gotProxyInfo);
|
2019-11-22 17:49:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function goTunnel() {
|
|
|
|
let createData = {
|
2019-11-26 23:06:24 -05:00
|
|
|
url: "http://" + control_host + ":" + control_port + "/i2ptunnel"
|
2019-11-22 17:49:27 -05:00
|
|
|
};
|
|
|
|
console.log("visiting homepage");
|
|
|
|
let creating = browser.tabs.create(createData);
|
|
|
|
}
|
|
|
|
|
|
|
|
function goMail() {
|
|
|
|
let createData = {
|
2019-11-26 23:06:24 -05:00
|
|
|
url: "http://" + control_host + ":" + control_port + "/susimail"
|
2019-11-22 17:49:27 -05:00
|
|
|
};
|
|
|
|
console.log("visiting homepage");
|
|
|
|
let creating = browser.tabs.create(createData);
|
|
|
|
}
|
|
|
|
|
|
|
|
function goSnark() {
|
|
|
|
let createData = {
|
2019-11-26 23:06:24 -05:00
|
|
|
url: "http://" + control_host + ":" + control_port + "/i2psnark"
|
2019-11-22 17:49:27 -05:00
|
|
|
};
|
2019-11-22 13:24:19 -05:00
|
|
|
console.log("visiting homepage");
|
|
|
|
let creating = browser.tabs.create(createData);
|
|
|
|
}
|
2019-11-10 22:24:10 -05:00
|
|
|
|
2019-11-25 20:19:44 -05:00
|
|
|
function onVisited(historyItem) {
|
|
|
|
function onCleaned(results) {
|
|
|
|
if (!results.length) {
|
|
|
|
console.log(" was removed");
|
|
|
|
} else {
|
|
|
|
console.log(" was not removed");
|
|
|
|
}
|
|
|
|
}
|
2019-11-10 22:24:10 -05:00
|
|
|
|
2019-11-25 20:19:44 -05:00
|
|
|
function onRemoved() {
|
|
|
|
var searching = browser.history.search({
|
|
|
|
text: historyItem.url,
|
|
|
|
startTime: 0
|
|
|
|
});
|
|
|
|
searching.then(onCleaned);
|
|
|
|
}
|
|
|
|
if (!history) {
|
2019-12-24 11:21:07 -05:00
|
|
|
if (i2pHost(historyItem.url)) {
|
|
|
|
var deletingUrl = browser.history.deleteUrl(historyItem.url);
|
|
|
|
}
|
2019-11-25 20:19:44 -05:00
|
|
|
deletingUrl.then(onRemoved);
|
|
|
|
}
|
2019-11-10 22:24:10 -05:00
|
|
|
}
|