MediaWiki:Gadget-TheOfficialiserTM.js: Difference between revisions

From SmashWiki, the Super Smash Bros. wiki
Jump to navigationJump to search
(Created page with "function getRandomDongle() { var randomDongles = ["","®","™","®™","™®"]; return randomDongles[Math.floor(Math.random()*randomDongles.length)]; } function af2024(node,articleName,specifier,canTagline) { var text = node.textContent; 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+'...")
 
(trying to fix pages with italics in the title)
Line 27: Line 27:
}
}


var articleName = document.querySelectorAll(".mw-page-title-main")[0].textContent;
var articleName = document.querySelectorAll("#firstHeading")[0].textContent;
document.querySelectorAll(".mw-page-title-main").forEach(function(node) {
document.querySelectorAll("#firstHeading").forEach(function(node) {
     af2024(node,null,"SmashWiki article",true);
     af2024(node,null,"SmashWiki article",true);
});
});

Revision as of 19:50, 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;
    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);
});