From 6ad83586bf5b4a90889f9d1a4e21b200223562c1 Mon Sep 17 00:00:00 2001 From: KittenTM Date: Sat, 14 Mar 2026 02:59:42 +0100 Subject: [PATCH] work: remove apibase from /x tab/x tab.js --- equipment/equipment.js | 93 ++++++++++++++++++------------------- equipment/index.html | 1 - friend_list/friendlist.js | 73 ++++++++++++++--------------- friend_list/index.html | 1 - ranking/index.html | 1 - ranking/rank.js | 97 +++++++++++++++++++-------------------- stages/index.html | 1 - stages/stages.js | 93 ++++++++++++++++++------------------- 8 files changed, 172 insertions(+), 188 deletions(-) diff --git a/equipment/equipment.js b/equipment/equipment.js index 8358ab7..420803a 100644 --- a/equipment/equipment.js +++ b/equipment/equipment.js @@ -1,55 +1,52 @@ window.loadHeader(function(headerContainer) { - if (typeof CONFIG !== 'undefined') { - const apiBase = CONFIG.API_BASE_URL.replace(/\/$/, ""); - const logoutForm = document.getElementById("logout-form"); + const logoutForm = document.getElementById("logout-form"); + + if (logoutForm) { + logoutForm.action = "/api/v1/spfn/logout"; + const originInput = document.getElementById("logout_frontend_origin"); + if (originInput) originInput.value = window.location.origin; - if (logoutForm) { - logoutForm.action = apiBase + "/api/v1/spfn/logout"; - const originInput = document.getElementById("logout_frontend_origin"); - if (originInput) originInput.value = window.location.origin; - - logoutForm.addEventListener('submit', () => { - sessionStorage.removeItem('user_cache'); - }); - } - - const renderData = (data) => { - if (typeof data === 'string') { - try { data = JSON.parse(data); } - catch (e) { console.error(e); } - } - const nameEl = document.getElementById('mii-name'); - const imgEl = document.getElementById('mii-img'); - if (nameEl) { - nameEl.textContent = (data.mii && data.mii.name) || data.nickname || data.user_id || data.username || "User"; - } - if (imgEl) { - const miiBlob = (data.mii && data.mii.data) || data.mii_data; - if (miiBlob) { - imgEl.src = `https://mii-unsecure.ariankordi.net/miis/image.png?erri=s6u7r-rsp&data=${encodeURIComponent(miiBlob)}&type=face&width=270`; - imgEl.style.display = 'block'; - } - } - }; - - const cached = sessionStorage.getItem('user_cache'); - if (cached) renderData(JSON.parse(cached)); - - fetch(apiBase + "/api/v1/me", { credentials: 'include' }) - .then(res => res.ok ? res.json() : Promise.reject(res)) - .then(data => { - sessionStorage.setItem('user_cache', JSON.stringify(data)); - renderData(data); - }) - .catch(err => { - if (!cached) { - const nameEl = document.getElementById('mii-name'); - if (nameEl) nameEl.textContent = "Guest"; - } - console.error(err); - }); + logoutForm.addEventListener('submit', () => { + sessionStorage.removeItem('user_cache'); + }); } + const renderData = (data) => { + if (typeof data === 'string') { + try { data = JSON.parse(data); } + catch (e) { console.error(e); } + } + const nameEl = document.getElementById('mii-name'); + const imgEl = document.getElementById('mii-img'); + if (nameEl) { + nameEl.textContent = (data.mii && data.mii.name) || data.nickname || data.user_id || data.username || "User"; + } + if (imgEl) { + const miiBlob = (data.mii && data.mii.data) || data.mii_data; + if (miiBlob) { + imgEl.src = `https://mii-unsecure.ariankordi.net/miis/image.png?erri=s6u7r-rsp&data=${encodeURIComponent(miiBlob)}&type=face&width=270`; + imgEl.style.display = 'block'; + } + } + }; + + const cached = sessionStorage.getItem('user_cache'); + if (cached) renderData(JSON.parse(cached)); + + fetch("/api/v1/me", { credentials: 'include' }) + .then(res => res.ok ? res.json() : Promise.reject(res)) + .then(data => { + sessionStorage.setItem('user_cache', JSON.stringify(data)); + renderData(data); + }) + .catch(err => { + if (!cached) { + const nameEl = document.getElementById('mii-name'); + if (nameEl) nameEl.textContent = "Guest"; + } + console.error(err); + }); + const equipButton = headerContainer.querySelector('.menu-item.equipment'); if (equipButton) { equipButton.classList.add('active'); diff --git a/equipment/index.html b/equipment/index.html index 3d1c13f..5a638b1 100644 --- a/equipment/index.html +++ b/equipment/index.html @@ -7,7 +7,6 @@ -
diff --git a/friend_list/friendlist.js b/friend_list/friendlist.js index d7fb3d9..d7c6e2f 100644 --- a/friend_list/friendlist.js +++ b/friend_list/friendlist.js @@ -4,47 +4,44 @@ window.loadHeader(function(headerContainer) { friendButton.classList.add('active'); } - if (typeof CONFIG !== 'undefined') { - const apiBase = CONFIG.API_BASE_URL.replace(/\/$/, ""); - const logoutForm = document.getElementById("logout-form"); + const logoutForm = document.getElementById("logout-form"); + + if (logoutForm) { + logoutForm.action = "/api/v1/spfn/logout"; + const originInput = document.getElementById("logout_frontend_origin"); + if (originInput) originInput.value = window.location.origin; - if (logoutForm) { - logoutForm.action = apiBase + "/api/v1/spfn/logout"; - const originInput = document.getElementById("logout_frontend_origin"); - if (originInput) originInput.value = window.location.origin; - - logoutForm.addEventListener('submit', () => { - sessionStorage.removeItem('user_cache'); - }); - } - - const renderData = (data) => { - if (typeof data === 'string') { - try { data = JSON.parse(data); } catch (e) {} - } - const nameEl = document.getElementById('mii-name'); - const imgEl = document.getElementById('mii-img'); - if (nameEl) nameEl.textContent = data.nickname || data.mii.name || "User"; - if (imgEl && (data.mii && data.mii.data)) { - imgEl.src = `https://mii-unsecure.ariankordi.net/miis/image.png?erri=s6u7r-rsp&data=${encodeURIComponent(data.mii.data)}&type=face&width=270`; - imgEl.style.display = 'block'; - } - }; - - const cached = sessionStorage.getItem('user_cache'); - if (cached) renderData(JSON.parse(cached)); - - fetch(apiBase + "/api/v1/me", { credentials: 'include' }) - .then(res => res.ok ? res.json() : Promise.reject(res)) - .then(data => { - sessionStorage.setItem('user_cache', JSON.stringify(data)); - renderData(data); - }) - .catch(() => { - if (!cached) document.getElementById('mii-name').textContent = "Guest"; - }); + logoutForm.addEventListener('submit', () => { + sessionStorage.removeItem('user_cache'); + }); } + const renderData = (data) => { + if (typeof data === 'string') { + try { data = JSON.parse(data); } catch (e) {} + } + const nameEl = document.getElementById('mii-name'); + const imgEl = document.getElementById('mii-img'); + if (nameEl) nameEl.textContent = data.nickname || data.mii.name || "User"; + if (imgEl && (data.mii && data.mii.data)) { + imgEl.src = `https://mii-unsecure.ariankordi.net/miis/image.png?erri=s6u7r-rsp&data=${encodeURIComponent(data.mii.data)}&type=face&width=270`; + imgEl.style.display = 'block'; + } + }; + + const cached = sessionStorage.getItem('user_cache'); + if (cached) renderData(JSON.parse(cached)); + + fetch("/api/v1/me", { credentials: 'include' }) + .then(res => res.ok ? res.json() : Promise.reject(res)) + .then(data => { + sessionStorage.setItem('user_cache', JSON.stringify(data)); + renderData(data); + }) + .catch(() => { + if (!cached) document.getElementById('mii-name').textContent = "Guest"; + }); + const loadingOverlay = document.getElementById("loading-overlay"); if (loadingOverlay) loadingOverlay.style.display = "none"; }); diff --git a/friend_list/index.html b/friend_list/index.html index 34c5c5b..4bed9cd 100644 --- a/friend_list/index.html +++ b/friend_list/index.html @@ -6,7 +6,6 @@ -
diff --git a/ranking/index.html b/ranking/index.html index 14682c8..0fc660e 100644 --- a/ranking/index.html +++ b/ranking/index.html @@ -6,7 +6,6 @@ -
diff --git a/ranking/rank.js b/ranking/rank.js index d59c067..e9a3fa6 100644 --- a/ranking/rank.js +++ b/ranking/rank.js @@ -4,59 +4,56 @@ window.loadHeader(function(headerContainer) { rankButton.classList.add('active'); } - if (typeof CONFIG !== 'undefined') { - const apiBase = CONFIG.API_BASE_URL.replace(/\/$/, ""); - const logoutForm = document.getElementById("logout-form"); + const logoutForm = document.getElementById("logout-form"); + + if (logoutForm) { + logoutForm.action = "/api/v1/spfn/logout"; + const originInput = document.getElementById("logout_frontend_origin"); + if (originInput) originInput.value = window.location.origin; - if (logoutForm) { - logoutForm.action = apiBase + "/api/v1/spfn/logout"; - const originInput = document.getElementById("logout_frontend_origin"); - if (originInput) originInput.value = window.location.origin; - - logoutForm.addEventListener('submit', () => { - sessionStorage.removeItem('user_cache'); - }); - } - - const renderData = (data) => { - if (typeof data === 'string') { - try { data = JSON.parse(data); } catch (e) { console.error(e); } - } - - const nameEl = document.getElementById('mii-name'); - const imgEl = document.getElementById('mii-img'); - - if (nameEl) { - nameEl.textContent = (data.mii && data.mii.name) || data.nickname || data.user_id || data.username || "User"; - } - - if (imgEl) { - const miiBlob = (data.mii && data.mii.data) || data.mii_data; - if (miiBlob) { - imgEl.src = `https://mii-unsecure.ariankordi.net/miis/image.png?erri=s6u7r-rsp&data=${encodeURIComponent(miiBlob)}&type=face&width=270`; - imgEl.style.display = 'block'; - } - } - }; - - const cached = sessionStorage.getItem('user_cache'); - if (cached) renderData(JSON.parse(cached)); - - fetch(apiBase + "/api/v1/me", { credentials: 'include' }) - .then(res => res.ok ? res.json() : Promise.reject(res)) - .then(data => { - sessionStorage.setItem('user_cache', JSON.stringify(data)); - renderData(data); - }) - .catch(err => { - if (!cached) { - const nameEl = document.getElementById('mii-name'); - if (nameEl) nameEl.textContent = "Guest"; - } - console.error("Profile fetch failed:", err); - }); + logoutForm.addEventListener('submit', () => { + sessionStorage.removeItem('user_cache'); + }); } + const renderData = (data) => { + if (typeof data === 'string') { + try { data = JSON.parse(data); } catch (e) { console.error(e); } + } + + const nameEl = document.getElementById('mii-name'); + const imgEl = document.getElementById('mii-img'); + + if (nameEl) { + nameEl.textContent = (data.mii && data.mii.name) || data.nickname || data.user_id || data.username || "User"; + } + + if (imgEl) { + const miiBlob = (data.mii && data.mii.data) || data.mii_data; + if (miiBlob) { + imgEl.src = `https://mii-unsecure.ariankordi.net/miis/image.png?erri=s6u7r-rsp&data=${encodeURIComponent(miiBlob)}&type=face&width=270`; + imgEl.style.display = 'block'; + } + } + }; + + const cached = sessionStorage.getItem('user_cache'); + if (cached) renderData(JSON.parse(cached)); + + fetch("/api/v1/me", { credentials: 'include' }) + .then(res => res.ok ? res.json() : Promise.reject(res)) + .then(data => { + sessionStorage.setItem('user_cache', JSON.stringify(data)); + renderData(data); + }) + .catch(err => { + if (!cached) { + const nameEl = document.getElementById('mii-name'); + if (nameEl) nameEl.textContent = "Guest"; + } + console.error("Profile fetch failed:", err); + }); + const urlParams = new URLSearchParams(window.location.search); const mode = urlParams.get('mode'); const images = { diff --git a/stages/index.html b/stages/index.html index b980f94..ed11c32 100644 --- a/stages/index.html +++ b/stages/index.html @@ -6,7 +6,6 @@ - diff --git a/stages/stages.js b/stages/stages.js index 31ad93a..308434c 100644 --- a/stages/stages.js +++ b/stages/stages.js @@ -9,60 +9,57 @@ window.loadHeader(function(headerContainer) { stageButton.classList.add('active'); } - if (typeof CONFIG !== 'undefined') { - const apiBase = CONFIG.API_BASE_URL.replace(/\/$/, ""); - const logoutForm = document.getElementById("logout-form"); + const logoutForm = document.getElementById("logout-form"); + + if (logoutForm) { + logoutForm.action = "/api/v1/spfn/logout"; + const originInput = document.getElementById("logout_frontend_origin"); + if (originInput) originInput.value = window.location.origin; - if (logoutForm) { - logoutForm.action = apiBase + "/api/v1/spfn/logout"; - const originInput = document.getElementById("logout_frontend_origin"); - if (originInput) originInput.value = window.location.origin; - - logoutForm.addEventListener('submit', () => { - sessionStorage.removeItem('user_cache'); - }); - } - - const renderData = (data) => { - if (typeof data === 'string') { - try { data = JSON.parse(data); } catch (e) { console.error(e); } - } - const nameEl = document.getElementById('mii-name'); - const imgEl = document.getElementById('mii-img'); - if (nameEl) { - nameEl.textContent = (data.mii && data.mii.name) || data.nickname || data.user_id || data.username || "User"; - } - if (imgEl) { - const miiBlob = (data.mii && data.mii.data) || data.mii_data; - if (miiBlob) { - imgEl.src = `https://mii-unsecure.ariankordi.net/miis/image.png?erri=s6u7r-rsp&data=${encodeURIComponent(miiBlob)}&type=face&width=270`; - imgEl.style.display = 'block'; - } - } - }; - - const cached = sessionStorage.getItem('user_cache'); - if (cached) renderData(JSON.parse(cached)); - - fetch(apiBase + "/api/v1/me", { credentials: 'include' }) - .then(res => res.ok ? res.json() : Promise.reject(res)) - .then(data => { - sessionStorage.setItem('user_cache', JSON.stringify(data)); - renderData(data); - }) - .catch(err => { - if (!cached) { - const nameEl = document.getElementById('mii-name'); - if (nameEl) nameEl.textContent = "Guest"; - } - console.error(err); - }); + logoutForm.addEventListener('submit', () => { + sessionStorage.removeItem('user_cache'); + }); } + const renderData = (data) => { + if (typeof data === 'string') { + try { data = JSON.parse(data); } catch (e) { console.error(e); } + } + const nameEl = document.getElementById('mii-name'); + const imgEl = document.getElementById('mii-img'); + if (nameEl) { + nameEl.textContent = (data.mii && data.mii.name) || data.nickname || data.user_id || data.username || "User"; + } + if (imgEl) { + const miiBlob = (data.mii && data.mii.data) || data.mii_data; + if (miiBlob) { + imgEl.src = `https://mii-unsecure.ariankordi.net/miis/image.png?erri=s6u7r-rsp&data=${encodeURIComponent(miiBlob)}&type=face&width=270`; + imgEl.style.display = 'block'; + } + } + }; + + const cached = sessionStorage.getItem('user_cache'); + if (cached) renderData(JSON.parse(cached)); + + fetch("/api/v1/me", { credentials: 'include' }) + .then(res => res.ok ? res.json() : Promise.reject(res)) + .then(data => { + sessionStorage.setItem('user_cache', JSON.stringify(data)); + renderData(data); + }) + .catch(err => { + if (!cached) { + const nameEl = document.getElementById('mii-name'); + if (nameEl) nameEl.textContent = "Guest"; + } + console.error(err); + }); + renderStages(); }); -const API_URL = `${CONFIG.API_BASE_URL}/api/v1/boss`; +const API_URL = "/api/v1/boss"; function stageNames(stages, lang = "en-US") { return stages.map(s => s.translatedNames[lang]);