Skip to content

Instantly share code, notes, and snippets.

@JulioC
Last active May 12, 2021 03:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JulioC/a227dad6c23d4be88856c221e83e3b73 to your computer and use it in GitHub Desktop.
Save JulioC/a227dad6c23d4be88856c221e83e3b73 to your computer and use it in GitHub Desktop.

How to install

Add it to GreaseMonkey or any other userscripts platform.

How to use

  • Arrow keys (Left and Right): navigate between document pages in record viewer (you'll need click outside of the document image so it doesn't move the document itself)
  • CTRL+UP: export the list of documents in a catalog to a CSV file (useful when you want to go through all documents in that list)
// ==UserScript==
// @name Add keyboard controls to familysearch
// @version 1
// @grant none
// @run-at document-body
// @match https://www.familysearch.org/*
// @require https://craig.global.ssl.fastly.net/js/mousetrap/mousetrap.min.js?a4098
// ==/UserScript==
// Left and Right change pages on document viewer
Mousetrap.bind('right', function(e) {
document.querySelector('.next.pager-icon').click();
return false;
});
Mousetrap.bind('left', function(e) {
document.querySelector('.previous.pager-icon').click();
return false;
});
// Ctrl+UpArrow downloads CSV with list of documents in a catalog (only links for the document in ark)
Mousetrap.bind('ctrl+up', function(e) {
const data = unsafeWindow.data;
const rows = [...data.film_note].map(a => {
const dates = `${a.inclusive_dates.replace(/[^0-9\-]/g, '')} (${a.inclusive_dates})`;
return [
a.text.replace(/\,/g, ' '),
a.record_type.replace(/\,/g, ' '),
dates.replace(/\,/g, ' '),
`https://www.familysearch.org/search/film/${a.digital_film_no}?cat=${data.titleno}`
]
});
rows.unshift(['Text', 'Type', 'Dates', 'URL']);
const csvContent = "data:text/csv;charset=utf-8," + rows.map(e => e.join(",")).join("\n");
const encodedUri = encodeURI(csvContent);
unsafeWindow.open(encodedUri);
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment