User:Rich Farmbrough/monobook.js
Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.
- Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
- Konqueror and Chrome: click Reload or press F5;
- Opera: clear the cache in Tools → Preferences;
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.
- This script lacks a documentation subpage. You may create it.
- Useful links: root page • root page’s subpages • links • redirects • your own
This JavaScript is executed for Rich Farmbrough on every page load, when User:Rich Farmbrough is using the Monobook skin.
/* <nowiki> */
function closeafd(bold, notbold){
var txt = document.editform.wpTextbox1;
txt.value = "{{subst:vt}} '''" + bold + "'''" + notbold + ". – ~~~~\n" + txt.value + "\n{{subst:vb}}\n";
txt = document.editform.wpSummary;
txt.value = "close discussion: " + bold + notbold;
document.editform.wpWatchthis.checked = false;
}
function replace(){
var s = prompt("Search reg exp?");
if(s){
var r = prompt("Replace reg exp?");
var txt = document.editform.wpTextbox1;
txt.value = txt.value.replace(new RegExp(s, "g"), r);
}
}
function spelling(){
var txt = document.editform.wpTextbox1;
txt.value = txt.value.replace(/civilise/m, "civilize");
txt.value = txt.value.replace(/ciunas/m, "ciúnas");
txt.value = txt.value.replace(/clamour/m, "clamor");
txt.value = txt.value.replace(/clear-cut/m, "clear cut");
txt.value = txt.value.replace(/cliche/m, "cliché");
txt.value = txt.value.replace(/client/server/m, "client-server");
txt.value = txt.value.replace(/cloath/m, "clothes");
txt.value = txt.value.replace(/cockadoodledoo/m, "cock-a-doodle-doo");
txt.value = txt.value.replace(/cock and bull story/m, "cock-and-bull story");
txt.value = txt.value.replace(/codes of practice/m, "code of practice");
txt.value = txt.value.replace(/code talker/m, "codetalker");
txt.value = txt.value.replace(/coerced/m, "coerce");
txt.value = txt.value.replace(/coercing/m, "coerce");
txt.value = txt.value.replace(/colonies/m, "colony");
txt.value = txt.value.replace(/combining/m, "combine");
txt.value = txt.value.replace(/combined/m, "combine");
txt.value = txt.value.replace(/coming/m, "come");
txt.value = txt.value.replace(/coming out of the woodwork/m, "come out of the woodwork");
txt.value = txt.value.replace(/commemorating/m, "commemorate");
txt.value = txt.value.replace(/transwiki:Commercial off-the-shelf/m, "commercial off-the-shelf");
txt.value = txt.value.replace(/committed/m, "commit");
txt.value = txt.value.replace(/communities/m, "community");
txt.value = txt.value.replace(/commuted/m, "commute");
txt.value = txt.value.replace(/companies/m, "company");
txt.value = txt.value.replace(/compar./m, "comparative");
txt.value = txt.value.replace(/comparing/m, "compare");
txt.value = txt.value.replace(/compared/m, "compare");
txt.value = txt.value.replace(/compelled/m, "compel");
txt.value = txt.value.replace(/complementary angle/m, "complementary angles");
txt.value = txt.value.replace(/completed/m, "complete");
txt.value = txt.value.replace(/completing/m, "complete");
txt.value = txt.value.replace(/composed/m, "compose");
txt.value = txt.value.replace(/transwiki:Compromise/m, "compromise");
document.forms.editform.wpSummary.value="Un-double redirect";
}
function decomma(){
var txt = document.editform.wpTextbox1;
txt.value = txt.value.replace(/([A-Z])([A-Z]+),(?: )*([\w,\. ]+)/g,"$3 $1"+ ("$2".toLowerCase()));
document.forms.editform.wpSummary.value=document.forms.editform.wpSummary.value + "Reverse and decomma names. ";
}
function bold(){
var txt = document.editform.wpTextbox1;
/* var title = document.title.value;
txt.value = txt.value.replace(/\<\/b\>/gim, "'''");
*/
txt.value = txt.value.replace(/\<\/b\>/gim, "'''");
txt.value = txt.value.replace(/\<\/i\>/gim, "''");
txt.value = txt.value.replace(/\<b\>/gim, "'''");
txt.value = txt.value.replace(/\<i\>/gim, "''");
document.forms.editform.wpSummary.value=document.forms.editform.wpSummary.value+"Bold/Italics";
}
function capitals(){
var txt = document.editform.wpTextbox1;
txt.value = txt.value.replace(/([\.|\n]) a/gm, "$1 A");
txt.value = txt.value.replace(/([\.|\n]) b/gm, "$1 B");
txt.value = txt.value.replace(/([\.|\n]) c/gm, "$1 C");
txt.value = txt.value.replace(/([\.|\n]) d/gm, "$1 D");
txt.value = txt.value.replace(/([\.|\n]) e/gm, "$1 E");
txt.value = txt.value.replace(/([\.|\n]) f/gm, "$1 F");
txt.value = txt.value.replace(/([\.|\n]) g/gm, "$1 G");
txt.value = txt.value.replace(/([\.|\n]) h/gm, "$1 H");
txt.value = txt.value.replace(/([\.|\n]) i/gm, "$1 I");
txt.value = txt.value.replace(/([\.|\n]) j/gm, "$1 J");
txt.value = txt.value.replace(/([\.|\n]) k/gm, "$1 K");
txt.value = txt.value.replace(/([\.|\n]) l/gm, "$1 L");
txt.value = txt.value.replace(/([\.|\n]) m/gm, "$1 M");
txt.value = txt.value.replace(/([\.|\n]) n/gm, "$1 N");
txt.value = txt.value.replace(/([\.|\n]) o/gm, "$1 O");
txt.value = txt.value.replace(/([\.|\n]) p/gm, "$1 P");
txt.value = txt.value.replace(/([\.|\n]) q/gm, "$1 Q");
txt.value = txt.value.replace(/([\.|\n]) r/gm, "$1 R");
txt.value = txt.value.replace(/([\.|\n]) s/gm, "$1 S");
txt.value = txt.value.replace(/([\.|\n]) t/gm, "$1 T");
txt.value = txt.value.replace(/([\.|\n]) u/gm, "$1 U");
txt.value = txt.value.replace(/([\.|\n]) v/gm, "$1 V");
txt.value = txt.value.replace(/([\.|\n]) w/gm, "$1 W");
txt.value = txt.value.replace(/([\.|\n]) x/gm, "$1 X");
txt.value = txt.value.replace(/([\.|\n]) y/gm, "$1 Y");
txt.value = txt.value.replace(/([\.|\n]) z/gm, "$1 Z");
document.forms.editform.wpSummary.value+=" Caps";
}
function cardinals(){
var txt = document.editform.wpTextbox1;
txt.value = txt.value.replace(/ 10( |\. |\, )/gm, " ten$1");
txt.value = txt.value.replace(/ 11( |\. |\, )/gm, " eleven$1");
txt.value = txt.value.replace(/ 12( |\. |\, )/gm, " twelve$1");
txt.value = txt.value.replace(/ 13( |\. |\, )/gm, " thirteen$1");
txt.value = txt.value.replace(/ 14( |\. |\, )/gm, " fourteen$1");
txt.value = txt.value.replace(/ 15( |\. |\, )/gm, " fifteen$1");
txt.value = txt.value.replace(/ 16( |\. |\, )/gm, " sixteen$1");
txt.value = txt.value.replace(/ 17( |\. |\, )/gm, " seventeen$1");
txt.value = txt.value.replace(/ 18( |\. |\, )/gm, " eighteen$1");
txt.value = txt.value.replace(/ 19( |\. |\, )/gm, " nineteen$1");
txt.value = txt.value.replace(/ 20( |\. |\, )/gm, " twenty$1");
txt.value = txt.value.replace(/ 30( |\. |\, )/gm, " thirty$1");
txt.value = txt.value.replace(/ 40( |\. |\, )/gm, " forty$1");
txt.value = txt.value.replace(/ 50( |\. |\, )/gm, " fifty$1");
txt.value = txt.value.replace(/ 60( |\. |\, )/gm, " sixty$1");
txt.value = txt.value.replace(/ 70( |\. |\, )/gm, " seventy$1");
txt.value = txt.value.replace(/ 80( |\. |\, )/gm, " eighty$1");
txt.value = txt.value.replace(/ 90( |\. |\, )/gm, " ninety$1");
txt.value = txt.value.replace(/ 100( |\. |\, )/gm, " one hundred$1");
txt.value = txt.value.replace(/ 2(\d)( |\. |\, )/gm, " twenty $1$2");
txt.value = txt.value.replace(/ 3(\d)( |\. |\, )/gm, " thirty $1$2");
txt.value = txt.value.replace(/ 4(\d)( |\. |\, )/gm, " forty $1$2");
txt.value = txt.value.replace(/ 5(\d)( |\. |\, )/gm, " fifty $1$2");
txt.value = txt.value.replace(/ 6(\d)( |\. |\, )/gm, " sixty $1$2");
txt.value = txt.value.replace(/ 7(\d)( |\. |\, )/gm, " seventy $1$2");
txt.value = txt.value.replace(/ 8(\d)( |\. |\, )/gm, " eighty $1$2");
txt.value = txt.value.replace(/ 9(\d)( |\. |\, )/gm, " ninety $1$2");
txt.value = txt.value.replace(/ 1( |\. |\, )/gm, " one$1");
txt.value = txt.value.replace(/ 2( |\. |\, )/gm, " two$1");
txt.value = txt.value.replace(/ 3( |\. |\, )/gm, " three$1");
txt.value = txt.value.replace(/ 4( |\. |\, )/gm, " four$1");
txt.value = txt.value.replace(/ 5( |\. |\, )/gm, " five$1");
txt.value = txt.value.replace(/ 6( |\. |\, )/gm, " six$1");
txt.value = txt.value.replace(/ 7( |\. |\, )/gm, " seven$1");
txt.value = txt.value.replace(/ 8( |\. |\, )/gm, " eight$1");
txt.value = txt.value.replace(/ 9( |\. |\, )/gm, " nine$1");
document.forms.editform.wpSummary.value += " cardinals";
}
function ordinals(){
var txt = document.editform.wpTextbox1;
txt.value = txt.value.replace(/ 10th/gm, " tenth");
txt.value = txt.value.replace(/ 11th/gm, " eleventh");
txt.value = txt.value.replace(/ 12th/gm, " twelfth");
txt.value = txt.value.replace(/ 13th/gm, " thirteenth");
txt.value = txt.value.replace(/ 14th/gm, " fourteenth");
txt.value = txt.value.replace(/ 15th/gm, " fifteenth");
txt.value = txt.value.replace(/ 16th/gm, " sixteenth");
txt.value = txt.value.replace(/ 17th/gm, " seventeenth");
txt.value = txt.value.replace(/ 18th/gm, " eighteenth");
txt.value = txt.value.replace(/ 19th/gm, " nineteenth");
txt.value = txt.value.replace(/ 20th/gm, " twentieth");
txt.value = txt.value.replace(/ 30th/gm, " thirtieth");
txt.value = txt.value.replace(/ 40th/gm, " fortieth");
txt.value = txt.value.replace(/ 50th/gm, " fiftieth");
txt.value = txt.value.replace(/ 60th/gm, " sixtieth");
txt.value = txt.value.replace(/ 70th/gm, " seventieth");
txt.value = txt.value.replace(/ 80th/gm, " eightieth");
txt.value = txt.value.replace(/ 90th/gm, " ninetieth");
txt.value = txt.value.replace(/ 2(\d)(st|nd|rd|th)/gm, " twenty $1$2");
txt.value = txt.value.replace(/ 3(\d)(st|nd|rd|th)/gm, " thirty $1$2");
txt.value = txt.value.replace(/ 4(\d)(st|nd|rd|th)/gm, " forty $1$2");
txt.value = txt.value.replace(/ 5(\d)(st|nd|rd|th)/gm, " fifty $1$2");
txt.value = txt.value.replace(/ 6(\d)(st|nd|rd|th)/gm, " sixty $1$2");
txt.value = txt.value.replace(/ 7(\d)(st|nd|rd|th)/gm, " seventy $1$2");
txt.value = txt.value.replace(/ 7(\d)(st|nd|rd|th)/gm, " eighty $1$2");
txt.value = txt.value.replace(/ 9(\d)(st|nd|rd|th)/gm, " ninety $1$2");
txt.value = txt.value.replace(/ 1st/gm, " first");
txt.value = txt.value.replace(/ 2nd/gm, " second");
txt.value = txt.value.replace(/ 3rd/gm, " third");
txt.value = txt.value.replace(/ 4th/gm, " fourth");
txt.value = txt.value.replace(/ 5th/gm, " fifth");
txt.value = txt.value.replace(/ 6th/gm, " sixth");
txt.value = txt.value.replace(/ 7th/gm, " seventh");
txt.value = txt.value.replace(/ 8th/gm, " eighth");
txt.value = txt.value.replace(/ 9th/gm, " ninth");
document.forms.editform.wpSummary.value += " ordinals";
}
function addlilink(tabs, url, name, id){
var na = document.createElement('a');
na.href = url;
na.id = id;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.appendChild(na);
tabs.appendChild(li);
return li;
}
function afdlinks(){
if(!document.getElementById) return;
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlilink(tabs, 'javascript:hideafd()', 'hide closed', 'ca-hide');
addlilink(tabs, 'javascript:showafd()', 'show closed', 'ca-show');
}
function addPurge(){
ta['ca-purge'] = ['g', 'Purge the internal cache for this page'];
if(!document.getElementById) return;
var x = document.getElementById('ca-history');
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
if(!x) return;
if(x.children) x = x.children[0];
else x = x.childNodes[0];
addlilink(tabs, x.href.replace(/=history/, "=purge"), 'purge', 'ca-purge');
}
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§ion=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§ion=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 + '§ion=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 + '§ion=0';
z.appendChild(document.createTextNode('0'));
y.appendChild(z);
document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling);
}
}
function changeLinks(){
if(!document.getElementById) return;
document.getElementById('pt-mytalk').firstChild.innerHTML = 'talk';
document.getElementById('pt-watchlist').firstChild.innerHTML = 'watchlist';
document.getElementById('pt-mycontris').firstChild.innerHTML = 'contributions';
}
function addForceSummary(){
if(!/&action=edit/.test(window.location.href)) return;
if(/§ion=new/.test(window.location.href)) return;
if(!document.forms.editform) return;
/* document.forms.editform.wpSave.onclick = forceSummary;*/
}
function afddelete(){
var form = document.forms.deleteconfirm;
form.wpReason.value = '[[Wikipedia:Articles for deletion/' + unescape(window.location.href.replace(/^.*\?title=([^&]+)&action=delete.*$/, '$1').replace(/_/g, ' ')) + ']]';
form.wpConfirm.checked = true;
}
function morelinks(){
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
if(document.title.indexOf("Editing ") == 0){
addlilink(tabs, 'javascript:replace()', '/r', '');
addlilink(tabs, 'javascript:bold()', 'bld', '');
addlilink(tabs, 'javascript:decomma()', ',', '');
addlilink(tabs, 'javascript:spelling()', 's', '');
addlilink(tabs, 'javascript:capitals()', 'C', '');
addlilink(tabs, 'javascript:ordinals()', 'st', '');
addlilink(tabs, 'javascript:cardinals()', '1', '');
/* var s = prompt("Offset: "+document.title.indexOf(":")); */
if(document.title.indexOf(":") == -1){
if(document.title.indexOf("/") == -1){
if(document.title.indexOf("September") == -1){
/* dates();*/
}
}
};
}else if(document.title.indexOf("Confirm delete - Delete") == 0){
}
}
function addToolBoxLinks(){
var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
addlilink(tb, '/wiki/Special:Newpages', 'New pages', '');
addlilink(tb, '/wiki/Special:Shortpages', 'Short pages', '');
}
function myLoadFuncs(){
addPurge();
addEditSection0();
changeLinks();
addForceSummary();
morelinks();
addToolBoxLinks();
}
if (window.addEventListener) window.addEventListener("load",myLoadFuncs,false);
else if (window.attachEvent) window.attachEvent("onload",myLoadFuncs);
else{
window._old_ABCD_onload = window.onload;
window.onload = function(){
window._old_ABCD_onload();
myLoadFuncs();
}
}
/* </nowiki> */