|
|
(2 intermediate revisions by one other user not shown) |
Line 1: |
Line 1: |
| $(function() {
| |
| console.log("✅ April Fools script loaded");
| |
|
| |
|
| var today = new Date();
| |
| var month = today.getMonth() + 1;
| |
| var day = today.getDate();
| |
|
| |
| var prankMonth = 10; // testing month
| |
| var prankDay = 12; // testing day
| |
|
| |
| // Check localStorage at the very top
| |
| var afDisabled = localStorage.getItem('noAF');
| |
| if (afDisabled) return; // If disabled, stop script immediately
| |
|
| |
| // Add "Turn off April Fools" to user dropdown early
| |
| if ($('#p-personal ul').length) {
| |
| $('#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'); // 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");
| |
| }
| |
| });
| |