Skip to content

Instantly share code, notes, and snippets.

@wragge
Last active July 11, 2025 02:43
Show Gist options
  • Select an option

  • Save wragge/2941e473ee70152f4de7 to your computer and use it in GitHub Desktop.

Select an option

Save wragge/2941e473ee70152f4de7 to your computer and use it in GitHub Desktop.
Userscript to show some of the people inside the National Archives of Australia's collections.
// ==UserScript==
// @name RecordSearch -- People Inside
// @namespace http://wraggelabs.com/recordsearch_show_people
// @description Records are about people. This userscript enriches the National Archives of Australia's database by inserting images of some of those people.
// @version 0.4
// @date 2025-07-11
// @creator Tim Sherratt
// @include https://recordsearch.naa.gov.au/SearchNRetrieve/Interface/ListingReports/ItemsListing.aspx*
// @include https://recordsearch.naa.gov.au/SearchNRetrieve/Interface/DetailsReports/ItemDetail.aspx*
// @grant GM_xmlhttpRequest
// @grant GM_addElement
// @connect wraggelabs.com
// ==/UserScript==
const processed_series = ['ST84/1']
function addFaces(links, type) {
for (i=0; i<links.length; i++) {
getPages(links[i], type);
}
}
function getPages(rs_link, type) {
const barcode = rs_link.match(/\/ViewImage.aspx\?B=(\d+)/)[1];
const url = 'https://wraggelabs.com/iabrowse/api/faces/' + barcode;
GM_xmlhttpRequest({
method: 'GET',
url: url,
onload: function(response) {
const data = JSON.parse(response.responseText);
if (data.length > 0) {
console.log(data);
if (type == 'single') {
console.log(type)
let row = document.createElement("tr");
let cell = document.createElement("td");
cell.setAttribute("colspan", "2");
row.append(cell);
for (i=0; i<data.length; i++) {
let link = document.createElement("a");
link.href = "https://recordsearch.naa.gov.au/SearchNRetrieve/Interface/ViewImage.aspx?B=" + barcode + "&S=" + data[i].page;
link.style.padding = "4px 4px 4px 4px";
GM_addElement(link, 'img', {
src: 'https://invisibleaus.s3.amazonaws.com/faces/' + data[i].image_file, width: "80px", height: "80px", style: "border: 2px solid #3366FF;", title: "Page: " + data[i].page
});
cell.append(link);
document.querySelector(".detailsTable table tr").after(row);
}
} else {
let face = data[Math.floor(Math.random() * data.length)];
document.querySelector("a[href*='" + barcode + "'] img").remove()
GM_addElement(document.querySelector("a[href*='" + barcode + "']"), 'img', {
src: 'https://invisibleaus.s3.amazonaws.com/faces/' + face.image_file, width: "80px"
});
}
}
}
});
}
let links = [];
let type;
if (document.location.href.indexOf('ItemDetail.aspx') > 0) {
type = 'single';
let series = document.querySelector("a[href*='SeriesDetail.aspx']").innerHTML;
let digitised = document.querySelector("a[href*='ViewImage.aspx']");
if (digitised && processed_series.indexOf(series) != -1) {
links.push(digitised.href);
}
} else {
type = 'multiple'
let rows = document.querySelectorAll("table#ContentPlaceHolderSNR_tblItemDetails tr");
for (var i=0 ; i < rows.length; i++ ) {
let cells = rows[i].querySelectorAll("td");
let series = cells[1].innerHTML;
let digitised = cells[5].querySelector("a");
if (digitised && processed_series.indexOf(series) != -1) {
links.push(digitised.href);
}
}
}
addFaces(links, type);
@wragge
Copy link
Author

wragge commented Jun 9, 2015

The people inside

This script runs on search results and item details pages in the National Archives of Australia's database RecordSearch. It looks for series that have been processed as part of the Real Face of White Australia project (currently ST84/1) and performs the following actions:

  • On search results pages it looks up the barcodes of files in the Real Face of White Australia database, if it finds any faces, it selects one at random and inserts a thumbnail version of the image in the place of the digitised file icon.
  • On item details pages it looks up the barcode in the Real Face of White Australia database, if it finds any faces it inserts thumbnails of all the images below the file title. These images are linked to the pages they came from in the digitised file viewer, so clicking on them will display the page.

For some background information see The People Inside.

Search results before

Results before

Search results after

Results after

Item before

Item before

Item after

Item after

Installation

  1. Add a userscript manager to your browser, for example TamperMonkey or ViolentMonkey.
  2. Click on the 'Raw' button above. The userscript manager will then ask you if you really want to install it. Click install!

Try it!

Here's a file in RecordSearch from series ST84/1 to try once the userscript is installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment