User:ReneRomann/monobook.js

/* Top of Javascript */ //"Unedit red links" by Stefan Majewsky. If clicking on red links, not the edit window, but the empty article will be opened. //(useful if you often view deleted pages with your sysop rights)

function cutOffEditParameter(link) { var index = link.href.indexOf('&action=edit'); if (index > 0) { link.href = link.href.slice(0, index); //cut off '&action=edit' } return link; }

function unEditRedLinks{ var links = document.getElementsByTagName('a'); for(var i1 = 0; i1 < links.length; i1++) { //walk through all links if (links[i1].getAttribute('class') == 'new') { //is red link? links[i1] = cutOffEditParameter(links[i1]); } }  var listitems = document.getElementsByTagName('li'); for (var i2 = 0; i2 < listitems.length; i2++) { //walk through all list items if (listitems[i2].getAttribute('class') == 'new') { //is red list item? var listlinks = listitems[i2].getElementsByTagName('a'); for (var i3 = 0; i3 < listlinks.length; i3++) { //walk through all links in the list item listlinks[i3] = cutOffEditParameter(listlinks[i3]); }   }  } }

$(unEditRedLinks);

// End of "unedit red links".

//Monobook Element Modding. Techniques by Stefan Majewsky (de.wikibooks.org/wiki/Benutzer:Stefan_Majewsky) //Based on http://commons.wikimedia.org/w/index.php?title=MediaWiki:Extra-tabs.js&oldid=3001654

//Creates a new list item. function createListItem(url, name, id) { var listitem = document.createElement('li'); listitem.setAttribute('id', id); var link = document.createElement('a'); if (url!='') {     link.setAttribute('href', url); } else {   listitem.setAttribute('class','selected'); } link.appendChild(document.createTextNode(name)); listitem.appendChild(link); return listitem; }

//Appends a new tab to the register at the top of a page. function appendTab(url, name, id) { // Grab the element we want to append the tab and append the tab to it. var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0]; tabs.appendChild(createListItem(url, name, id)); }

//Appends the into tab near the "Edit" tab. function appendIntroTab(articlename) { // Grab the element we want to append the tab and append the tab to it. var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0]; tabs.insertBefore(createListItem('http://en.wikipedia.org/w/index.php?title=' + articlename + '&action=edit&section=0', 'intro', 'ca-editintro'), tabs.getElementsByTagName('li')[3]); }

//Adds supplementary links to the personal bar at the top right. function appendPLink(url, name, id) { // Insert the element before the "log out" link. var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[1].getElementsByTagName('ul')[0]; tabs.insertBefore(createListItem(url, name, id), document.getElementById('pt-logout')); }

//Adds a supplementary menu at the left navigation. Returns the list where links have to be added. function appendMenu(title, id) { //initialize the single elements var basediv = document.createElement('div'); basediv.setAttribute('class','portlet'); basediv.setAttribute('id',id); var heading = document.createElement('h5'); heading.appendChild(document.createTextNode(title)); var innerdiv = document.createElement('div'); innerdiv.setAttribute('class','pBody'); var linklist = document.createElement('ul'); //ONLY FOR PERSONAL PURPOSE - change the background color of the menu innerdiv.setAttribute('style','background-color: #E2E2F9'); //build menu basediv.appendChild(heading); basediv.appendChild(innerdiv); innerdiv.appendChild(linklist); //insert in column-one after p-tb document.getElementById('column-one').insertBefore(basediv, document.getElementById('p-tb').nextSibling); return linklist; }

//Adds a menu item to a menu. function addMenuItem(menu, link, text, id) { var listitem = document.createElement('li'); listitem.setAttribute('id',id); var linkitem = document.createElement('a'); linkitem.setAttribute('href',link); //build link linkitem.appendChild(document.createTextNode(text)); listitem.appendChild(linkitem); menu.appendChild(listitem); }

//Adds a horizontal separator to a menu. function addMenuSep(menu) { menu.appendChild(document.createElement('hr')); }

//(On special pages) Change the caption of the tab "Special page". function changeSpecialPageCaption(newname) { document.getElementById('ca-nstab-special').getElementsByTagName('a')[0].innerHTML = newname; }

//Rename all special pages. function changeSpecialPageCaptions { switch(wgTitle) {   case 'Ancientpages': changeSpecialPageCaption('Am längsten unbearbeitete Seiten'); break; case 'Allmessages': changeSpecialPageCaption('Systemnachrichten'); break; case 'Allpages': changeSpecialPageCaption('Seitenverzeichnis'); break; case 'Boardvote': changeSpecialPageCaption('Wahlen zum Wikimedia-Kuratorium'); break; case 'Booksources': changeSpecialPageCaption('Buchquellen'); break; case 'BrokenRedirects': changeSpecialPageCaption('Kaputte Weiterleitungen'); break; case 'Categories': changeSpecialPageCaption('Kategorienverzeichnis'); break; case 'CategoryTree': changeSpecialPageCaption('Kategoriebaum'); break; case 'CrossNamespaceLinks': changeSpecialPageCaption('Links zwischen Namensräumen'); break; case 'Deadendpages': changeSpecialPageCaption('Sackgassenseiten'); break; case 'Disambiguations': changeSpecialPageCaption('Begriffsklärungsseiten'); break; case 'ExpandTemplates': changeSpecialPageCaption('Vorlagenexpandierung'); break; case 'Export': changeSpecialPageCaption('Seitenexport'); break; case 'DoubleRedirects': changeSpecialPageCaption('Kettenweiterleitungen'); break; case 'Filepath': changeSpecialPageCaption('Dateipfadermittlung'); break; case 'Imagelist': changeSpecialPageCaption('Dateiverzeichnis'); break; case 'Ipblocklist': changeSpecialPageCaption('Gesperrte IPs und Benutzer'); break; case 'Log': changeSpecialPageCaption('Logbücher'); break; case 'Lonelypages': changeSpecialPageCaption('Verwaiste Seiten'); break; case 'Longpages': changeSpecialPageCaption('Längste Seiten'); break; case 'Linksearch': changeSpecialPageCaption('Weblinksuche'); break; case 'Listredirects': changeSpecialPageCaption('Weiterleitungsverzeichnis'); break; case 'Listusers': changeSpecialPageCaption('Benutzerverzeichnis'); break; case 'MIMEsearch': changeSpecialPageCaption('Suche nach MIME-Typ'); break; case 'Mostcategories': changeSpecialPageCaption('Meist benutzte Kategorien'); break; case 'Mostimages': changeSpecialPageCaption('Meist benutzte Bilder'); break; case 'Mostlinked': changeSpecialPageCaption('Meiste Verweise'); break; case 'Mostrevisions': changeSpecialPageCaption('Meiste Seitenversionen'); break; case 'Newimages': changeSpecialPageCaption('Neueste Bilder'); break; case 'Newpages': changeSpecialPageCaption('Neueste Seiten'); break; //case 'Preferences': changeSpecialPageCaption('Einstellungen'); break; case 'Prefixindex': changeSpecialPageCaption('Unterseiten'); break; case 'Randompage': changeSpecialPageCaption('Zufällige Seite'); break; case 'Randomredirect': changeSpecialPageCaption('Zufällige Weiterleitung'); break; case 'Recentchanges': changeSpecialPageCaption('Letzte Änderungen'); break; case 'Search': changeSpecialPageCaption('Seitensuche'); break; case 'Shortpages': changeSpecialPageCaption('Kürzeste Seiten'); break; case 'SiteMatrix': changeSpecialPageCaption('Wikimatrix'); break; case 'Specialpages': changeSpecialPageCaption('Spezialseitenverzeichnis'); break; case 'Statistics': changeSpecialPageCaption('Statistiken'); break; case 'Uncategorizedcategories': changeSpecialPageCaption('Nicht kategorisierte Kategorien'); break; case 'Uncategorizedimages': changeSpecialPageCaption('Nicht kategorisierte Bilder'); break; case 'Uncategorizedpages': changeSpecialPageCaption('Nicht kategorisierte Seiten'); break; case 'Unusedcategories': changeSpecialPageCaption('Nicht benutzte Kategorien'); break; case 'Unusedimages': changeSpecialPageCaption('Nicht benutzte Bilder'); break; case 'Unusedtemplates': changeSpecialPageCaption('Nicht verwendete Vorlagen'); break; case 'Upload': changeSpecialPageCaption('Hochladen'); break; case 'Userlogin': changeSpecialPageCaption('Anmeldung'); break; case 'Version': changeSpecialPageCaption('Systemversionsinformationen'); break; case 'Watchlist': changeSpecialPageCaption('Beobachtungsliste'); break; case 'Wantedcategories': changeSpecialPageCaption('Gewünschte Kategorien'); break; case 'Wantedpages': changeSpecialPageCaption('Gewünschte Seiten'); break; } }

//Onload hook. Will be executed after the site has been loaded. function doMonobookTuningOnload { //append tabs if(wgNamespaceNumber == -1) {   //change the captions (makes h1.firstHeading obsolete which is removed by my css) changeSpecialPageCaptions; } else {   //add extra tabs appendTab('http://en.wikipedia.org/wiki/Special:Prefixindex/' + wgPageName, 'Unterseiten', 'ca-subpage'); appendTab('http://en.wikipedia.org/wiki/Special:Allpages/' + wgPageName, 'Index durchsuchen', 'ca-searchindex'); appendTab('http://ee.wikipedia.org/w/index.php?title=' + wgPageName + '&action=purge', 'Cache leeren', 'ca-purge'); appendIntroTab(wgPageName); } //append personal links appendPLink('http://en.wikipedia.org/wiki/Special:Mypage/monobook.css','CSS','pt-css'); appendPLink('http://en.wikipedia.org/wiki/Special:Mypage/monobook.js','JS','pt-js'); //change tab titles - adapted from Benutzer:PDD/changeBeschriftungen.js var cbiid, cbielement; var cbliste = { "ca-edit":    ["A",  "Edit"], "ca-history": ["A",  "Historie"], "ca-unwatch": ["A",  "Entobachten"] }; for (cbiid in cbliste) { if (cbielement = document.getElementById(cbiid)) { cbielement.getElementsByTagName(cbliste[cbiid][0])[0].innerHTML = cbliste[cbiid][1]; } } }

//Onload control. $(doMonobookTuningOnload);

//End of Monobook Element Modding.

// User:Lupin/popups.js mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js&action=raw&ctype=text/javascript');

//Twinkle-Support für erw. Bearbeitung importScript('User:AzaToth/twinkle.js');

/* Bottom of Javascript */