User:Aidan9382/scripts/show-all-isxyz-messages.js

Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//Shows all text normally hidden behind certain permissions
function showxyzProcessList(classname, displayname) {
	var classSet = document.getElementsByClassName(classname);
	for (var i=0; i<classSet.length; i++) {
        var classElement = classSet[i];
        var tag = classElement.tagName;
        if (tag == "DIV" || tag == "P")
        	classElement.style = "display: block !important";
        else if (tag == "SPAN" || tag == "SMALL")
        	classElement.style = "display: inline !important";
        else if (tag == "LI")
        	classElement.style = "display: list-item !important";
        else
        	classElement.style = "display: inline !important";
        classElement.innerHTML = "<!--SHOWXYZ_S--><abbr class=\"isxyz-styling\" title=\"[ShowXYZ] This is "+displayname+" only text\"><!--SHOWXYZ_E-->"+classElement.innerHTML+"<!--SHOWXYZ_S--></abbr><!--SHOWXYZ_E-->";
    }
    return classSet.length;
}

function showxyzUnprocessList(classname, displayname) {
	var classSet = document.getElementsByClassName(classname);
	for (var i=0; i<classSet.length; i++) {
        var classElement = classSet[i];
        classElement.style = "";
        classElement.innerHTML = classElement.innerHTML.replace(/<!--SHOWXYZ_S-->.*?<!--SHOWXYZ_E-->/, "").replace(/<!--SHOWXYZ_S-->.*?<!--SHOWXYZ_E-->/, ""); //Yes, twice
    }
}

showxyzTags = {
	"anonymous-show":"IP",
	"user-show":"logged in",
	"autoconfirmed-show":"autoconfirmed",
	"unconfirmed-show":"unconfirmed",
	"extendedconfirmed-show":"extendedconfirmed",
	"nonextendedconfirmed-show":"non-extendedconfirmed",
	"sysop-show":"administrator",
	"checkuser-show":"checkuser",
	"patroller-show":"NPP",
	"abusefilter-show":"abusefilter",
	"abusefilter-helper-show":"abusefilter helper",
	"templateeditor-show":"template editor",
	"extendedmover-show":"extendedmover"
};

function showxyzProcess() {
	var changes = 0;
	for (var tag in showxyzTags) { changes += showxyzProcessList(tag,showxyzTags[tag]); }
	return changes;
}

function showxyzUnprocess() {
	for (var tag in showxyzTags) { showxyzUnprocessList(tag,showxyzTags[tag]); }
}

var shownState = true; //Show by default
function showxyzToggleState() {
	shownState = !shownState;
	if (shownState) {
		showxyzProcess();
	} else {
		showxyzUnprocess();
	}
}

if (showxyzProcess() > 0) { //Only show portlet link if its even taken effect
	mw.util.addCSS(".isxyz-styling {background: #ddd}");
	mw.util.addPortletLink('p-tb', 'javascript:showxyzToggleState()', "Toggle ShowXYZ");
}