This commit is contained in:
ItsVipra 2023-05-28 12:23:50 +02:00
commit 74daa5d94a

View file

@ -14,24 +14,29 @@ const host_name = location.host;
checkSite();
let logging;
function error() {
if (logging) console.error(arguments);
/** @param {any[]} arguments */
function error(...arguments) {
if (logging) console.error(...arguments);
}
function warn() {
if (logging) console.warn(arguments);
/** @param {any[]} arguments */
function warn(...arguments) {
if (logging) console.warn(...arguments);
}
function log() {
if (logging) console.log(arguments);
/** @param {any[]} arguments */
function log(...arguments) {
if (logging) console.log(...arguments);
}
function info() {
if (logging) console.info(arguments);
/** @param {any[]} arguments */
function info(...arguments) {
if (logging) console.info(...arguments);
}
function debug() {
if (logging) console.debug(arguments);
/** @param {any[]} arguments */
function debug(...arguments) {
if (logging) console.debug(...arguments);
}
// log("hey vippy, du bist cute <3")
@ -41,14 +46,14 @@ function debug() {
* If so creates an 'readystatechange' EventListener, with callback to main()
*/
async function checkSite() {
await browser.storage.sync.get("logging").then(
(res) => {
logging = res["logging"];
},
() => {
logging = true;
},
);
try {
let { logging: optionValue } = await browser.storage.sync.get("logging");
logging = optionValue;
} catch {
// Enable the logging automatically if we cannot determine the user preference.
logging = true;
}
let requestDest = location.protocol + "//" + host_name + "/api/v1/instance";
let response = await fetch(requestDest);