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 15:16, 9 December 2022 (Different element check). 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

//Static header
let topDropElems = document.getElementById("pt-preferences").parentElement.children;
for (let i = 0; i < topDropElems.length; i++) {
	let curElem = topDropElems[i];
	if (curElem.id != "pt-watchlist" && curElem.id != "pt-userpage") {
		let tempElem = curElem.cloneNode(true).children[0];
		tempElem.className = "mw-ui-button mw-ui-quiet mw-ui-icon-element " + tempElem.children[0].className;
		tempElem.innerHTML = "";
		tempElem = tempElem.parentElement;
		tempElem.id = "";
		$(document.getElementById("pt-userpage-2").parentElement).append(tempElem);
	}
}

//Sticky header
let stkyDropElems = document.getElementById("pt-preferences-sticky-header");
if (stkyDropElems != null) {//Check for sticky header
	stkyDropElems = stkyDropElems.parentElement.children;
	for (let i = stkyDropElems.length - 1; i >= 0; i--) {
		let tempElem = stkyDropElems[i].cloneNode(true).children[0];
		tempElem.className = "mw-ui-button mw-ui-quiet mw-ui-icon-element " + tempElem.children[0].className;
		tempElem.innerHTML = "";
		let ppStkyHeader = document.getElementById("p-personal-sticky-header").parentElement;
		ppStkyHeader.className = "vector-sticky-header-icons " + ppStkyHeader.className;
		$(ppStkyHeader).prepend(tempElem);
	}
}
//</nowiki>[[Category:Wikipedia scripts]]