MediaWiki:Gadget-TheOfficialiserTM.js: Difference between revisions
From SmashWiki, the Super Smash Bros. wiki
Jump to navigationJump to search
(trying to fix pages with italics in the title) |
(this should fix infobox images being killed (also standardised to tabs)) |
||
Line 1: | Line 1: | ||
function getRandomDongle() { | function getRandomDongle() { | ||
var randomDongles = ["","®","™","®™","™®"]; | |||
return randomDongles[Math.floor(Math.random()*randomDongles.length)]; | |||
} | } | ||
function af2024(node,articleName,specifier,canTagline) { | function af2024(node,articleName,specifier,canTagline) { | ||
var text = node.textContent; | |||
if (!text || text === "\n") { | |||
return; | |||
} | |||
var tagline = "from SmashWiki, the Super Smash Bros. wiki"; | |||
var extraTagline = "from SmashWiki, the Super Smash Bros. wiki that anyone can edit"; | |||
if (specifier !== null) { | |||
node.textContent = 'The "'+text+'"'+getRandomDongle()+' '+specifier; | |||
} else { | |||
node.textContent = text+getRandomDongle(); | |||
} | |||
if (articleName !== null && Math.random() > 0.75) { | |||
node.textContent += ' of the "'+articleName+'"'+getRandomDongle()+' SmashWiki article'; | |||
} | |||
var tagRandom = Math.random(); | |||
if (!canTagline) { | |||
tagRandom = 0; | |||
} | |||
if (tagRandom > 0.95) { | |||
node.textContent += " "+extraTagline; | |||
} else if (tagRandom > 0.75) { | |||
node.textContent += " "+tagline; | |||
} | |||
} | } | ||
var articleName = document.querySelectorAll("#firstHeading")[0].textContent; | var articleName = document.querySelectorAll("#firstHeading")[0].textContent; | ||
document.querySelectorAll("#firstHeading").forEach(function(node) { | document.querySelectorAll("#firstHeading").forEach(function(node) { | ||
af2024(node,null,"SmashWiki article",true); | |||
}); | }); | ||
document.querySelectorAll(".mw-headline").forEach(function(node) { | document.querySelectorAll(".mw-headline").forEach(function(node) { | ||
af2024(node,articleName,"section",true); | |||
}); | }); | ||
document.querySelectorAll(".infobox th").forEach(function(node) { | document.querySelectorAll(".infobox th").forEach(function(node) { | ||
af2024(node,null,null,false); | |||
}); | }); | ||
document.querySelectorAll(".infobox td > b").forEach(function(node) { | document.querySelectorAll(".infobox td > b").forEach(function(node) { | ||
af2024(node,null,null,false); | |||
}); | }); | ||
document.querySelectorAll("#pt-userpage > a").forEach(function(node) { | document.querySelectorAll("#pt-userpage > a").forEach(function(node) { | ||
af2024(node,null,"user",false); | |||
}); | }); |
Latest revision as of 21:38, March 31, 2024
function getRandomDongle() {
var randomDongles = ["","®","™","®™","™®"];
return randomDongles[Math.floor(Math.random()*randomDongles.length)];
}
function af2024(node,articleName,specifier,canTagline) {
var text = node.textContent;
if (!text || text === "\n") {
return;
}
var tagline = "from SmashWiki, the Super Smash Bros. wiki";
var extraTagline = "from SmashWiki, the Super Smash Bros. wiki that anyone can edit";
if (specifier !== null) {
node.textContent = 'The "'+text+'"'+getRandomDongle()+' '+specifier;
} else {
node.textContent = text+getRandomDongle();
}
if (articleName !== null && Math.random() > 0.75) {
node.textContent += ' of the "'+articleName+'"'+getRandomDongle()+' SmashWiki article';
}
var tagRandom = Math.random();
if (!canTagline) {
tagRandom = 0;
}
if (tagRandom > 0.95) {
node.textContent += " "+extraTagline;
} else if (tagRandom > 0.75) {
node.textContent += " "+tagline;
}
}
var articleName = document.querySelectorAll("#firstHeading")[0].textContent;
document.querySelectorAll("#firstHeading").forEach(function(node) {
af2024(node,null,"SmashWiki article",true);
});
document.querySelectorAll(".mw-headline").forEach(function(node) {
af2024(node,articleName,"section",true);
});
document.querySelectorAll(".infobox th").forEach(function(node) {
af2024(node,null,null,false);
});
document.querySelectorAll(".infobox td > b").forEach(function(node) {
af2024(node,null,null,false);
});
document.querySelectorAll("#pt-userpage > a").forEach(function(node) {
af2024(node,null,"user",false);
});