2020-01-03 18:09:16 -05:00
|
|
|
function contentUpdateById(id, message) {
|
2022-10-16 16:08:01 -04:00
|
|
|
let infoTitle = document.getElementById(id);
|
|
|
|
let messageContent = chrome.i18n.getMessage(message);
|
|
|
|
if (infoTitle === null) {
|
2022-10-24 19:57:51 -04:00
|
|
|
console.log("content error", id, messageContent);
|
2022-10-16 16:08:01 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
infoTitle.textContent = messageContent;
|
2020-01-03 18:09:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Information Section
|
2022-10-24 19:57:51 -04:00
|
|
|
contentUpdateById("text-section-header", "extensionName");
|
|
|
|
contentUpdateById("description", "extensionDescription");
|
|
|
|
contentUpdateById("i2pbrowser-version", browser.runtime.getManifest().version);
|
2020-01-03 18:09:16 -05:00
|
|
|
|
|
|
|
// Control Section
|
2022-10-24 19:57:51 -04:00
|
|
|
contentUpdateById("controlHeader", "controlHeader");
|
|
|
|
contentUpdateById("controlExplain", "controlExplain");
|
|
|
|
contentUpdateById("clear-browser-data", "clearData");
|
|
|
|
contentUpdateById("clear-desc", "clearDesc");
|
|
|
|
contentUpdateById("enable-web-rtc", "enableWebRTC");
|
|
|
|
contentUpdateById("rtcDesc", "rtcDesc");
|
|
|
|
contentUpdateById("disable-history", "disableHistory");
|
|
|
|
contentUpdateById("histDesc", "histDesc");
|
2020-01-03 18:09:16 -05:00
|
|
|
|
|
|
|
// Application Section
|
2022-10-24 19:57:51 -04:00
|
|
|
contentUpdateById("applicationHeader", "applicationHeader");
|
|
|
|
contentUpdateById("applicationExplain", "applicationExplain");
|
|
|
|
contentUpdateById("window-visit-index", "windowVisitHelppage");
|
|
|
|
contentUpdateById("help", "help");
|
|
|
|
contentUpdateById("window-visit-router", "windowVisitConsole");
|
|
|
|
contentUpdateById("routerConsole", "routerConsole");
|
|
|
|
contentUpdateById("window-visit-homepage", "extensionName");
|
|
|
|
contentUpdateById("abouthome", "abouthome");
|
|
|
|
contentUpdateById("window-visit-i2ptunnel", "windowVisitI2ptunnel");
|
|
|
|
contentUpdateById("i2ptunnel", "i2ptunnel");
|
|
|
|
contentUpdateById("window-visit-susimail", "windowVisitSusiMail");
|
|
|
|
contentUpdateById("susimail", "susimail");
|
|
|
|
contentUpdateById("window-visit-snark", "windowVisitSnark");
|
|
|
|
contentUpdateById("snark", "snark");
|
2020-01-03 18:09:16 -05:00
|
|
|
|
2020-01-04 11:47:25 -05:00
|
|
|
// Homepage Section
|
2022-10-24 19:57:51 -04:00
|
|
|
contentUpdateById("window-visit-webpage", "windowVisitWebPage");
|
|
|
|
contentUpdateById("webpage", "help");
|
|
|
|
contentUpdateById("window-visit-sources", "windowVisitSources");
|
|
|
|
contentUpdateById("sources", "sources");
|
|
|
|
contentUpdateById("window-visit-releases", "windowVisitReleases");
|
|
|
|
contentUpdateById("releases", "releases");
|
2020-01-11 23:14:58 -05:00
|
|
|
|
2021-05-24 13:57:37 -04:00
|
|
|
function hide(elements) {
|
2023-06-20 15:24:37 -04:00
|
|
|
const elems = Array.isArray(elements) ? elements : [elements];
|
|
|
|
for (let i = 0; i < elems.length; i++) {
|
|
|
|
const el = elems[i];
|
|
|
|
if (el.style) {
|
|
|
|
console.log("(content) hiding");
|
|
|
|
el.classList.add("hidden");
|
2022-09-27 18:39:05 -04:00
|
|
|
}
|
2022-10-16 16:08:01 -04:00
|
|
|
}
|
2021-05-24 13:57:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function unhide(elements) {
|
2023-06-20 15:24:37 -04:00
|
|
|
const elems = Array.isArray(elements) ? elements : [elements];
|
|
|
|
elems.forEach(el => {
|
|
|
|
if (el.style) {
|
|
|
|
//el.style.display = "inline-block";
|
|
|
|
console.log("(content) unhiding");
|
|
|
|
el.classList.remove("hidden");
|
2022-09-27 18:39:05 -04:00
|
|
|
}
|
2023-06-20 15:24:37 -04:00
|
|
|
});
|
2021-05-24 13:57:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//TODO: Don't hard-code this.
|
|
|
|
fetch("http://127.0.0.1:7657/themes/console/light/images/i2plogo.png")
|
2022-10-16 16:08:01 -04:00
|
|
|
.then((myJson) => {
|
|
|
|
var consoleLinks = document.querySelectorAll(".application-info");
|
|
|
|
unhide(consoleLinks);
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
var consoleLinks = document.querySelectorAll(".application-info");
|
|
|
|
hide(consoleLinks);
|
|
|
|
});
|
2021-05-26 15:11:46 -04:00
|
|
|
|
|
|
|
fetch("http://127.0.0.1:7657/jsonrpc/")
|
2022-10-16 16:08:01 -04:00
|
|
|
.then((myJson) => {
|
|
|
|
var toopieLinks = document.querySelectorAll(".window-visit-toopie");
|
|
|
|
unhide(toopieLinks);
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
var toopieLinks = document.querySelectorAll(".window-visit-toopie");
|
|
|
|
hide(toopieLinks);
|
|
|
|
});
|