Files
I2P_in_Private_Browsing_Mod…/content.js

92 lines
3.2 KiB
JavaScript
Raw Normal View History

2020-01-03 18:09:16 -05:00
function contentUpdateById(id, message) {
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);
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
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");
}
}
}
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");
}
2023-06-20 15:24:37 -04:00
});
}
//TODO: Don't hard-code this.
fetch("http://127.0.0.1:7657/themes/console/light/images/i2plogo.png")
.then((myJson) => {
var consoleLinks = document.querySelectorAll(".application-info");
unhide(consoleLinks);
})
.catch((error) => {
var consoleLinks = document.querySelectorAll(".application-info");
hide(consoleLinks);
});
fetch("http://127.0.0.1:7657/jsonrpc/")
.then((myJson) => {
var toopieLinks = document.querySelectorAll(".window-visit-toopie");
unhide(toopieLinks);
})
.catch((error) => {
var toopieLinks = document.querySelectorAll(".window-visit-toopie");
hide(toopieLinks);
});