User:SD0001/AllCollapseToggle.js

/**

* Simple script to to provide an option in the left sidebar "Tools" menu (p-tb)

* to uncollapse/collapse all hatted discussions and navboxes on a page.

* Requested by Atsme, Special:Diff/902814062

*/

$.when(mw.loader.using('mediawiki.util'), $.ready).then(function() {

var i = 0;

$(mw.util.addPortletLink('p-tb', '#', 'Uncollpase all', 'collapse-toggle',

'Collapse or uncollapse all hatted discussions and navboxes on this page')).click(function() {

$('.mw-collapsible-toggle-default').click();

if (i % 2 == 0) {

$('.mw-collapsible-toggle-collapsed').click();

this.childNodes[0].textContent = 'Collapse all';

} else {

$('.mw-collapsible-toggle-expanded').click();

this.childNodes[0].textContent = 'Uncollapse all';

}

i++;

});

});