Jump to content

MediaWiki:Common.js: Difference between revisions

Johnball589 (talk | contribs)
No edit summary
Johnball589 (talk | contribs)
No edit summary
Line 1: Line 1:
mw.loader.using('mediawiki.util', function() {
// Any JavaScript here will be loaded for all users on every page load.
    $(function() {


        // ----- CONFIG -----
// Get current date info
        var today = new Date();
var today = new Date();
        var month = today.getMonth() + 1; // 1–12
var month = today.getMonth() + 1; // JS months are 0-based so add 1
        var day = today.getDate();
var day = today.getDate();


        var prankMonth = 10;
// Define the day and month you want to trigger April Fools mode
        var prankDay = 12;
var prankMonth = 10; // October (since you're testing now)
var prankDay = 12;   // today's day (or change this to whatever test day)


        var forceAF = true;
// Check if it's prank day
        // -------------------
if (month === prankMonth && day === prankDay) {
 
    // Get the current page name
        var pageName = mw.config.get('wgPageName');
    var pageName = mw.config.get('wgPageName');
 
   
        if (!pageName.startsWith('AF:') && pageName !== 'MediaWiki:Common.js') {
    // If we're not already on an AF page, redirect to it
 
    if (!pageName.startsWith('AF:')) {
            if ((month === prankMonth && day === prankDay) || forceAF) {
        window.location.href = '/wiki/AF:' + pageName;
 
     }
                var afPage;
}
                if (pageName === 'Main_Page') {
                    afPage = '/wiki/AF:Main_Page';
                } else {
                    afPage = '/wiki/AF:' + pageName;
                }
 
                window.location.href = afPage;
            }
        }
 
        if (!localStorage.getItem('noAF')) {
            mw.notify("April Fools Mode Activated!");
 
            $('#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();
            });
        }
 
     });
});
Cookies help us deliver our services. By using our services, you agree to our use of cookies.