Files
I2P_in_Private_Browsing_Mod…/proxyinfo.js

68 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-06-20 13:19:49 -04:00
document.addEventListener("DOMContentLoaded", proxyStatus, false);
function proxyStatus() {
console.log("(proxyinfo) checking proxy status");
fetch("http://proxy.i2p", { cache: "no-store" }).then(
proxyStatusSuccess,
proxyStatusError
);
}
function proxyStatusSuccess(myJson) {
console.warn("(proxyinfo)", myJson);
contentUpdateById("proxy-check", "proxySuccessStatus");
let readyness = document.querySelectorAll(".readyness");
if (readyness !== null) {
unhide(readyness);
}
}
function proxyStatusError(error) {
console.error("(proxyinfo)", error);
contentUpdateById("proxy-check", "proxyFailedStatus");
let readyness = document.querySelectorAll(".readyness");
if (readyness !== null) {
hide(readyness);
}
}
2022-10-07 11:01:16 -04:00
function hide(elements) {
2023-06-20 13:19:49 -04:00
const elems = Array.isArray(elements) ? elements : [elements];
elems.forEach((elem) => {
if (elem.style) {
elem.style.display = "none";
2022-10-07 11:01:16 -04:00
}
2023-06-20 13:19:49 -04:00
});
2022-10-07 11:01:16 -04:00
}
function unhide(elements) {
2023-06-20 13:19:49 -04:00
const elems = Array.isArray(elements) ? elements : [elements];
elems.forEach((elem) => {
if (elem.style) {
elem.style.display = "inline-block";
2022-10-07 11:01:16 -04:00
}
2023-06-20 13:19:49 -04:00
});
2022-10-07 11:01:16 -04:00
}
//TODO: Don't hard-code this.
2023-06-20 13:19:49 -04:00
/*fetch("http://127.0.0.1:7657/themes/console/light/images/i2plogo.png")
2022-10-16 16:50:28 -04:00
.then((myJson) => {
var consoleLinks = document.querySelectorAll(".application-info");
unhide(consoleLinks);
})
.catch((error) => {
var consoleLinks = document.querySelectorAll(".application-info");
hide(consoleLinks);
});
2022-10-07 11:01:16 -04:00
fetch("http://127.0.0.1:7657/jsonrpc/")
2022-10-16 16:50:28 -04:00
.then((myJson) => {
var toopieLinks = document.querySelectorAll(".window-visit-toopie");
unhide(toopieLinks);
})
.catch((error) => {
var toopieLinks = document.querySelectorAll(".window-visit-toopie");
hide(toopieLinks);
});
2023-06-20 13:19:49 -04:00
*/