Jump to content

User:Terasail/HeaderIcons.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Terasail (talk | contribs) at 16:32, 1 August 2023 (Update sticky header icon parent). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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>
	HeaderIcons.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';
		$(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';
			$(stickyIconList).prepend(tempElem);
		}
	}
}
//</nowiki>[[Category:Wikipedia scripts]]