Jump to content

MediaWiki:Common.js: Difference between revisions

From Electron: Chat App Wiki
Johnball589 (talk | contribs)
No edit summary
rmv accidental redirection happening every day
 
(18 intermediate revisions by one other user not shown)
Line 1: Line 1:
$(function() {
  const today = new Date();
  const month = today.getMonth(); // 0 = Jan, 3 = April
  const date = today.getDate();


  if (month === 9 && date === 12 && !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();
    });
  }
});

Latest revision as of 17:59, 12 October 2025

Cookies help us deliver our services. By using our services, you agree to our use of cookies.