User:Walrus068/undominussummaries.js

var undosummaries = function { var a, b, c, d = document.getElementById("mw-diff-ntitle1").getElementsByTagName("strong")[0], e = d.getElementsByTagName("a")[2].search.substring(1) + "&format=json&token=" + encodeURIComponent(YAHOO.util.Cookie.get("EditToken")) + "&summary=", f = function (a) { var b = sajax_init_object; b.onreadystatechange = function { if (this.readyState === 4 && this.status === 200) { if (this.responseText.match(/error/i)) { alert(JSON.parse(this.responseText).error.info); } else { document.location.assign(wgScript + "?title=" + wgPageName); }               }            };            b.open("POST", wgScript.substring(0, wgScript.indexOf("index.php")) + "api.php", true); b.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); b.send(a); },       g = { british: { summary: "British flooring", color: "green", text: "floor", condition: wgNamespaceNumber === 0 && wgCategories[0] !== "Charm log submissions" },           exchange: { summary: "Market price, please.", color: "", text: "market", contition: wgCanonicalNamespace === "Exchange" },           charm1: { summary: "50 or more kills, please.", color: "green", text: "50--", condition: wgCategories[0] === "Charm log submissions" },           charm2: { summary: "Doubt it.", color: "red", text: "nono", condition: wgCategories[0] === "Charm log submissions" },           rdt: { summary: "Rare drop table", color: "red", text: "RDT-", condition: /Bestiary|Items|Demons|Fiends|Elementals|Dragon|Bosses|Dagannoth|Monsters/gi.test(wgCategories) && wgNamespaceNumber === 0 },           test: { summary: "hi suppa", color: "orange", text: "test", condition: true }       },        h = ""; if (!document.getElementsByClassName("diff-multi")[0]) { h = YAHOO.util.Cookie.get("Undo-summary").replace("$1", e.match(/[?&]undo=(\d+)/)[1]).replace(/\$2/g, encodeURIComponent(document.getElementsByClassName("mw-userlink")[1].innerHTML)) + "%20"; }   for (c in g) { if (g[c].condition) { a = document.getElementById("undolinks"); if (!a) { a = document.createElement("strong"); a.id = "undolinks"; d.appendChild(a); }           b = document.createElement("a"); b.innerHTML = g[c].text; b.style.color = g[c].color; b.onclick = function { f(e + h + encodeURIComponent(g[c].summary)); return false; };           b.href = "$"; a.appendChild(document.createTextNode(" ("));           a.appendChild(b);            a.appendChild(document.createTextNode(")")); } else { continue; }   } }; document.addEventListener("DOMContentLoaded", function  {    if (document.location.search.match(/diff=\d+/) && !document.getElementById("differences-nextlink")) {        undosummaries;    } });