<syntaxhighlight lang="javascript">
// ==UserScript==
// @name           MCH stub creator
// @namespace	   http://opensourceexile.blogspot.com/
// @description    Create wikipedia stubs from MCH bio pages
// @include        http://www.teara.govt.nz/en/biographies/*
// ==/UserScript==

// See https://secure.wikimedia.org/wikipedia/enhttps://wiki95.com/en/Wikipedia:WikiProject_Missing_encyclopedic_articles/NZ/Dictionary_of_New_Zealand_Biography

var rawTitle=document.getElementsByName("DC.title").content;
var rawName=rawTitle;
var first=rawTitle.substring(rawTitle.indexOf(', ')+2);
var last=rawTitle.substring(0,rawTitle.indexOf(', '));
var fixedName= rawTitle.substring(rawTitle.indexOf(', ')+2) + ' ' + rawTitle.substring(0,rawTitle.indexOf(', '));
var rawDates=document.getElementsByTagName("p").item(0).childNodes.textContent;
var birthDate=rawDates.substring(0,4);
var deathDate=rawDates.substring(5,9);

var rawBio=document.getElementsByTagName("p").item(1).childNodes.textContent;
if (rawBio.indexOf(' and ') == -1 ){
    var regexpBio=/^(.*), (*)$/;
    var cookedBio=rawBio.replace(regexpBio, "$1 and $2");
} else {
    var cookedBio=rawBio;
}

var rawFooter=document.getElementById("footer-citation").childNodes.textContent;
var refAuthor=rawFooter.substring(rawFooter.indexOf(':')+1).substring(0,rawFooter.indexOf("'")-rawFooter.indexOf(':')-3);
var refLast=refAuthor.substring(refAuthor.lastIndexOf(' '));
var refFirst=refAuthor.substring(0,refAuthor.lastIndexOf(' '));
var rawDate=rawFooter.substring(rawFooter.indexOf('updated')+7)
var refDate=rawDate.substring(0,rawDate.indexOf('\n'));
var refURL=rawFooter.substring(rawFooter.indexOf('URL:')+5);

var regexpId=/^.*\/(?)\/.*$/;
var id=refURL.replace(regexpId,"$1");

alert("\n" + "'''" + fixedName + "''' (" + birthDate + "&ndash;" + deathDate + ")" + " was a ] " + cookedBio.toLowerCase() + ".<ref name=\"DNZB " + last + "\">{{DNZB|title=" + fixedName + "|first=" + refFirst +"|last=" + refLast + "|id=" + id + "|accessdate=December 2011}}</ref>\n\n==References==\n{{Reflist}}\n\n{{Persondata <!-- Metadata: see ]. --> \n| NAME              = " + rawName + "\n| ALTERNATIVE NAMES = \n| SHORT DESCRIPTION = " + rawBio + "\n| DATE OF BIRTH     = " + birthDate + "\n| PLACE OF BIRTH    = \n| DATE OF DEATH     = " + deathDate + "\n| PLACE OF DEATH    = \n}}\n{{DEFAULTSORT:" + rawName  +"}}\n\n]\n]\n]\n\n{{NewZealand-bio-stub}}\n\n")
</syntaxhighlight>