Fix alert: use !important via style tag to override WHM CSS

WHM's CSS overrides inline styles on positioned elements. Inject a
style tag with !important rules targeting #gniza-alert to ensure
fixed positioning, padding, and sizing are applied correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-04 03:17:51 +02:00
parent 632309db0f
commit f85cbb49c9
2 changed files with 14 additions and 2 deletions

View File

@@ -714,11 +714,17 @@ function gnizaTestConnection() {
function gnizaToast(type, msg) {
var prev = document.getElementById('gniza-alert');
if (prev) prev.remove();
var s = document.getElementById('gniza-alert-style');
if (!s) {
s = document.createElement('style');
s.id = 'gniza-alert-style';
s.textContent = '#gniza-alert{position:fixed!important;top:24px!important;right:24px!important;z-index:9999!important;max-width:480px!important;padding:12px 20px!important;border-radius:8px!important;font-size:14px!important;box-shadow:0 4px 12px rgba(0,0,0,.15)!important;transition:opacity .3s!important;display:block!important;}';
document.head.appendChild(s);
}
var el = document.createElement('div');
el.id = 'gniza-alert';
el.className = 'alert alert-' + type;
el.textContent = msg;
el.style.cssText = 'position:fixed;top:24px;right:24px;z-index:9999;max-width:480px;padding:12px 20px;border-radius:8px;font-size:14px;box-shadow:0 4px 12px rgba(0,0,0,.15);transition:opacity .3s';
document.body.appendChild(el);
setTimeout(function() { el.style.opacity = '0'; }, type === 'error' ? 6000 : 3000);
setTimeout(function() { el.remove(); }, type === 'error' ? 6500 : 3500);

View File

@@ -316,11 +316,17 @@ function gnizaTestConnection() {
function gnizaToast(type, msg) {
var prev = document.getElementById('gniza-alert');
if (prev) prev.remove();
var s = document.getElementById('gniza-alert-style');
if (!s) {
s = document.createElement('style');
s.id = 'gniza-alert-style';
s.textContent = '#gniza-alert{position:fixed!important;top:24px!important;right:24px!important;z-index:9999!important;max-width:480px!important;padding:12px 20px!important;border-radius:8px!important;font-size:14px!important;box-shadow:0 4px 12px rgba(0,0,0,.15)!important;transition:opacity .3s!important;display:block!important;}';
document.head.appendChild(s);
}
var el = document.createElement('div');
el.id = 'gniza-alert';
el.className = 'alert alert-' + type;
el.textContent = msg;
el.style.cssText = 'position:fixed;top:24px;right:24px;z-index:9999;max-width:480px;padding:12px 20px;border-radius:8px;font-size:14px;box-shadow:0 4px 12px rgba(0,0,0,.15);transition:opacity .3s';
document.body.appendChild(el);
setTimeout(function() { el.style.opacity = '0'; }, type === 'error' ? 6000 : 3000);
setTimeout(function() { el.remove(); }, type === 'error' ? 6500 : 3500);