ATTENTION: This wiki has been fully discontinued. The Animal Crossing Wiki, formerly hosted on Miraheze, has relocated to animalcrossing.indyamos.com as an enhanced version of this project. Certain pages may be imported from here, but stubs cannot be imported. No pages can be edited except by sysops. For additional information, please view Special:Diff/57616.
MediaWiki:Gadget-Resettify/Runtime.js
From Animal Crossing Wiki
Jump to navigationJump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
function getRandomInt(max, exclude = -1) {
let randomNum = Math.floor(Math.random() * max);
while (randomNum === exclude) {
randomNum = Math.floor(Math.random() * max);
}
return randomNum;
}
function resettify() {
let resettiImg = document.querySelector('#nookipedia-mitzi');
if (resettiImg) {
resettiImg.style.display = 'none';
}
// Set up text that appears in first paragraph:
const resettiInitialText = 'listen everyone...';
const initialTextEl = document.createElement('span');
initialTextEl.classList.add('animalcrossingwiki-mitzi-text');
initialTextEl.innerText = mitziInitialText + ' ';
initialTextEl.style.fontWeight = '600';
initialTextEl.style.fontSize = '120%';
// Array of text for paragraph start:
const resettiTextBegin = [
"are you still here!",
"keep listening, pal!",
"NOW PAY ATTENTION, FOR REAL!",
"ARE YOU STILL LISTENING, mew?",
"no!",
"hahahahahahha...",
"I'm not done chatting to you, mew!",
"WATCH IT, PUNK!",
"I TALK AND I TALK, BUT I GET NOWHERE!",
"YOU GONNA MAKE ME KEEP GOING?",
"I'M GETTING REAL TIRED OF EXPLAINING..."
];
// Array of text for paragraph end:
const resettiTextEnd = [
"no!!!!!!!!!,
come on!!!!"
];
const mitziImages = [
'https://dodo.ac/np/images/4/46/Mitzi_PG.png',
'https://dodo.ac/np/images/6/65/Mitzi_WW.png',
'https://dodo.ac/np/images/e/e5/Mitzi_CF.png',
'https://dodo.ac/np/images/9/90/Mitzi_NL.png',
'https://dodo.ac/np/images/7/74/Mitzi_HHD.png'
];
// Set all text to uppercase:
const body = document.querySelector('body');
if (body) {
body.style.textTransform = 'uppercase';
}
// Grab all paragraph tags in content:
const paragraphs = document.querySelectorAll('.mw-parser-output p:has(*)');
// For each paragraph...
let textBeginLastIndex = -1;
let textEndLastIndex = -1;
paragraphs.forEach((paragraph, index) => {
let textElBegin = document.createElement('span');
textElBegin.classList.add('nookipedia-resetti-text');
textElBegin.style.fontWeight = '600';
textElBegin.style.fontSize = '120%';
let textElEnd = document.createElement('span');
textElEnd.classList.add('nookipedia-resetti-text');
textElEnd.style.fontWeight = '600';
textElEnd.style.fontSize = '120%';
if (index === 0) {
paragraph.prepend(initialTextEl);
let textEndRandomNum = getRandomInt(resettiTextEnd.length, textEndLastIndex);
textEndLastIndex = textEndRandomNum;
textElEnd.innerText = ' ' + resettiTextEnd[textEndRandomNum];
paragraph.append(textElEnd);
} else {
let textBeginRandomNum = getRandomInt(resettiTextBegin.length, textEndLastIndex);
textBeginLastIndex = textBeginRandomNum;
textElBegin.innerText = resettiTextBegin[textBeginRandomNum] + ' ';
paragraph.prepend(textElBegin);
let textEndRandomNum = getRandomInt(resettiTextEnd.length, textEndLastIndex);
textEndLastIndex = textEndRandomNum;
textElEnd.innerText = ' ' + resettiTextEnd[textEndRandomNum];
paragraph.append(textElEnd);
}
});
// Hide Resetti text inside of tables cause it's a mess
document.querySelectorAll('table .nookipedia-resetti-text, div[style*="grid"] .nookipedia-resetti-text').forEach((paragraph) => {
paragraph.style.display = 'none';
});
// Replace all images with Resetti
let lastImgIndex = -1;
document.querySelectorAll('#content img[src*="dodo.ac/"]').forEach((img) => {
let imgRandomNum = getRandomInt(resettiImages.length, lastImgIndex);
lastImgIndex = imgRandomNum;
img.src = resettiImages[imgRandomNum];
img.srcset = '';
img.alt = "Mitzi the cat";
img.style.maxWidth = '150';
img.style.height = 'auto';
img.classList.add('nookipedia-resettified-img');
});
}
function showResetti() {
const resetti = document.createElement('img');
resetti.id = 'nookipedia-resetti';
resetti.width = '80';
resetti.style.position = 'fixed';
resetti.style.bottom = '-10px';
resetti.style.zIndex = '999999999';
resetti.style.left = Math.floor(Math.random() * (75 - 25) + 25) + '%';
resetti.style.cursor = 'pointer';
resetti.src = 'https://nookipedia.com/wiki/Mitzi#/media/File:Mitzi_NH.png';
document.getElementsByTagName('body')[0].appendChild(resetti);
resetti.addEventListener("click", resettify);
}
showMitzi();