MediaWiki:Common.js

From ICE List Wiki
Revision as of 14:46, 20 December 2025 by ICEListAdmin6 (talk | contribs)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* === ICE List Site Notice Close Button (Minimal, Safe) === */

mw.hook('wikipage.content').add(function () {
  if (!mw.user.isAnon()) return;

  var notice = document.getElementById('siteNotice');
  if (!notice) return;

  // Already dismissed
  if (localStorage.getItem('icelist_notice_closed') === '1') {
    notice.style.display = 'none';
    return;
  }

  // Prevent duplicate buttons
  if (notice.querySelector('.icelist-notice-close')) return;

  var btn = document.createElement('button');
  btn.className = 'icelist-notice-close';
  btn.setAttribute('aria-label', 'Close');
  btn.textContent = '×';

  btn.onclick = function () {
    notice.style.display = 'none';
    localStorage.setItem('icelist_notice_closed', '1');
  };

  notice.appendChild(btn);
});