User:Grutness/nothingthree-monobookTops.js

nothingthreeTops = { core: function (topsOpacity, animationCallback) { //Sets opacity of (top) edits. If you plan on setting topsOpacity to 0, you might want to set animationCallback to make the then-invisible links unclickable. var cli, lin, topElsewhere, titleSelectorGroup, titleSelector; cli = jQuery(jQuery("#bodyContent > ul")[0]).find("li"); lin = 0; topElsewhere = []; for (lin = 0; lin < cli.length; lin++) { titleSelectorGroup = jQuery(cli[lin]).find("a:not(.comment a, .mw-rollback-link a)"); //hopefully this is not too hackish! :)               titleSelector = titleSelectorGroup[titleSelectorGroup.length - 1].textContent || titleSelectorGroup[titleSelectorGroup.length - 1].innerText; //this neither! textContent seems better, but IE needs innerText.                if (jQuery(cli[lin]).children(".mw-uctop").length >= 1 || topElsewhere.indexOf(titleSelector) !== -1) {                    jQuery(cli[lin]).fadeTo("default", topsOpacity, animationCallback);                    topElsewhere.push(titleSelector);                } //end if            } //end for        }, //end core

hiddenOpacity: 0.25, topsHidden: false, hide: function { //Hides (top) edits. nothingthreeTops.core(nothingthreeTops.hiddenOpacity); nothingthreeTops.topsHidden = true; }, //end hide show: function { //Shows (top) edits. nothingthreeTops.core(1); nothingthreeTops.topsHidden = false; }, //end show toggle: function { //Toggles between hidden and shown based on the current value. if (nothingthreeTops.topsHidden === true) { nothingthreeTops.show; } else { nothingthreeTops.hide; }       }, //end toggle toggleTab: function { //Adds a tab to the menu allowing the visibility of (top) edits to be toggled. if (document.body.className.indexOf("page-Special_Contributions") !== -1 && jQuery("#ca-tops").length === 0) { mw.util.addPortletLink('p-cactions', 'javascript:nothingthreeTops.toggle', 'Toggle (top) entries', 'ca-tops', 'Hide or show the (top) entries', null, null); jQuery("#ca-tops").addClass("collapsible"); } //end if       } //end toggleTab }

jQuery(document).ready(function {nothingthreeTops.toggleTab;})