MediaWiki:Common.js

Revision as of 16:29, 12 October 2025 by Johnball589 (talk | contribs) (Created page with "$(function() { const today = new Date(); const month = today.getMonth(); // 0 = Jan, 3 = April const date = today.getDate(); // Check if it's April 1st if (month === 3 && date === 1 && !localStorage.getItem('noAF')) { const pageName = mw.config.get('wgPageName'); const afPage = 'AF:' + pageName; // Only redirect if we're not already on the AF page if (!pageName.startsWith('AF:')) { $.get(mw.util.getUrl(afPage), function(data) { i...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.
$(function() {
  const today = new Date();
  const month = today.getMonth(); // 0 = Jan, 3 = April
  const date = today.getDate();

  // Check if it's April 1st
  if (month === 3 && date === 1 && !localStorage.getItem('noAF')) {
    const pageName = mw.config.get('wgPageName');
    const afPage = 'AF:' + pageName;

    // Only redirect if we're not already on the AF page
    if (!pageName.startsWith('AF:')) {
      $.get(mw.util.getUrl(afPage), function(data) {
        if (!data.includes('There is currently no text in this page')) {
          window.location.href = mw.util.getUrl(afPage);
        }
      });
    }

    // Add goofy styles to the page
    $('body').addClass('april-fools');


    $('#p-personal ul').append('<li><a href="#" id="disable-af">Turn off April Fools</a></li>');
    $('#disable-af').on('click', function(e) {
      e.preventDefault();
      localStorage.setItem('noAF', '1');
      location.reload();
    });
  }
});