User:Matthew's test/monobook.js

function format { var txt = document.editform.wpTextbox1; txt.value = DHRef(txt.value); }

function DHRef(str){ str = str.replace(/(.*)\(.*)Season (.*), \"(.*)\", approx. (.*):(.*).\<\/ref\>(.*)/gi, "$1\\{\{cite episode \| title \= $4 \| series \= \[\[Desperate Housewives\]\]\}\}\<\/ref\>$6"); return trim(str); } //trim start and end, trim spaces from the end of lines function trim(str) { return (str); } addOnloadHook(function {  if(document.forms.editform) {    mw.util.addPortletLink('p-cactions', 'javascript:format', 'format', 'ca-format', 'Format article', '', document.getElementById('ca-history'));  } });