Jump to content

User:Terasail/ArticleInfo.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Terasail (talk | contribs) at 15:10, 25 February 2023 (Update: Improve icon loading & Fix sticky header). 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
*/
//jshint esversion: 6

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 = 3; i < headerIcons.length; i++) {//Remove icons after notification buttons
		headerIcons[i].remove();
	}
	let userLinks = $("#p-personal .mw-list-item");
	for (let i = 1; i < userLinks.length; i++) {
		let tempElem = userLinks[i].cloneNode(true);
		let elemIcon = tempElem.children[0].children[0];
		tempElem.id = userLinks[i].id + '-2';
		tempElem.className = 'user-links-collapsible-item mw-list-item';
		tempElem.children[0].className = 'mw-ui-button mw-ui-quiet mw-ui-icon-element ' + elemIcon.className;
		elemIcon.remove();
		$(headerIconList).append(tempElem);
	}

	//Sticky header
	if ($('#vector-sticky-header').length !== 0) {//Check for sticky header
		$('<div id="sticky-user-menu-overflow" class="vector-sticky-header-icons"></div>').insertBefore(".vector-sticky-header-icon-end");
		let stickyIconList = $("#sticky-user-menu-overflow");
		let userLinks = $("#p-personal-sticky-header .mw-list-item");
		for (let i = 0; i < userLinks.length; i++) {
			let tempElem = userLinks[i].children[0].cloneNode(true);
			let elemIcon = tempElem.children[0];
			tempElem.id = userLinks[i].id + '-2';
			//tempElem.className = 'user-links-collapsible-item mw-list-item';
			tempElem.className = 'mw-ui-button mw-ui-quiet mw-ui-icon-element ' + elemIcon.className;
			elemIcon.remove();
			$(stickyIconList).append(tempElem);
		}
	}
}
//</nowiki>[[Category:Wikipedia scripts]]