This commit is contained in:
4DBug
2026-08-26 13:22:49 -05:00
commit 53b3c1da6c
96 changed files with 6210 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
/*
CONFIG — where the API lives. Resolution order:
1. ?api=<url> query param on any page (session override)
2. localStorage (saved from the Settings dialog)
3. built-in default
*/
(function () {
'use strict';
const DEFAULT_BASE = 'https://bug-api-test.tuns.sh';
const STORAGE_KEY = 'streamreverse.apiBase.v1';
function normalize(value) {
let v = String(value || '').trim();
if (!v) return '';
if (!/^https?:\/\//i.test(v)) v = `https://${v}`;
return v.replace(/\/+$/, '');
}
function getBase() {
const fromQuery = SR.util.getParam('api');
if (fromQuery) return normalize(fromQuery);
try {
const stored = localStorage.getItem(STORAGE_KEY);
if (stored) return normalize(stored);
} catch (e) {
/* private mode etc. */
}
return DEFAULT_BASE;
}
function setBase(value) {
const v = normalize(value);
try {
localStorage.setItem(STORAGE_KEY, v);
} catch (e) {
/* ignore */
}
return v;
}
function clearBase() {
try {
localStorage.removeItem(STORAGE_KEY);
} catch (e) {
/* ignore */
}
}
window.SR = window.SR || {};
SR.config = { DEFAULT_BASE, STORAGE_KEY, getBase, setBase, clearBase };
})();