MediaWiki:Monobook.js: Difference between revisions

From JP1 Remotes Wiki
Jump to navigationJump to search
Created page with "All JavaScript here will be loaded for users of the MonoBook skin: document.addEventListener('DOMContentLoaded', function () { const mainLink = document.querySelector('#mw-panel a[href*="Main_Page"]'); if (mainLink) { mainLink.removeAttribute('style'); } });"
 
No edit summary
Line 1: Line 1:
/* All JavaScript here will be loaded for users of the MonoBook skin */
/* All JavaScript here will be loaded for users of the MonoBook skin */
document.addEventListener('DOMContentLoaded', function () {
document.addEventListener('DOMContentLoaded', function () {
   const mainLink = document.querySelector('#mw-panel a[href*="Main_Page"]');
   const el = document.querySelector('#n-mainpage-description a');
   if (mainLink) {
   if (el && el.style.border.includes('red')) {
     mainLink.removeAttribute('style');
     el.style.border = 'none';
   }
   }
  // MutationObserver to catch re-injections
  new MutationObserver(muts => {
    muts.forEach(m => {
      if (m.type === 'attributes' && m.attributeName === 'style') {
        const el = m.target;
        if (el.id === 'n-mainpage-description' || el.closest('#n-mainpage-description')) {
          if (el.style.border.includes('red')) {
            el.style.border = 'none';
          }
        }
      }
    });
  }).observe(document.getElementById('n-mainpage-description'), {
    attributes: true,
    subtree: true,
    attributeFilter: ['style']
  });
});
});

Revision as of 18:05, 18 November 2025

/* All JavaScript here will be loaded for users of the MonoBook skin */
document.addEventListener('DOMContentLoaded', function () {
  const el = document.querySelector('#n-mainpage-description a');
  if (el && el.style.border.includes('red')) {
    el.style.border = 'none';
  }

  // MutationObserver to catch re-injections
  new MutationObserver(muts => {
    muts.forEach(m => {
      if (m.type === 'attributes' && m.attributeName === 'style') {
        const el = m.target;
        if (el.id === 'n-mainpage-description' || el.closest('#n-mainpage-description')) {
          if (el.style.border.includes('red')) {
            el.style.border = 'none';
          }
        }
      }
    });
  }).observe(document.getElementById('n-mainpage-description'), {
    attributes: true,
    subtree: true,
    attributeFilter: ['style']
  });
});