Zum Inhalt springen

„Benutzer:Lustiger seth/left menu adaptions.js“ – Versionsunterschied

aus Wikipedia, der freien Enzyklopädie
Inhalt gelöscht Inhalt hinzugefügt
fixed check for existence
check for existence before deletion
Zeile 4: Zeile 4:
*/
*/
$(function (){
$(function (){
function remove_item(id){
if(document.getElementById(id) !== null){
document.getElementById(id).remove();
}
}

if(document.getElementById("n-mainpage-description") !== null){
if(document.getElementById("n-mainpage-description") !== null){
document.getElementById("n-mainpage-description").replaceWith(
document.getElementById("n-mainpage-description").replaceWith(
Zeile 9: Zeile 15:
);
);
}
}
document.getElementById("p-Mitmachen").remove(); // "participate"
remove_item("p-Mitmachen") // "participate"
// the previous command includes the following
// the previous command includes the following
//document.getElementById("n-Artikel-verbessern").remove(); // "improve articles"
//remove_item("n-Artikel-verbessern"); // "improve articles"
//document.getElementById("n-Neuerartikel").remove(); // "create article"
//remove_item("n-Neuerartikel"); // "create article"
//document.getElementById("n-portal").remove(); // "community portal"
//remove_item("n-portal"); // "community portal"
//document.getElementById("n-help").remove();
//remove_item("n-help");
//document.getElementById("n-contact").remove();
//remove_item("n-contact");
//document.getElementById("n-sitesupport").remove(); // "donate"
//remove_item("n-sitesupport"); // "donate"
// delete "switch to old look"
// delete "switch to old look"
const mw_panel_children = document.getElementById("mw-panel").children;
const mw_panel_children = document.getElementById("mw-panel").children;

Version vom 13. Februar 2022, 13:31 Uhr

/*
task: delete items from the left hand side menu that i don't use
tested in firefox only
*/
$(function (){
	function remove_item(id){
		if(document.getElementById(id) !== null){
			document.getElementById(id).remove();
		}
	}

	if(document.getElementById("n-mainpage-description") !== null){
		document.getElementById("n-mainpage-description").replaceWith(
			document.getElementById("n-recentchanges")
		);
	}
	remove_item("p-Mitmachen") // "participate"
	// the previous command includes the following
	//remove_item("n-Artikel-verbessern"); // "improve articles"
	//remove_item("n-Neuerartikel"); // "create article"
	//remove_item("n-portal"); // "community portal"
	//remove_item("n-help");
	//remove_item("n-contact");
	//remove_item("n-sitesupport"); // "donate"
	// delete "switch to old look"
	const mw_panel_children = document.getElementById("mw-panel").children;
	for(let i = 0; i < mw_panel_children.length; ++i){
		const elem_content = mw_panel_children[i].innerHTML;
		if(elem_content.includes("Switch to old look") 
			|| elem_content.includes("Language")
		){
			mw_panel_children[i].remove();
		}
	}
	// this needs a time-out, because the link is loaded delayed
	setTimeout(function(){
		if(document.getElementById("t-wikibase") !== null){
			const tools_children = document.getElementById("t-wikibase").parentNode.children;
			for(let i = 0; i < tools_children.length; ++i){
				const elem_content = tools_children[i].innerHTML;
				if(elem_content.includes("Edit interlanguage links")){
					tools_children[i].remove();
				}
			}
		}
	}, 1000);
});