User:Bookofjude/monobook.js
Jump to navigation
Jump to search
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Clear the cache in Tools → Preferences
For details and instructions about other browsers, see Wikipedia:Bypass your cache.
Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the central discussion page, Scriptorium. The code will be executed when previewing this page under some skins, including Monobook. You can in the interim if you wish to refresh the content sooner under another skin. |
The accompanying .css page for this skin is at User:Bookofjude/monobook.css. |
/* <pre><nowiki> */
/**
* [[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 = "{{subst:Dated soft redirect|"+r+"}}";
var summary = document.editform.wpSummary;
summary.value = "Converted to soft redirect";
}
function addHeader() {
var txt = document.getElementById('wpTextbox1');
txt.value = "{{header\n"
+" | title = {{subst:PAGENAME}}\n"
+" | author = \n"
+" | section = \n"
+" | previous = \n"
+" | next = \n"
+" | notes = \n"
+"}}\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;
};
/* </nowiki></pre> */