// ==UserScript==
// @name Interesting Wikipedia userscript
// @namespace roxwize
// @match *://*.wikipedia.org/*
// @grant none
// @version 1.0
// @author roxwize
// @description Does evil things to wikipedia articles
// @license GPL-3.0-or-later
// ==/UserScript==
const images = [
"https://cdn.discordapp.com/attachments/862154953295396884/1173367948249927720/anim9.gif",
"https://media.tenor.com/MBkt9DXPaUYAAAAd/ddostumka%C3%A7.gif",
"https://media.discordapp.net/attachments/836622752735690792/892543216514117662/ezgif.com-gif-maker.gif",
"https://media.discordapp.net/attachments/203413905865834496/625861266988335115/flanders_fucking_dies.gif",
"https://media.discordapp.net/attachments/1114953713153486968/1166939127942500523/vivaldi10807_1698290357.gif",
"https://media.discordapp.net/attachments/816133227508662292/1172693664171040829/anim2.gif",
"https://media.discordapp.net/attachments/972366344983031838/1028865879343120454/Ut3Yx38fp4.gif",
"https://media.discordapp.net/attachments/600630338795995136/1144468663467003924/Untitled-2.gif",
"https://media.tenor.com/C8aEDgYC1y4AAAAd/aphex-twin-come-to-daddy.gif",
"https://cdn.discordapp.com/attachments/1099111307380277331/1125686366668341298/download_8.gif",
"https://media.discordapp.net/attachments/846920921599836180/983072664023363655/FILE0319.gif",
"https://media.tenor.com/4i00_7OrisUAAAAC/sandoz-canu-sandoz.gif",
"https://media.tenor.com/hrNDlz8yD3UAAAAC/harley-quinn-margot-robbie.gif",
"https://cdn.discordapp.com/attachments/800044401501798403/942883938978914354/caption-17-1.gif",
"https://media.tenor.com/s1w-Sc5ahpEAAAAd/paz-pazzin.gif",
"https://media.discordapp.net/attachments/907403580011601931/908189601888354384/image0-2.gif",
"https://media.discordapp.net/attachments/862154953295396884/1168344353014562816/anim8.gif",
"https://cdn.discordapp.com/attachments/862154953295396884/1173407665305690172/1D1cW2Ntai.gif",
"https://media.tenor.com/dWS427mpAZAAAAAd/secu-rity-meme.gif",
"https://media.tenor.com/XUFDsSt48GYAAAAd/eminem.gif",
"https://media.tenor.com/QgphpoWrjaAAAAAd/retro-retro-dev.gif",
"https://media.tenor.com/uSo4lQu9dVgAAAAC/homer-smile.gif",
"https://media.tenor.com/QMpyBmPBlhoAAAAC/wtf-roblox.gif",
"https://media.tenor.com/47hdAGX-uAwAAAAC/charjabug-weegee.gif"
];
let words = [];
const config = {
styleModifications: {
label: "Modify page style",
current: true
},
linkModifications: {
label: "Modify links",
current: true
},
figCaptions: {
label: "Modify image captions",
current: false
},
textualModifications: {
label: "Screw up text nodes",
current: true
}
};
function modify(e, f) {
const n = e.childNodes;
for (let d of n) {
if (d.nodeType === Node.TEXT_NODE) f(d);
else modify(d, f);
}
}
const chance = () => Math.random() * 100;
const rand = (a) => a[Math.floor(Math.random() * a.length)];
const screwup = (str) => {
const s = str.split("");
let o = "";
for (let l of s) {
if (chance() < 80) o += l;
if (chance() > 90) o += l;
}
return o;
}
(function() {
const rootEl = document.createElement("div");
rootEl.id = "god";
rootEl.style = "position:fixed;bottom:1em;left:1em;background:rgba(50,40,80,0.8);padding:1em;color:white;";
rootEl.innerHTML = '<input type="text" id="bregex" placeholder="regex" /><br/><input type="text" id="breplacement" placeholder="replacement" /><br/><button id="bok" style="cursor:pointer;">ok</button>';
document.body.appendChild(rootEl);
document.getElementById("bok").addEventListener("click", () => {
words = [];
const regexp = new RegExp(document.getElementById("bregex").value, "g");
const replce = document.getElementById("breplacement").value;
document.querySelectorAll(`p, ${config.figCaptions.current ? "figcaption," : ""} th, td, li, h1, h2, h3, h4, h5, h6`).forEach((e) => {
modify(e, (node) => {
node.textContent = node.textContent.replaceAll(regexp, replce); words.push(node.textContent);
if (config.textualModifications.current) {
if (chance() > 90) {
node.textContent = node.textContent.replaceAll(/[aeiou]/g, "");
} else if (chance() > 90) {
node.textContent = screwup(node.textContent);
}
}
});
if (config.styleModifications.current) {
e.style.color = `hsl(${Math.round(Math.random()*360)} 50% 50%)`;
e.style.textDecoration = chance() > 70 ? "underline" : "normal";
e.style.fontStyle = chance() > 70 ? "italic" : "normal";
if (chance() > 30) {
e.style.transform = `translate(${Math.random()*25}px, ${Math.random()*50}px)`;
} else {
e.style.transform = `rotate(${Math.random()*5-2.5}deg)`;
if (chance() > 45) {
e.style.transform += ` scale(${Math.random()*2+0.5})`;
}
}
e.style.fontSize = `${9 + Math.floor(Math.random()*10)}pt`;
}
});
document.querySelectorAll("img").forEach((e) => {
e.src = rand(images);
});
if (config.linkModifications.current) {
document.querySelectorAll("a").forEach((e) => {
e.setAttribute("href", "https://en.wikipedia.org/wiki/Special:Random");
modify(e, (node) => {
node.textContent = rand(words);
});
});
}
});
const configEl = document.createElement("div");
configEl.id = "gantzgraf";
configEl.style = "position:fixed;bottom:1em;right:1em;background:rgba(50,40,80,0.8);padding:1em;color:white;";
for (let [k, v] of Object.entries(config)) {
const e = document.createElement("div");
e.style = "display:flex;align-items:center;gap:1em;";
e.innerHTML = `<label for="bo-${k}" style="flex-grow:1;text-align:right;">${v.label}</label>`;
const o = document.createElement("input");
o.type = "checkbox";
o.name = `bo-${k}`;
o.id = o.name;
o.checked = config[k].current;
o.addEventListener("input", () => {
config[k].current = o.checked;
});
e.appendChild(o);
configEl.appendChild(e);
}
document.body.appendChild(configEl);
})();