|
|
Line 1: |
Line 1: |
| $(function() {
| | // Any JavaScript here will be loaded for all users on every page load. |
| console.log("✅ April Fools script loaded");
| |
|
| |
|
| var today = new Date();
| | // Get current date info |
| var month = today.getMonth() + 1;
| | var today = new Date(); |
| var day = today.getDate();
| | var month = today.getMonth() + 1; // JS months are 0-based so add 1 |
| | var day = today.getDate(); |
|
| |
|
| var prankMonth = 10; // testing month
| | // Define the day and month you want to trigger April Fools mode |
| var prankDay = 12; // testing day
| | var prankMonth = 10; // October (since you're testing now) |
| | var prankDay = 12; // today's day (or change this to whatever test day) |
|
| |
|
| // Check localStorage at the very top
| | // Check if it's prank day |
| var afDisabled = localStorage.getItem('noAF');
| | if (month === prankMonth && day === prankDay) { |
| if (afDisabled) return; // If disabled, stop script immediately
| | // Get the current page name |
| | | var pageName = mw.config.get('wgPageName'); |
| // Add "Turn off April Fools" to user dropdown early
| | |
| if ($('#p-personal ul').length) {
| | // If we're not already on an AF page, redirect to it |
| $('#p-personal ul').append('<li><a href="#" id="disable-af">Turn off April Fools</a></li>');
| | if (!pageName.startsWith('AF:')) { |
| $('#disable-af').on('click', function(e) {
| | window.location.href = '/wiki/AF:' + pageName; |
| e.preventDefault();
| |
| localStorage.setItem('noAF','1'); // disable AF mode
| |
| location.reload();
| |
| });
| |
| }
| |
| | |
| // Only redirect if it's the prank day
| |
| if (month === prankMonth && day === prankDay) {
| |
| var pageName = mw.config.get('wgPageName');
| |
| | |
| if (!pageName.startsWith('AF:')) {
| |
| var afPage = '/wiki/AF:' + pageName;
| |
| $.get(afPage, function(data) {
| |
| if (!data.includes('There is currently no text in this page')) {
| |
| window.location.href = afPage;
| |
| }
| |
| });
| |
| }
| |
| | |
| // Add a "Back to regular page" bar for AF pages
| |
| if (pageName.startsWith('AF:')) {
| |
| var regularPage = pageName.replace(/^AF:/, '');
| |
| $('body').prepend('<div id="back-regular" style="background:yellow;padding:10px;text-align:center;cursor:pointer;font-weight:bold;">Click here to go back to regular page</div>');
| |
| $('#back-regular').on('click', function() {
| |
| localStorage.setItem('noAF','1');
| |
| window.location.href = '/wiki/' + regularPage;
| |
| });
| |
| }
| |
| | |
| mw.notify("🤡 April Fools Mode Activated");
| |
| } | | } |
| }); | | } |