Last active
July 11, 2025 02:43
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==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); | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
For some background information see The People Inside.
Search results before
Search results after
Item before
Item after
Installation
Try it!
Here's a file in RecordSearch from series ST84/1 to try once the userscript is installed.