fix: Add MutationObserver to continuously hide OpenWrt header
- Added startHeaderObserver() for continuous DOM monitoring - Observer watches for new header elements and hides them immediately - Added interval-based backup hiding every 100ms - Ensures OpenWrt header stays hidden even after dynamic content loads Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
a604b2da61
commit
48da7d71ad
@ -254,6 +254,36 @@ function injectCSS() {
|
|||||||
document.head.appendChild(style);
|
document.head.appendChild(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Continuously watch and hide OpenWrt header elements
|
||||||
|
var headerObserver = null;
|
||||||
|
function startHeaderObserver() {
|
||||||
|
if (headerObserver) return;
|
||||||
|
|
||||||
|
var hideNonSecuBoxHeaders = function() {
|
||||||
|
document.querySelectorAll('header, .brand, div.brand, header.brand, .main-header, #header').forEach(function(el) {
|
||||||
|
if (!el.classList.contains('sb-global-header') && !el.closest('.sb-global-header') && !el.closest('.secubox-page-wrapper')) {
|
||||||
|
el.style.cssText = 'display:none!important;visibility:hidden!important;height:0!important;overflow:hidden!important;';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Run immediately
|
||||||
|
hideNonSecuBoxHeaders();
|
||||||
|
|
||||||
|
// Watch for DOM changes
|
||||||
|
headerObserver = new MutationObserver(function(mutations) {
|
||||||
|
hideNonSecuBoxHeaders();
|
||||||
|
});
|
||||||
|
|
||||||
|
headerObserver.observe(document.body, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// Also run on intervals as backup
|
||||||
|
setInterval(hideNonSecuBoxHeaders, 100);
|
||||||
|
}
|
||||||
|
|
||||||
function hideOpenWrtUI() {
|
function hideOpenWrtUI() {
|
||||||
document.body.classList.add('secubox-mode');
|
document.body.classList.add('secubox-mode');
|
||||||
|
|
||||||
@ -371,6 +401,7 @@ return baseclass.extend({
|
|||||||
render: function() {
|
render: function() {
|
||||||
injectCSS();
|
injectCSS();
|
||||||
hideOpenWrtUI();
|
hideOpenWrtUI();
|
||||||
|
startHeaderObserver();
|
||||||
|
|
||||||
var activeSection = detectActiveSection();
|
var activeSection = detectActiveSection();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user