User:Phlsph7/AlphabeticToolbox.js

// sort the links in the toolbox alphabetically $(document).ready(function {	setTimeout(function{ const toolbox = document.getElementById('p-tb'); const list = toolbox.getElementsByTagName('ul')[0]; const items = Array.from(list.getElementsByTagName('li')); items.sort(function(a, b) {			var textA = a.textContent.trim.toUpperCase;			var textB = b.textContent.trim.toUpperCase;			return textA.localeCompare(textB);		}); // Remove existing items and append sorted items while (list.firstChild) { list.removeChild(list.firstChild); }		items.forEach(function(item) {			list.appendChild(item);		}); // hide unnecessary items const hideItems = `Cite this page, Download QR code, Edit interlanguage links, Expand all, Get shortened URL, Permanent link, Related changes, Special pages, What links here, Wikidata item, Add interlanguage links`.split(', '); for(let item of items){ if(hideItems.includes(item.textContent)){ item.style.display = 'none'; }		}	}, 500); });