Jump to content

User:Terasail/HeaderTextLinks.js

From Wikipedia, the free encyclopedia
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.
/*	//<nowiki>
	HeaderTextLinks.js
	Created by: Terasail
*/
if (mw.config.get("skin") === "vector-2022") {
	//Static header
	let headerIconList = $("#p-vector-user-menu-overflow .vector-menu-content-list")[0];
	let headerIcons = headerIconList.children;
	for (let i = 0; i < headerIcons.length; i++) {//Remove icons after notification buttons
		if (headerIcons[i].id !== "pt-userpage-2" && headerIcons[i].id.indexOf("-2") >= 0) {
			headerIcons[i].remove();
		}
	}
	let userLinks = $("#p-personal .mw-list-item");
	for (let i = 1; i < userLinks.length; i++) {
		let tempElem = userLinks[i].cloneNode(true);
		tempElem.id = userLinks[i].id + '-2';
		tempElem.className = 'user-links-collapsible-item mw-list-item';
		tempElem.children[0].className = 'cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only';
		tempElem.children[0].children[0].remove();
		$(headerIconList).append(tempElem);
	}

	//Sticky header
	if ($('#vector-sticky-header').length !== 0) {//Check for sticky header
		let stickyIconList = $(".vector-sticky-header-buttons")[0];
		for (let i = 1; i < userLinks.length; i++) {
			let tempElem = userLinks[i].children[0].cloneNode(true);
			tempElem.id = userLinks[i].id + '-sticky-header-2';
			tempElem.className = 'cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only';
			// tempElem.className = "cdx-button cdx-button--weight-quiet mw-interlanguage-selector"
			tempElem.children[0].remove();
			$(stickyIconList).append(tempElem);
		}
	}
}
//</nowiki>[[Category:Wikipedia scripts]]