In my monobook, at the end, I have this: (This is probably closer to what you are trying to do...)
function superAutoFormat() {
// get page title pagetitle = document.getElementById('content').getElementsByTagName('h1').item(0).firstChild.nodeValue; if (pagetitle.search(/Editing /) == -1) return; pagetitle = pagetitle.replace(/Editing /g, ""); pageexternal = pagetitle.replace(/\ /g, "_");
// is this in the main namespace? If not, stop. if (pagetitle.search(/\:/) != -1) { anonIPfmt(); return; }
// If editing a section, skip all of everything. if (pagetitle.search(/\(section\)/) != -1) return;
if (/&wikiredr=clean/.test(window.location.href)) { document.editform.wpSummary.value = "Random cleanup"; }
txt = " " + document.editform.wpTextbox1.value; txt = txt.substr (1, txt.length-1); myoldtxt = txt; oldtxt = txt; if (txt.length < 2) txt = " " + txt;
//safety valves if (txt.search(/^\* Common misspelling of/i) != -1) return; if (txt.search(/^\*Common misspelling of/i) != -1) return; if (txt.search(/^#redirect \[/i) != -1) return;
// change me, if not exiting properly Hamaryns/monobook.js / Hamaryns/monobook.js
txt = txt.replace(/\{\{PAGENAMEE\}\}/g, pageexternal); txt = txt.replace(/\{\{PAGENAME\}\}/g, pagetitle); txt = txt.replace(/\{\{subst:PAGENAME\}\}/g, pagetitle);
minorFormat(); //minor format problems that must be dealt with first genderFmt(); //format gender from italics to template langHdrs(); //spap out Template:-en- and such headLevel(); //correct known 3rd level heading level problems langHdrs(); //correct known language heading level problems langSubsts(); //subst: all the language templates deWikify(); //de-wikify all "common" languages //todo: limit formatting of inflections and such to ==English== section only? inflLine(); //add an "inflection" line if missing transTable(); //reformat translations tables, balance columns (todo) parseLines(); //TTBC specialCharacters(); //Special characters entered when they shouldn't be or vice versa
txt = txt.replace(/\{\{PAGENAMEE\}\}/g, pageexternal); txt = txt.replace(/\{\{PAGENAME\}\}/g, pagetitle); txt = txt.replace(/\{\{subst:PAGENAME\}\}/g, pagetitle);
//2/22/2006: Running through the /todo4 cleanup list; TEMPORARY CODE //Add "==English==\n\n" by default. //txt.multiline() = true; if (txt.length > 1) if ( txt.search(/==\{\}|: (ü)\-a-z]+==\n/) == -1 ) { if ( txt.search(/^\*common misspelling of/gi) == -1 ) { if ( txt.search(/^#redirect /gi) == -1 ) { txt = "==English==\n\n" + txt; document.editform.wpSummary.value += " +==Lang=="; } } }
if (txt == " ") txt = "";
document.editform.wpTextbox1.value = txt;
//document.editform.wpSummary.value = document.forms.length;
oldtxt = myoldtxt; if (txt != oldtxt) { //comments now added for specific sections only. if (document.editform.wpSummary.value.search(/User:/g) == -1) { if (document.editform.wpSummary.value != "") document.editform.wpSummary.value += ", "; document.editform.wpSummary.value += "fmt"; } //document.editform.wpSummary.value += "+format"; document.editform.wpDiff.click(); }
}
addLoadEvent( superAutoFormat );