From ef7431cf463f3fdef1916c481493d4b4c05ba72d Mon Sep 17 00:00:00 2001 From: Staninna <26458805+Staninna@users.noreply.github.com> Date: Sun, 31 Aug 2025 12:18:22 +0200 Subject: [PATCH 1/3] Reapply "Update urls && baseurl in localstorage" This reverts commit f74e54458d7cc1595e3244279683692938b300b2. --- Auto-Image.js | 29 ++++++++++++++++++++++++++--- auto-image-styles.css | 6 ++---- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Auto-Image.js b/Auto-Image.js index 049bad5..0d0b9d6 100644 --- a/Auto-Image.js +++ b/Auto-Image.js @@ -1,4 +1,17 @@ ; (async () => { + // Base URL configuration - checks localStorage first, falls back to GitHub + const getBaseUrl = () => { + try { + const customBaseUrl = localStorage.getItem('wplace-autobot-base-url'); + if (customBaseUrl) { + return customBaseUrl.endsWith('/') ? customBaseUrl.slice(0, -1) : customBaseUrl; + } + } catch (e) { + console.warn('Could not access localStorage for base URL:', e); + } + return 'https://raw.githubusercontent.com/Wplace-AutoBot/WPlace-AutoBOT/main'; + }; + // CONFIGURATION CONSTANTS const CONFIG = { COOLDOWN_DEFAULT: 31000, @@ -283,8 +296,8 @@ function applyTheme() { return loadedTranslations[language]; } - // Load translations from CDN - const url = `https://staninna.github.io/WPlace-AutoBOT/decoupled-translations/lang/${language}.json`; + // Load translations using base URL (checks localStorage, falls back to GitHub) + const url = `${getBaseUrl()}/decoupled-translations/lang/${language}.json`; const maxRetries = 3; const baseDelay = 1000; // 1 second @@ -2729,10 +2742,20 @@ function applyTheme() { // Link external CSS files const cssLink = document.createElement('link'); cssLink.rel = 'stylesheet'; - cssLink.href = 'https://staninna.github.io/WPlace-AutoBOT/decoupled-css/auto-image-styles.css'; // TODO: Before merge change to https://raw.githubusercontent.com/Wplace-AutoBot/WPlace-AutoBOT/refs/heads/main/auto-image-styles.css + cssLink.href = `${getBaseUrl()}/auto-image-styles.css`; cssLink.setAttribute('data-wplace-theme', 'true'); document.head.appendChild(cssLink); + // Dynamically load theme CSS files using base URL + const themeFiles = ['classic.css', 'classic-light.css', 'neon.css']; + themeFiles.forEach(themeFile => { + const themeLink = document.createElement('link'); + themeLink.rel = 'stylesheet'; + themeLink.href = `${getBaseUrl()}/themes/${themeFile}`; + themeLink.setAttribute('data-wplace-theme-file', themeFile); + document.head.appendChild(themeLink); + }); + const container = document.createElement("div") container.id = "wplace-image-bot-container" container.innerHTML = ` diff --git a/auto-image-styles.css b/auto-image-styles.css index e3fecf3..2a44553 100644 --- a/auto-image-styles.css +++ b/auto-image-styles.css @@ -7,10 +7,8 @@ /* Theme tokens (CSS vars) */ /* ========================= */ -/* Import theme files - classic is default */ -@import url('https://staninna.github.io/WPlace-AutoBOT/decoupled-css/themes/classic.css'); -@import url('https://staninna.github.io/WPlace-AutoBOT/decoupled-css/themes/classic-light.css'); -@import url('https://staninna.github.io/WPlace-AutoBOT/decoupled-css/themes/neon.css'); +/* Theme files are now loaded dynamically via JavaScript using the base URL from localStorage */ +/* See Auto-Image.js lines 2749-2757 for dynamic theme loading implementation */ /* Default :root CSS variables for 100% classic theme compliance */ /* These ensure the bot works perfectly even if theme files fail to load */ From e3806b5ce7f757c33ee5bfea7aaf2aa60213ca8a Mon Sep 17 00:00:00 2001 From: Staninna <26458805+Staninna@users.noreply.github.com> Date: Sun, 31 Aug 2025 12:19:42 +0200 Subject: [PATCH 2/3] update path --- Auto-Image.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Auto-Image.js b/Auto-Image.js index 0d0b9d6..3560a3d 100644 --- a/Auto-Image.js +++ b/Auto-Image.js @@ -296,8 +296,7 @@ function applyTheme() { return loadedTranslations[language]; } - // Load translations using base URL (checks localStorage, falls back to GitHub) - const url = `${getBaseUrl()}/decoupled-translations/lang/${language}.json`; + const url = `${getBaseUrl()}/lang/${language}.json`; const maxRetries = 3; const baseDelay = 1000; // 1 second From fdf3349f1a0945090171025d7b4906bdac03a969 Mon Sep 17 00:00:00 2001 From: Staninna <26458805+Staninna@users.noreply.github.com> Date: Sun, 31 Aug 2025 12:25:27 +0200 Subject: [PATCH 3/3] update localstorage key --- Auto-Image.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Auto-Image.js b/Auto-Image.js index 3560a3d..33e794a 100644 --- a/Auto-Image.js +++ b/Auto-Image.js @@ -2,7 +2,7 @@ // Base URL configuration - checks localStorage first, falls back to GitHub const getBaseUrl = () => { try { - const customBaseUrl = localStorage.getItem('wplace-autobot-base-url'); + const customBaseUrl = localStorage.getItem('wplace-bot-base-url'); if (customBaseUrl) { return customBaseUrl.endsWith('/') ? customBaseUrl.slice(0, -1) : customBaseUrl; }