mirror of
https://github.com/tiennm99/WPlace-AutoBOT.git
synced 2026-10-13 08:15:08 +00:00
dynamic base url
This commit is contained in:
1 parent
09272dbde1
commit
bf29dfeb9e
2 files changed
+28
-7
No files matched your search
+26
-3
@@ -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://raw.githubusercontent.com/Wplace-AutoBot/WPlace-AutoBOT/main/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://raw.githubusercontent.com/Wplace-AutoBot/WPlace-AutoBOT/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 = `
|
||||
|
||||
@@ -7,10 +7,8 @@
|
||||
/* Theme tokens (CSS vars) */
|
||||
/* ========================= */
|
||||
|
||||
/* Import theme files - classic is default */
|
||||
@import url('https://raw.githubusercontent.com/Wplace-AutoBot/WPlace-AutoBOT/main/themes/classic.css');
|
||||
@import url('https://raw.githubusercontent.com/Wplace-AutoBot/WPlace-AutoBOT/main/themes/classic-light.css');
|
||||
@import url('https://raw.githubusercontent.com/Wplace-AutoBot/WPlace-AutoBOT/main/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 */
|
||||
|
||||
Reference in new issue
Block a user