User:Weeklyd3/scripts/linkRemover.js

/* Hides some links I do not frequently use. */ (function { var idsToHide = ["t-mute", 'n-portal', 'n-help', 'n-introduction', 'n-currentevents', 'n-contents', 'n-aboutsite', 'n-contactpage', 'n-sitesupport']; if (!globalThis.hiddenLeft) globalThis.hiddenLeft = idsToHide; for (var i = 0; i < globalThis.hiddenLeft.length; i++) {	var link = document.querySelector('li#' + globalThis.hiddenLeft[i]);	if (!link) continue;	link.style.display = 'none'; } }); if (mw.config.get("wgFormattedNamespaces")[mw.config.get("wgNamespaceNumber")] === "Special"    && mw.config.get("wgTitle") === "HideLinks") { document.querySelector('title').textContent = 'Hide links - Wikipedia'; document.querySelector('h1').textContent = 'Links to hide'; document.querySelector('#mw-content-text').innerHTML = ` Here are some of the IDs of links on the left. Note that other userscripts may add other links. To choose the links to hide, set  to an array with the ids to hide before loading the link remover script. (Note: This list is generated automatically on page load.) `;	var links = document.querySelectorAll('#mw-panel > nav'); for (var i = 0; i < links.length; i++) { var menu = links[i]; var title = menu.children[0]; if (title.textContent != "") { var titleField = document.createElement('tr'); var titleText = document.createElement('td'); titleText.style.textAlign = 'center'; titleText.textContent = title.textContent; titleText.setAttribute('colspan', '3'); titleField.appendChild(titleText); document.querySelector('#links').appendChild(titleField); }		var menuChildren = menu.children[1].children[0]; if (menuChildren.tagName !== 'UL') continue; var menuChildrenItems = menuChildren.children; for (var j = 0; j < menuChildrenItems.length; j++) { var menuItem = menuChildrenItems[j]; var data = document.createElement('tr'); var linkText = document.createElement('td'); linkText.textContent = menuItem.textContent; data.appendChild(linkText); var idText = document.createElement('td'); idText.textContent = menuItem.getAttribute('id'); data.appendChild(idText); var hidden = document.createElement('td'); hidden.innerHTML = (menuItem.style.display == 'none') ? ' Yes ' : "No"; data.appendChild(hidden); document.querySelector('#links').appendChild(data); }	} }