Skip to content

Commit 939098f

Browse files
Merge pull request #98 from Staninna/hotfix/update-urls
update urls && localStorage base url for extern files
2 parents 4ae1804 + fdf3349 commit 939098f

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

Auto-Image.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
; (async () => {
2+
// Base URL configuration - checks localStorage first, falls back to GitHub
3+
const getBaseUrl = () => {
4+
try {
5+
const customBaseUrl = localStorage.getItem('wplace-bot-base-url');
6+
if (customBaseUrl) {
7+
return customBaseUrl.endsWith('/') ? customBaseUrl.slice(0, -1) : customBaseUrl;
8+
}
9+
} catch (e) {
10+
console.warn('Could not access localStorage for base URL:', e);
11+
}
12+
return 'https://raw.githubusercontent.com/Wplace-AutoBot/WPlace-AutoBOT/main';
13+
};
14+
215
// CONFIGURATION CONSTANTS
316
const CONFIG = {
417
COOLDOWN_DEFAULT: 31000,
@@ -283,8 +296,7 @@ function applyTheme() {
283296
return loadedTranslations[language];
284297
}
285298

286-
// Load translations from CDN
287-
const url = `https://staninna.github.io/WPlace-AutoBOT/decoupled-translations/lang/${language}.json`;
299+
const url = `${getBaseUrl()}/lang/${language}.json`;
288300
const maxRetries = 3;
289301
const baseDelay = 1000; // 1 second
290302

@@ -2729,10 +2741,20 @@ function applyTheme() {
27292741
// Link external CSS files
27302742
const cssLink = document.createElement('link');
27312743
cssLink.rel = 'stylesheet';
2732-
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
2744+
cssLink.href = `${getBaseUrl()}/auto-image-styles.css`;
27332745
cssLink.setAttribute('data-wplace-theme', 'true');
27342746
document.head.appendChild(cssLink);
27352747

2748+
// Dynamically load theme CSS files using base URL
2749+
const themeFiles = ['classic.css', 'classic-light.css', 'neon.css'];
2750+
themeFiles.forEach(themeFile => {
2751+
const themeLink = document.createElement('link');
2752+
themeLink.rel = 'stylesheet';
2753+
themeLink.href = `${getBaseUrl()}/themes/${themeFile}`;
2754+
themeLink.setAttribute('data-wplace-theme-file', themeFile);
2755+
document.head.appendChild(themeLink);
2756+
});
2757+
27362758
const container = document.createElement("div")
27372759
container.id = "wplace-image-bot-container"
27382760
container.innerHTML = `

auto-image-styles.css

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
/* Theme tokens (CSS vars) */
88
/* ========================= */
99

10-
/* Import theme files - classic is default */
11-
@import url('https://staninna.github.io/WPlace-AutoBOT/decoupled-css/themes/classic.css');
12-
@import url('https://staninna.github.io/WPlace-AutoBOT/decoupled-css/themes/classic-light.css');
13-
@import url('https://staninna.github.io/WPlace-AutoBOT/decoupled-css/themes/neon.css');
10+
/* Theme files are now loaded dynamically via JavaScript using the base URL from localStorage */
11+
/* See Auto-Image.js lines 2749-2757 for dynamic theme loading implementation */
1412

1513
/* Default :root CSS variables for 100% classic theme compliance */
1614
/* These ensure the bot works perfectly even if theme files fail to load */

0 commit comments

Comments
 (0)