Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js

MediaWiki interface page
Revision as of 21:06, 29 December 2025 by Cranio is thinking (talk | contribs)

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.
/* Any JavaScript here will be loaded for all users on every page load. */

mw.hook('wikipage.content').add(function ($content) {
  // 1) trova il box nel contenuto
  var $box = $content.find('[data-stato-archivio="1"]').first();
  if (!$box.length) return;

  // 2) trova l'area TOC di Citizen
  // Citizen usa comunemente .citizen-toc per il blocco del ToC (sidebar/rail)
  var tocContainer =
    document.querySelector('.citizen-toc') ||
    document.querySelector('#citizen-toc') ||
    document.querySelector('#toc'); // fallback estremo

  if (!tocContainer) return;

  // 3) inserisci il box sopra al contenuto del TOC
  // se esiste un contenitore interno, mettiamo il box prima della lista
  var inner =
    tocContainer.querySelector('.citizen-toc-contents') ||
    tocContainer.querySelector('.toc') ||
    tocContainer;

  inner.parentNode.insertBefore($box[0], inner);

  // 4) margini “da widget” nella rail
  $box[0].style.margin = '0 0 12px 0';
});