User:Bookofjude/monobook.js

/* */ /** * User:Bookofjude's monobook.js, based on primarily on User:Wayward's,  * which in turn is based on User:Alphax/monobook.js's * with many of User:Wayward's own mods * Must use User:Wayward/monobook.css for full tab functionality * Forked from User:ABCD/monobook.js around April 2005 * Dual licensed under the GFDL and GPL * See also: User:JesseW/monobook.js * And best of all: WP:US **/ $(function {   var scriptlink = document.getElementById('n-scriptorium');    if (!scriptlink) return;    while (scriptlink.firstChild) {        scriptlink.removeChild(scriptlink.firstChild);    }    y = document.createElement('a');    y.setAttribute('href', 'http://en.wikisource.org/wiki/Wikisource:Scriptorium');    y.appendChild(document.createTextNode('Scriptorium'));    scriptlink.appendChild(y);    mw.util.addPortletLink('p-caction',wgScript + '?title=' + encodeURIComponent(mw.config.get('wgPageName')) + '&action=purge','purge')

if(queryString("submitdelete")=="true") document.forms[0].wpConfirmB.click;

mw.util.addPortletLink('p-navigation', "http://en.wikisource.org/wiki/Wikisource:Possible_copyright_violations", "WS:COPYVIO"); mw.util.addPortletLink('p-navigation', "http://en.wikisource.org/wiki/Wikisource:Proposed_deletions", "WS:PD"); if(document.forms.editform) { mw.util.addPortletLink('p-cactions', 'javascript:softRedirect;', 'soft redirect', 'ca-redirect', 'Replace a redirect with a soft redirect'); mw.util.addPortletLink('p-cactions', 'javascript:replace("\\n([^\\n])", " $1");', 'r1', 'ca-r2', 'Deal with weird line-endings.'); mw.util.addPortletLink('p-cactions', 'javascript:replace', 'replace', 'ca-replace', 'Regexp replace for the edit window', '', document.getElementById('ca-history')); mw.util.addPortletLink('p-cactions', 'javascript:addHeader', 'header', 'ca-header', 'Add a blank header', '', document.getElementById('ca-summary')); } });

function softRedirect{ var txt = document.editform.wpTextbox1; var r = txt.value.replace(new RegExp("[\\S\\s]*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt][_ ]?(\\[\\^\\*\\]\\])[\\S\\s]*|[\\s\\S]*", "g"), "$1"); if (r==""){ var r = ""+prompt('What page should the redirect point to?')+""; }   txt.value = ""+r+""; var summary = document.editform.wpSummary; summary.value = "Converted to soft redirect"; }

function addHeader { var txt = document.getElementById('wpTextbox1'); txt.value = "\n"+txt.value; } function getPname{ z=document.getElementById("content").childNodes; for (var n=0;n<z.length;n++) { if (z[n].className=="firstHeading") return z[n].textContent; }; }

function getUname { return document.URL.match(/:.*:(.*)/)[1]; }

function replace(s, r) { if (!s) { var s = prompt("Search regexp?"); } if(s) { if (!r) { var r = prompt("Replace regexp?"); } if(!r && r != '') return; var txt = document.editform.wpTextbox1; txt.value = txt.value.replace(new RegExp(s, "g"), r); } }

function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { }   }    return null; };

/* */