User:Flatscan/rollbackToggle.js

const rollbackToggle_rblClass = "mw-rollback-link";

var rollbackToggle_CSS; var rollbackToggle_hidden;

function rollbackToggle_init { // TODO: detect initial setting rollbackToggle_hidden = true; }

function rollbackToggle_toggle { rollbackToggle_hidden = !rollbackToggle_hidden; var css = rollbackToggle_getCSS(rollbackToggle_hidden);

if (rollbackToggle_CSS === undefined) { rollbackToggle_CSS = appendCSS(css); } else { // appendCSS, MediaWiki talk:Common.css/Archive 4 if (rollbackToggle_CSS.styleSheet) { rollbackToggle_CSS.styleSheet.cssText = css; // IE   } else { rollbackToggle_CSS.lastChild.nodeValue = css; } } }

function rollbackToggle_getCSS(hide) { return "." + rollbackToggle_rblClass + " { display: " + ( hide ? "none" : "inline" ) + "; }"; }

function rollbackToggle_hasRollbackLink { var spans = document.getElementsByTagName("span"); for (var i = 0; i < spans.length; i++) { var span = spans[i]; if (span.className == rollbackToggle_rblClass) { return true; } }  return false; }

function rollbackToggle_addLink { if (!rollbackToggle_hasRollbackLink) { return; } rollbackToggle_init; mw.util.addPortletLink("p-cactions", "javascript:rollbackToggle_toggle", "rb toggle", "ca-rollbackToggle", "Toggles rollback links"); }

addOnloadHook(rollbackToggle_addLink);