User:Jlorenz1/monobook.js


 * /**** Define shortcut function for adding scripts ****/

function winc(s) {   s = s.replace(/^\[\[/, ).replace(/\]\]$/, ); document.write('<\/script>'); }

/**** Include common functions ****/

winc("User:Alphax/common-functions.js");

/**** Move tabs into their own drop-down menu ****/

winc("User:Alphax/move-tabs.js");

/**** Add navigation popups ****/

// User:Lupin/popups.js - please include this line

document.write('<\/script>');

// customisations = see wikipedia:Wikipedia:Tools/Navigation popups for more

popupStructure = 'menus'; popupAdminLinks = true; popupFixRedirs = true; popupRevertSummaryPrompt = true; popupDragHandle = 'popupTopLinks';

/**** Add "toggle" button to undelete pages - from w:User:Cryptic/toggleundelete.js ****/

winc("User:Alphax/toggleundelete.js");

/**** Quick-delete - see MediaWiki talk:Quick-delete.js ****/

winc("MediaWiki:Quick-delete.js");

// Custom development version

//~ winc("User:Alphax/qd-merged.js"); // while testing nfd_autosave = false; mnx_autosave = false; //~ mcv_autosave = false; //~ spd_autosave = false;

/**** Image dimension checker ****/ winc("User:Nux/dimcheck_n_title.js");

/**** Wikimedia Logomosaic counts ****/ winc("User:Nux/mosaic counter.js");

