RecordSearch Mapping Our Anzacs links

By wragge Last update Jan 28, 2009 — Installed 39 times. Daily Installs: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0
// ==UserScript==
// @name           RecordSearch Mapping Our Anzacs links
// @namespace      http://ozhistory.info/rs_moa_link
// @description    Adds links from B2455 items in RecordSearch to Mapping our Anzacs
// @version        0.1
// @date           2008-01-28
// @creator        Tim Sherratt
// @include        http://naa12.naa.gov.au/scripts/*
// @include        http://recordsearch.naa.gov.au/scripts/*
// ==/UserScript==

function openMOA(barcode) {
    var url = 'http://mappingouranzacs.naa.gov.au/details-permalink.aspx?barcode_no=' + barcode;
    window.open(url);
}
function embedFunction(s) {
head.appendChild(document.createElement('script')).innerHTML=s.toString().replace(/([\s\S]*?return;){2}([\s\S]*)}/,'$2');
}
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
if (document.location.href.match(/ItemDetail.asp/i)) {
    embedFunction(openMOA);
    var series = document.evaluate('//td[b="Series number"]/a', document, null, XPathResult.ANY_TYPE, null).iterateNext().innerHTML;
    var barcode = document.evaluate('//td[b="Barcode"]', document, null, XPathResult.ANY_TYPE, null).iterateNext().lastChild.textContent;
    if (series == 'B2455') {
        var forms = document.getElementsByTagName('form');
        form = forms[0];
        moa_button = document.createElement('input');
        moa_button.setAttribute('type', 'button');
        moa_button.setAttribute('value', 'View in Mapping our Anzacs');
        moa_button.setAttribute('onclick','openMOA(' + barcode + '); return false;');
        form.appendChild(moa_button);
    }
}