Benutzer:Lustiger seth/editsection0.js
Erscheinungsbild
Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
//testing edit section 0
// orig script: http://de.wikipedia.org/wiki/MediaWiki_Diskussion:Gadget-Einleitung-bearbeiten.js
// this version is modified, because of 1. lang=en; 2. insert button _behind_ heading
if(wgIsArticle){
addOnloadHook(function (){
// Neither run on fully-protected pages (which lack ca-edit) nor modify the same page twice
if((document.getElementById("ca-edit") == null) ||
(document.getElementById('firstsectionedit') !== null)){
return;
}
// if there are no edit-section links then stop
var spans = document.getElementsByTagName("span");
var exists_edit_section = 0;
var editsection_title = 'edit';
var editsection_tooltip = 'Edit section: Introduction';
for(var i = 0 ; i < spans.length && exists_edit_section == 0; ++i) {
if (spans[i].className === 'editsection') {
exists_edit_section = 1;
alert(spans[i]);
alert(spans[i].nodeValue);
alert(spans[i].firstChild);
alert(spans[i].firstChild.nodeValue);
alert(spans[i].title);
editsection_title = spans[i].nodeValue;
editsection_tooltip = spans[i].title.substring(0, spans[i].title.indexOf(":")-1)+" 0";
}
}
if(exists_edit_section == 1){
// get first header element
var fst_h1 = document.getElementById("firstHeading");
// Creating elements
// create span
var span = document.createElement("SPAN");
span.className = 'editsection';
span.id = 'firstsectionedit';
// create link
var link = document.createElement("A");
link.href = document.getElementById("ca-edit").getElementsByTagName("a")[0].href + '§ion=0';
link.title = editsection_tooltip;
link.appendChild(document.createTextNode(editsection_title));
// append link and stuff to span
span.appendChild(document.createTextNode('['));
span.appendChild(link);
span.appendChild(document.createTextNode(']'));
// Insert span container into the DOM before the </h1>
fst_h1.appendChild(document.createTextNode(" "));
fst_h1.appendChild(span);
}
});
}