|
1 | 1 | ; (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 | + |
2 | 15 | // CONFIGURATION CONSTANTS |
3 | 16 | const CONFIG = { |
4 | 17 | COOLDOWN_DEFAULT: 31000, |
@@ -283,8 +296,7 @@ function applyTheme() { |
283 | 296 | return loadedTranslations[language]; |
284 | 297 | } |
285 | 298 |
|
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`; |
288 | 300 | const maxRetries = 3; |
289 | 301 | const baseDelay = 1000; // 1 second |
290 | 302 |
|
@@ -2729,10 +2741,20 @@ function applyTheme() { |
2729 | 2741 | // Link external CSS files |
2730 | 2742 | const cssLink = document.createElement('link'); |
2731 | 2743 | 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`; |
2733 | 2745 | cssLink.setAttribute('data-wplace-theme', 'true'); |
2734 | 2746 | document.head.appendChild(cssLink); |
2735 | 2747 |
|
| 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 | + |
2736 | 2758 | const container = document.createElement("div") |
2737 | 2759 | container.id = "wplace-image-bot-container" |
2738 | 2760 | container.innerHTML = ` |
|
0 commit comments