Jump to content

User:Matthew's test/monobook.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
function format() {
    var txt = document.editform.wpTextbox1;
    txt.value = DHRef(txt.value);
}

function DHRef(str){
    str = str.replace(/(.*)\<ref\>(.*)Season (.*), \"(.*)\", approx. (.*):(.*).\<\/ref\>(.*)/gi, "$1\<ref name\=\"$4\"\>\{\{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'));
  }
});