$( function {    // &action=purge    addPurge;    // &section=0    addEditSection0;    // cause the personal menu looks bad    changeLinks;    // and some stuff for the sidebar    addToolBoxLinks;    // add other stuff    morelinks;    // change the title of the edit link    ta['ca-edit'] = ['e', 'Edit page'];    // remove the logout button    document.getElementById("pt-logout").parentNode.removeChild(document.getElementById("pt-logout"));    // re-render the title and accesskeys for stuff    akeytt; } );

/**** Add purge tab ****/

function addPurge {   ta['ca-purge'] = ['g', 'Purge the internal cache for this page']; if(!document.getElementById) return; var x = document.getElementById('ca-history'); if(!x) { return; } // if it doesn't have a history tab, it's not purgable var tabs = x.parentNode; if(x.children) { x = x.children[0]; } else { x = x.childNodes[0]; } addlilink(tabs, x.href.replace(/=history/, "=purge"), 'purge', 'ca-purge'); }

/**** Add generic tab - now in common-functions.js ****/

/* function addlilink(tabs, url, name, id) {   var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.id = id; li.appendChild(na); tabs.appendChild(li); return li; }

/**** Edit section 0 ****/

function addEditSection0 {   ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page']; if(!document.getElementById) return; var x = document.getElementById('ca-edit'); if(!x) return; var y = document.createElement('LI'); y.id = 'ca-edit-0'; if(x.className == 'selected'){ if(/&action=edit&section=0$/.test(window.location.href)){ x.className = 'istalk'; y.className = 'selected'; } else { x.className = 'selected istalk'; }   } else if(x.className == 'selected istalk'){ if(/&action=edit&section=0$/.test(window.location.href)){ x.className = 'istalk'; y.className = 'selected istalk'; } else { y.className = 'istalk'; }   } else { y.className = x.className; x.className = 'istalk'; }   var z = document.createElement('A'); if(x.children){ z.href = x.children[0].href + '&section=0'; z.appendChild(document.createTextNode('0')); y.appendChild(z); document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling); }else{ z.href = x.childNodes[0].href + '&section=0'; z.appendChild(document.createTextNode('0')); y.appendChild(z); document.getElementById('p-cactions').getElementsByTagName("ul")[0].insertBefore(y,x.nextSibling); } }

/**** Make the top links look better ****/

function changeLinks {   if(!document.getElementById) return; // remove the "my" bits document.getElementById('pt-mytalk').firstChild.innerHTML = 'talk'; document.getElementById('pt-preferences').firstChild.innerHTML = 'preferences'; document.getElementById('pt-watchlist').firstChild.innerHTML = 'watchlist'; document.getElementById('pt-mycontris').firstChild.innerHTML = 'contributions'; // add a clock var toplinks = document.getElementById('p-personal').getElementsByTagName('ul')[0]; addlilink(toplinks, '#', '', 'utcdate'); showtime; }

/**** Get a clock that autoupdates! ****/

function showtime {   var timerID; var now = new Date; var timeValue = now.toUTCString.replace(/GMT/, "UTC"); document.getElementById('utcdate').firstChild.innerHTML = timeValue; timerID = setTimeout('showtime', 100); }

/**** Add links to the toolbox ****/

function addToolBoxLinks {   var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; var logs = addlilink(tb, "/wiki/Special:Log", "L"); var dot = document.createTextNode(" · "); var log_u = document.createElement('a').appendChild(document.createTextNode("u")).parentNode; log_u.href = "/wiki/Special:Log/upload"; logs.appendChild(dot.cloneNode(false)).parentNode.appendChild(log_u); var log_d = document.createElement('a').appendChild(document.createTextNode("d")).parentNode; log_d.href = "/wiki/Special:Log/delete"; logs.appendChild(dot.cloneNode(false)).parentNode.appendChild(log_d); var log_b = document.createElement('a').appendChild(document.createTextNode("b")).parentNode; log_b.href = "/wiki/Special:Log/block"; logs.appendChild(dot.cloneNode(false)).parentNode.appendChild(log_b); var log_p = document.createElement('a').appendChild(document.createTextNode("p")).parentNode; log_p.href = "/wiki/Special:Log/protect"; logs.appendChild(dot.cloneNode(false)).parentNode.appendChild(log_p); var log_m = document.createElement('a').appendChild(document.createTextNode("m")).parentNode; log_m.href = "/wiki/Special:Log/move"; logs.appendChild(dot.cloneNode(false)).parentNode.appendChild(log_m); var log_cu = document.createElement('a').appendChild(document.createTextNode("cu")).parentNode; log_cu.href = "/wiki/Special:CheckUser?log=1"; logs.appendChild(dot.cloneNode(false)).parentNode.appendChild(log_cu); var monobook = addlilink(tb, '/wiki/User:Alphax/monobook.js', 'monobook.js'); var rawlink = document.createElement('a'); rawlink.appendChild(document.createTextNode("raw")); rawlink.href = "/w/index.php?title=User:Alphax/monobook.js&action=raw&ctype=text/javascript&dontcountme=s"; monobook.appendChild(dot.cloneNode(false)).parentNode.appendChild(rawlink); }

/** add other stuff **/

function morelinks {   var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; if(document.title.indexOf("Editing Commons:Deletion requests") == 0) {       addlilink(tabs, 'javascript:closedel(prompt("Result?"))', 'close deletion request', ''); } }

// function closedel(result) {   var txt = document.editform.wpTextbox1; txt.value = "\n" + txt.value + "\n\n" + result + " – ~\n\n"; txt = document.editform.wpSummary; txt.value = "close discussion"; } //

// Autolink wikilinks and {templates} (especially useful for monobook.js and similar pages) // From wikipedia:Wikipedia:WikiProject User scripts/Scripts/Autolink, by w:User:Omegatron

$(function {    // Ignore special pages entirely, images because it screws up metadata, and Templates because... well, because    if((wgNamespaceNumber == -1) || (wgNamespaceNumber == 6) || (wgNamespaceNumber == 10))    {        return;    }    // Get the HTML of just the main body of the page, not including textareas hopefully    if (document.getElementById("wpTextbox1") == null && getParamValue("action") != "delete") {        targetdiv = document.getElementById('bodyContent');  // bodyContent div for most pages    } else     if (document.getElementById('wikiPreview')) {        targetdiv = document.getElementById('wikiPreview');  // wikiPreview if it's there    } else    if (document.getElementById('wikiDiff')) {        targetdiv = document.getElementById('wikiDiff');   // wikiDiff if it's there    } else {        return;    }    content = targetdiv.innerHTML;    content = content.replace(/([^\[])\[{2}([^\[\]\|\<\>\n]*)([^\[\]\<\>\n]*?)?\]{2}([^\]])/g, '$1$2$3$4'); // Make wikilink code into links content = content.replace(/([^\{])\{{2}(subst\:|msg\:)?([^\{\}\|\<\>\n]*)([^\{\}\<\>\n]*?)?\}{2}([^\}])/g, '$1\{\{$2$3$4\}\}$5'); // Make template code into links targetdiv.innerHTML = content; // Write it back }); Von „http://commons.wikimedia.org/wiki/User:Alphax/monobook.js“