Refactor CSS integration by decoupling styles from JavaScript and adding complete CSS file

This commit is contained in:
Staninna committed 2025-08-25 01:23:43 +02:00
1 parent 8d5bd64988
commit 4667c5b736
2 files changed
+771 -80

No files matched your search

+18 -80
View File
@@ -1700,18 +1700,7 @@
}
this._turnstileContainer = document.createElement('div');
this._turnstileContainer.style.cssText = `
position: fixed !important;
left: -99999px !important;
top: -99999px !important;
width: 1px !important;
height: 1px !important;
pointer-events: none !important;
opacity: 0 !important;
visibility: hidden !important;
z-index: -99999 !important;
overflow: hidden !important;
`;
this._turnstileContainer.className = 'wplace-turnstile-hidden';
this._turnstileContainer.setAttribute('aria-hidden', 'true');
this._turnstileContainer.id = 'turnstile-widget-container';
document.body.appendChild(this._turnstileContainer);
@@ -1727,35 +1716,19 @@
const overlay = document.createElement('div');
overlay.id = 'turnstile-overlay-container';
overlay.style.cssText = `
position: fixed !important;
bottom: 20px !important;
right: 20px !important;
z-index: 99999 !important;
background: rgba(0,0,0,0.9) !important;
border-radius: 12px !important;
padding: 20px !important;
box-shadow: 0 8px 32px rgba(0,0,0,0.4) !important;
backdrop-filter: blur(10px) !important;
border: 1px solid rgba(255,255,255,0.2) !important;
color: white !important;
font-family: 'Segoe UI', sans-serif !important;
display: none !important;
max-width: 350px !important;
min-width: 300px !important;
`;
overlay.className = 'wplace-turnstile-overlay wplace-overlay-hidden';
const title = document.createElement('div');
title.textContent = 'Cloudflare Turnstile — please complete the check if shown';
title.style.cssText = 'font: 600 12px/1.3 "Segoe UI",sans-serif; margin-bottom: 8px; opacity: 0.9;';
title.className = 'wplace-turnstile-title';
const host = document.createElement('div');
host.id = 'turnstile-overlay-host';
host.style.cssText = 'width: 100%; min-height: 70px;';
host.className = 'wplace-turnstile-host';
const hideBtn = document.createElement('button');
hideBtn.textContent = 'Hide';
hideBtn.style.cssText = 'position:absolute; top:6px; right:6px; font-size:11px; background:transparent; color:#fff; border:1px solid rgba(255,255,255,0.2); border-radius:6px; padding:2px 6px; cursor:pointer;';
hideBtn.className = 'wplace-turnstile-hide-btn';
hideBtn.addEventListener('click', () => overlay.remove());
overlay.appendChild(title);
@@ -2084,40 +2057,7 @@
showAlert: (message, type = "info") => {
const alertDiv = document.createElement("div")
alertDiv.style.cssText = `
position: fixed;
top: 20px;
left: 50%;
transform: translateX(-50%);
padding: 12px 20px;
border-radius: 8px;
color: white;
font-weight: 600;
z-index: 10001;
max-width: 400px;
text-align: center;
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
animation: slideDown 0.3s ease-out;
font-family: 'Segoe UI', sans-serif;
`
const colors = {
info: "background: linear-gradient(135deg, #3498db, #2980b9);",
success: "background: linear-gradient(135deg, #27ae60, #229954);",
warning: "background: linear-gradient(135deg, #f39c12, #e67e22);",
error: "background: linear-gradient(135deg, #e74c3c, #c0392b);",
}
alertDiv.style.cssText += colors[type] || colors.info
const style = document.createElement("style")
style.textContent = `
@keyframes slideDown {
from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
`
document.head.appendChild(style)
alertDiv.className = `wplace-alert-base wplace-alert-${type}`
alertDiv.textContent = message
document.body.appendChild(alertDiv)
@@ -2126,7 +2066,6 @@
alertDiv.style.animation = "slideDown 0.3s ease-out reverse"
setTimeout(() => {
document.body.removeChild(alertDiv)
document.head.removeChild(style)
}, 300)
}, 4000)
},
@@ -3292,13 +3231,20 @@
document.head.appendChild(googleFonts)
}
// Link external CSS file
// Link external CSS files
const cssLink = document.createElement('link');
cssLink.rel = 'stylesheet';
cssLink.href = 'https://staninna.github.io/WPlace-AutoBOT/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 = 'https://staninna.github.io/WPlace-AutoBOT/auto-image-complete-styles.css'; // TODO: Before merge change to https://raw.githubusercontent.com/Wplace-AutoBot/WPlace-AutoBOT/refs/heads/main/auto-image-styles.css
cssLink.setAttribute('data-wplace-theme', 'true');
document.head.appendChild(cssLink);
// Link complete styles CSS file (includes extracted inline styles)
const completeCssLink = document.createElement('link');
completeCssLink.rel = 'stylesheet';
completeCssLink.href = './auto-image-complete-styles.css';
completeCssLink.setAttribute('data-wplace-complete', 'true');
document.head.appendChild(completeCssLink);
// Apply theme-specific dynamic styles
const style = document.createElement("style")
style.setAttribute("data-wplace-theme-dynamic", "true")
@@ -3838,17 +3784,9 @@
`linear-gradient(135deg, ${theme.primary} 0%, ${theme.secondary || theme.primary} 100%)` :
`linear-gradient(135deg, #667eea 0%, #764ba2 100%)`
settingsContainer.style.cssText = `
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: ${themeBackground};
border: ${theme.borderWidth || '1px'} ${theme.borderStyle || 'solid'} ${theme.accent || 'rgba(255,255,255,0.1)'};
border-radius: ${theme.borderRadius || '16px'};
padding: 0;
z-index: 10002;
display: none;
settingsContainer.className = 'wplace-settings-container-base';
// Apply theme-specific background
settingsContainer.style.background = themeBackground;
min-width: 420px;
max-width: 480px;
color: ${theme.text || 'white'};
+753
View File
@@ -0,0 +1,753 @@
/* WPlace Auto-Image Bot - Complete CSS Styles */
/* All styling separated from JavaScript */
/* CSS Custom Properties for Dynamic Values */
:root {
/* Default Theme Colors */
--wplace-primary: #000000;
--wplace-secondary: #111111;
--wplace-accent: #775ce3;
--wplace-text: #ffffff;
--wplace-success: #00ff00;
--wplace-error: #ff0000;
--wplace-warning: #ffa500;
/* Layout Properties */
--wplace-border-width: 1px;
--wplace-border-style: solid;
--wplace-border-radius: 16px;
--wplace-padding: 16px;
/* Animation Properties */
--wplace-glow-enabled: 0;
--wplace-pixel-blink-enabled: 0;
--wplace-scanline-enabled: 0;
/* Overlay Properties */
--wplace-overlay-opacity: 0.6;
}
/* Theme Variants */
.theme-cyberpunk {
--wplace-primary: #0a0a0a;
--wplace-secondary: #1a1a2e;
--wplace-accent: #00ffff;
--wplace-text: #00ff00;
--wplace-glow-enabled: 1;
--wplace-pixel-blink-enabled: 1;
}
.theme-neon {
--wplace-primary: #0f0f23;
--wplace-secondary: #16213e;
--wplace-accent: #ff006e;
--wplace-text: #ffffff;
--wplace-glow-enabled: 1;
}
.theme-matrix {
--wplace-primary: #000000;
--wplace-secondary: #001100;
--wplace-accent: #00ff00;
--wplace-text: #00ff00;
--wplace-scanline-enabled: 1;
}
.theme-minimal {
--wplace-primary: #ffffff;
--wplace-secondary: #f5f5f5;
--wplace-accent: #007acc;
--wplace-text: #333333;
}
/* Base Animations */
@keyframes neonGlow {
0%, 100% {
text-shadow: 0 0 5px currentColor, 0 0 10px currentColor, 0 0 15px currentColor;
}
50% {
text-shadow: 0 0 2px currentColor, 0 0 5px currentColor, 0 0 8px currentColor;
}
}
@keyframes pixelBlink {
0%, 50% { opacity: 1; }
51%, 100% { opacity: 0.7; }
}
@keyframes scanline {
0% { transform: translateY(-100%); }
100% { transform: translateY(400px); }
}
@keyframes pulse {
0% { box-shadow: 0 0 0 0 rgba(0, 255, 0, 0.7); }
70% { box-shadow: 0 0 0 10px rgba(0, 255, 0, 0); }
100% { box-shadow: 0 0 0 0 rgba(0, 255, 0, 0); }
}
@keyframes slideIn {
from { transform: translateY(-10px); opacity: 0; }
to { transform: translateY(0); opacity: 1; }
}
@keyframes slideDown {
from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
@keyframes shimmer {
0% { transform: translateX(-100%); }
100% { transform: translateX(100%); }
}
/* Conditional Animations Based on Theme */
.theme-cyberpunk .wplace-header,
.theme-neon .wplace-header {
animation: neonGlow 2s ease-in-out infinite alternate;
}
.theme-cyberpunk .fas,
.theme-cyberpunk .fa,
.theme-neon .fas,
.theme-neon .fa {
filter: drop-shadow(0 0 3px currentColor);
}
.theme-cyberpunk .wplace-btn:hover:not(:disabled),
.theme-cyberpunk .status-error,
.theme-cyberpunk .wplace-progress-bar::after {
animation: pixelBlink 0.5s infinite;
}
.theme-matrix::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 2px;
background: linear-gradient(90deg, transparent, var(--wplace-accent), transparent);
animation: scanline 3s linear infinite;
pointer-events: none;
}
/* Turnstile Container Styles */
.wplace-turnstile-hidden {
position: fixed !important;
left: -99999px !important;
top: -99999px !important;
width: 1px !important;
height: 1px !important;
pointer-events: none !important;
opacity: 0 !important;
visibility: hidden !important;
z-index: -99999 !important;
overflow: hidden !important;
}
.wplace-turnstile-overlay {
position: fixed !important;
bottom: 20px !important;
right: 20px !important;
z-index: 99999 !important;
background: rgba(0,0,0,0.9) !important;
border-radius: 12px !important;
padding: 20px !important;
box-shadow: 0 8px 32px rgba(0,0,0,0.4) !important;
backdrop-filter: blur(10px) !important;
border: 1px solid rgba(255,255,255,0.2) !important;
color: var(--wplace-text) !important;
font-family: "Segoe UI", sans-serif !important;
min-width: 300px !important;
max-width: 400px !important;
}
.wplace-turnstile-title {
font: 600 12px/1.3 "Segoe UI", sans-serif !important;
margin-bottom: 8px !important;
opacity: 0.9 !important;
color: var(--wplace-text) !important;
}
.wplace-turnstile-host {
width: 100% !important;
min-height: 70px !important;
}
.wplace-turnstile-hide-btn {
position: absolute !important;
top: 6px !important;
right: 6px !important;
font-size: 11px !important;
background: transparent !important;
color: var(--wplace-text) !important;
border: 1px solid rgba(255,255,255,0.2) !important;
border-radius: 6px !important;
padding: 2px 6px !important;
cursor: pointer !important;
}
.wplace-turnstile-hide-btn:hover {
background: rgba(255,255,255,0.1) !important;
}
/* Alert System */
.wplace-alert {
position: fixed;
top: 20px;
left: 50%;
transform: translateX(-50%);
padding: 12px 20px;
border-radius: 8px;
color: white;
font-weight: 600;
z-index: 10001;
max-width: 400px;
text-align: center;
animation: slideDown 0.3s ease-out;
}
.wplace-alert-success {
background: linear-gradient(135deg, #4caf50, #66bb6a);
box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}
.wplace-alert-error {
background: linear-gradient(135deg, #f44336, #ef5350);
box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}
.wplace-alert-warning {
background: linear-gradient(135deg, #ff9800, #ffb74d);
box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}
.wplace-alert-info {
background: linear-gradient(135deg, #2196f3, #42a5f5);
box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}
/* Settings Container */
.wplace-settings-container {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: var(--wplace-primary);
border: var(--wplace-border-width) var(--wplace-border-style) var(--wplace-accent);
border-radius: var(--wplace-border-radius);
padding: 0;
z-index: 10002;
display: none;
color: var(--wplace-text);
font-family: "Segoe UI", Roboto, sans-serif;
min-width: 400px;
max-width: 500px;
max-height: 80vh;
overflow-y: auto;
box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.wplace-settings-container.show {
display: block;
animation: slideIn 0.3s ease-out;
}
/* Settings Header */
.wplace-settings-header {
background: var(--wplace-secondary);
padding: var(--wplace-padding);
border-bottom: 1px solid var(--wplace-accent);
display: flex;
justify-content: space-between;
align-items: center;
}
.wplace-settings-title {
color: var(--wplace-accent);
font-size: 18px;
font-weight: 600;
display: flex;
align-items: center;
gap: 10px;
}
.wplace-settings-close {
background: none;
border: none;
color: var(--wplace-text);
font-size: 18px;
cursor: pointer;
opacity: 0.7;
transition: opacity 0.2s;
}
.wplace-settings-close:hover {
opacity: 1;
}
/* Settings Content */
.wplace-settings {
padding: var(--wplace-padding);
max-height: 400px;
overflow-y: auto;
}
.wplace-setting-section {
margin-bottom: 20px;
padding: 12px;
background: rgba(255,255,255,0.03);
border: 1px solid rgba(255,255,255,0.1);
border-radius: 8px;
}
.wplace-setting-title {
display: flex;
align-items: center;
margin-bottom: 12px;
font-size: 14px;
font-weight: 600;
color: var(--wplace-accent);
}
.wplace-setting-title i {
margin-right: 8px;
}
/* Form Controls */
.wplace-select {
width: 100%;
padding: 8px 12px;
font-size: 14px;
margin-bottom: 10px;
background: var(--wplace-secondary);
border: 1px solid var(--wplace-accent);
border-radius: 6px;
color: var(--wplace-text);
}
.wplace-select:focus {
outline: none;
box-shadow: 0 0 0 2px rgba(119, 92, 227, 0.3);
}
.wplace-description {
font-size: 12px;
opacity: 0.8;
line-height: 1.4;
color: var(--wplace-text);
}
/* Speed Controls */
.wplace-speed-control {
margin-top: 12px;
padding: 12px;
background: rgba(255,255,255,0.03);
border-radius: 8px;
}
.wplace-speed-label {
display: flex;
align-items: center;
margin-bottom: 8px;
font-size: 13px;
font-weight: 600;
color: var(--wplace-text);
}
.wplace-speed-label i {
margin-right: 6px;
}
.wplace-speed-slider-container {
display: flex;
align-items: center;
gap: 12px;
}
.wplace-speed-slider {
flex: 1;
height: 6px;
border-radius: 3px;
outline: none;
cursor: pointer;
-webkit-appearance: none;
appearance: none;
background: #444;
}
.wplace-speed-slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 18px;
height: 18px;
border-radius: 50%;
cursor: pointer;
border: 2px solid var(--wplace-accent);
background: var(--wplace-accent);
}
.wplace-speed-slider::-moz-range-thumb {
width: 18px;
height: 18px;
border-radius: 50%;
cursor: pointer;
border: 2px solid var(--wplace-accent);
background: var(--wplace-accent);
}
.wplace-speed-display {
display: flex;
align-items: center;
gap: 4px;
min-width: 90px;
justify-content: flex-end;
padding: 5px 10px;
border-radius: 4px;
font-weight: 600;
background: var(--wplace-secondary);
color: var(--wplace-text);
}
.wplace-speed-unit {
font-size: 11px;
opacity: 0.8;
}
/* Theme Customization */
.wplace-theme-custom {
margin-top: 15px;
padding: 15px;
background: rgba(255,255,255,0.03);
border-radius: 8px;
}
.wplace-custom-group {
margin-bottom: 15px;
}
.wplace-custom-label {
display: flex;
align-items: center;
margin-bottom: 8px;
font-size: 13px;
font-weight: 600;
color: var(--wplace-text);
}
.wplace-custom-label i {
margin-right: 8px;
width: 16px;
}
.wplace-color-input-group {
display: flex;
gap: 8px;
align-items: center;
}
.wplace-color-input {
width: 50px;
height: 30px;
border: none;
border-radius: 4px;
cursor: pointer;
background: transparent;
}
.wplace-color-text {
flex: 1;
padding: 6px 10px;
border-radius: 4px;
font-size: 12px;
font-family: monospace;
background: var(--wplace-secondary);
border: 1px solid var(--wplace-accent);
color: var(--wplace-text);
}
.wplace-animation-controls {
display: flex;
flex-direction: column;
gap: 8px;
}
.wplace-checkbox-label {
display: flex;
align-items: center;
gap: 8px;
font-size: 12px;
cursor: pointer;
color: var(--wplace-text);
}
.wplace-custom-actions {
display: flex;
gap: 10px;
margin-top: 20px;
border-top: 1px solid rgba(255,255,255,0.1);
padding-top: 15px;
}
/* Overlay Styles */
.wplace-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
z-index: 9999;
display: none;
}
.wplace-overlay.show {
display: block;
}
/* Overlay visibility classes */
.wplace-overlay-hidden {
display: none !important;
}
.wplace-overlay-visible {
display: block !important;
}
/* Responsive Design */
@media (max-width: 768px) {
.wplace-settings-container {
min-width: 90vw;
max-width: 90vw;
margin: 20px;
}
.wplace-turnstile-overlay {
bottom: 10px !important;
right: 10px !important;
left: 10px !important;
min-width: auto !important;
}
.wplace-alert {
max-width: 90vw;
margin: 0 5vw;
}
}
/* Dark/Light mode support */
@media (prefers-color-scheme: light) {
.theme-auto {
--wplace-primary: #ffffff;
--wplace-secondary: #f5f5f5;
--wplace-accent: #007acc;
--wplace-text: #333333;
}
}
@media (prefers-color-scheme: dark) {
.theme-auto {
--wplace-primary: #1e1e1e;
--wplace-secondary: #2d2d30;
--wplace-accent: #775ce3;
--wplace-text: #ffffff;
}
}
/* =============================================== */
/* EXTRACTED INLINE STYLES - PREVIOUSLY IN JS */
/* =============================================== */
/* Turnstile Overlay Styles - extracted from createTurnstileOverlay */
.wplace-turnstile-title {
font: 600 12px/1.3 "Segoe UI", sans-serif;
margin-bottom: 8px;
opacity: 0.9;
color: var(--wplace-text, #ffffff);
}
.wplace-turnstile-host {
width: 100%;
min-height: 70px;
}
.wplace-turnstile-hide-btn {
position: absolute;
top: 6px;
right: 6px;
font-size: 11px;
background: transparent;
color: var(--wplace-text, #ffffff);
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 6px;
padding: 2px 6px;
cursor: pointer;
transition: background 0.2s ease;
}
.wplace-turnstile-hide-btn:hover {
background: rgba(255, 255, 255, 0.1);
}
/* Alert System Styles - extracted from showAlert */
.wplace-alert-base {
position: fixed;
top: 20px;
left: 50%;
transform: translateX(-50%);
padding: 12px 20px;
border-radius: 8px;
color: white;
font-weight: 600;
z-index: 10001;
max-width: 400px;
text-align: center;
animation: slideDown 0.3s ease-out;
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
font-family: 'Segoe UI', sans-serif;
}
/* Alert type variants - extracted from showAlert colors object */
.wplace-alert-info {
background: linear-gradient(135deg, #3498db, #2980b9);
box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}
.wplace-alert-success {
background: linear-gradient(135deg, #27ae60, #229954);
box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
}
.wplace-alert-warning {
background: linear-gradient(135deg, #f39c12, #e67e22);
box-shadow: 0 4px 12px rgba(243, 156, 18, 0.3);
}
.wplace-alert-error {
background: linear-gradient(135deg, #e74c3c, #c0392b);
box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}
/* Settings Container Base Styles - extracted from showSettings */
.wplace-settings-container-base {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 10002;
display: none;
font-family: "Segoe UI", Roboto, sans-serif;
min-width: 400px;
max-width: 500px;
max-height: 80vh;
overflow-y: auto;
animation: slideIn 0.3s ease-out;
border: 1px solid var(--wplace-accent, rgba(255,255,255,0.1));
border-radius: 16px;
padding: 0;
}
.wplace-settings-container-base.show {
display: block;
}
/* Dynamic Theme Background Classes */
.wplace-theme-classic {
background: linear-gradient(135deg, var(--wplace-primary, #000000) 0%, #1a1a1a 100%);
}
.wplace-theme-standard {
background: var(--wplace-primary, #000000);
}
/* Settings Container Theme Variations */
.wplace-settings-cyberpunk {
background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%);
}
.wplace-settings-neon {
background: linear-gradient(135deg, #0f0f23 0%, #16213e 50%, #240046 100%);
}
.wplace-settings-matrix {
background: linear-gradient(135deg, #000000 0%, #001100 50%, #002200 100%);
}
.wplace-settings-retro {
background: linear-gradient(135deg, #2c3e50 0%, #3498db 50%, #9b59b6 100%);
}
.wplace-settings-minimal {
background: linear-gradient(135deg, #ecf0f1 0%, #bdc3c7 100%);
}
.wplace-settings-synthwave {
background: linear-gradient(135deg, #1a0033 0%, #2d1b69 50%, #11998e 100%);
}
.wplace-settings-vapor {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
/* Color swatch states - extracted from updateColorGrid */
.wplace-color-swatch.unavailable {
opacity: 0.4;
filter: grayscale(50%);
}
/* Stats container visibility - extracted from toggleStats */
.wplace-stats-container.hidden {
display: none;
}
/* Additional utility classes for dynamic behavior */
.wplace-drag-active {
transition: none !important;
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8), 0 0 0 2px rgba(255, 255, 255, 0.2) !important;
transform: scale(1.02) !important;
z-index: 9999 !important;
}
.wplace-paint-effect {
animation: pulse 0.5s ease-out;
}
.wplace-settings-error {
background: rgba(255, 0, 0, 0.4) !important;
}
/* Animation modifier classes for conditional application */
.wplace-glow-animation .wplace-header {
animation: neonGlow 2s ease-in-out infinite alternate;
}
.wplace-glow-animation .fas,
.wplace-glow-animation .fa {
filter: drop-shadow(0 0 3px currentColor);
}
.wplace-blink-animation .wplace-btn:hover:not(:disabled) {
animation: pixelBlink 0.5s infinite;
}
.wplace-blink-animation .status-error {
animation: pixelBlink 0.5s infinite;
}
.wplace-blink-animation .wplace-progress-bar::after {
animation: pixelBlink 1s infinite;
}
.wplace-scanline-animation::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 2px;
background: linear-gradient(90deg, transparent, var(--wplace-neon, #00ffff), transparent);
animation: scanline 3s linear infinite;
z-index: 1;
pointer-events: none;
}