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 = ["","®","™","®™","™®"];
var randomDongles = ["","®","™","®™","™®"];
    return randomDongles[Math.floor(Math.random()*randomDongles.length)];
return randomDongles[Math.floor(Math.random()*randomDongles.length)];
}
}


function af2024(node,articleName,specifier,canTagline) {
function af2024(node,articleName,specifier,canTagline) {
    var text = node.textContent;
var text = node.textContent;
    var tagline = "from SmashWiki, the Super Smash Bros. wiki";
if (!text || text === "\n") {
    var extraTagline = "from SmashWiki, the Super Smash Bros. wiki that anyone can edit";
return;
    if (specifier !== null) {
}
  node.textContent = 'The "'+text+'"'+getRandomDongle()+' '+specifier;
var tagline = "from SmashWiki, the Super Smash Bros. wiki";
    } else {
var extraTagline = "from SmashWiki, the Super Smash Bros. wiki that anyone can edit";
    node.textContent = text+getRandomDongle();
if (specifier !== null) {
    }
node.textContent = 'The "'+text+'"'+getRandomDongle()+' '+specifier;
    if (articleName !== null && Math.random() > 0.75) {
} else {
    node.textContent += ' of the "'+articleName+'"'+getRandomDongle()+' SmashWiki article';
node.textContent = text+getRandomDongle();
    }
}
    var tagRandom = Math.random();
if (articleName !== null && Math.random() > 0.75) {
    if (!canTagline) {
node.textContent += ' of the "'+articleName+'"'+getRandomDongle()+' SmashWiki article';
    tagRandom = 0;
}
    }
var tagRandom = Math.random();
    if (tagRandom > 0.95) {
if (!canTagline) {
    node.textContent += " "+extraTagline;
tagRandom = 0;
    } else if (tagRandom > 0.75) {
}
    node.textContent += " "+tagline;
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);
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);
af2024(node,articleName,"section",true);
});
});
document.querySelectorAll(".infobox th").forEach(function(node) {
document.querySelectorAll(".infobox th").forEach(function(node) {
    af2024(node,null,null,false);
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);
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);
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);
});