MediaWiki:Common.js: Difference between revisions

Johnball589 (talk | contribs)
No edit summary
Tag: Reverted
Johnball589 (talk | contribs)
No edit summary
Tag: Manual revert
Line 1: Line 1:
// Any JavaScript here will be loaded for all users on every page load.
var today = new Date();
var today = new Date();
var month = today.getMonth() + 1;
var month = today.getMonth() + 1;
Line 4: Line 6:


var prankMonth = 10;  // October
var prankMonth = 10;  // October
var prankDay = 12;    // test day
var prankDay = 12;    // your test day


var pageName = mw.config.get('wgPageName');
var pageName = mw.config.get('wgPageName');
Line 11: Line 13:
if (month === prankMonth && day === prankDay) {
if (month === prankMonth && day === prankDay) {


     // Skip pages we don’t want to redirect
     // Don’t redirect these special pages
     if (
     if (
         !pageName.startsWith('AF:') &&       // skip AF pages
         !pageName.startsWith('AF:') &&
         pageName !== 'MediaWiki:Common.js' && // skip Common.js
         pageName !== 'MediaWiki:Common.js'
        pageName !== 'MediaWiki:Common.css'  // optional: skip CSS too
     ) {
     ) {
 
         // If it's the main page
         // Redirect main page explicitly
         if (pageName === 'Main_Page') {
         if (mw.config.get('wgIsMainPage')) {
             window.location.href = '/wiki/AF:Main_Page';
             window.location.replace('/wiki/AF:Main_Page');
         } else {
         } else {
             window.location.replace('/wiki/AF:' + pageName);
             window.location.href = '/wiki/AF:' + pageName;
         }
         }
     }
     }
}
}