NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name jfk_randomizer
// @version 2025-03-20
// @description get a random jfk record from the archives.gov page
// @author (You)
// @match https://www.archives.gov/research/jfk/release-2025
// @icon https://www.google.com/s2/favicons?sz=64&domain=archives.gov
// @require https://code.jquery.com/jquery-3.6.0.min.js
// @grant none
// @updateURL https://openuserjs.org/meta/eclipse9614/jfk_randomizer.meta.js
// @license MIT
// ==/UserScript==
(function() {
'use strict';
var randomButton = $('<input />').attr({
type: "button",
id: "randomButton",
style: "position:fixed; top:5%; left:50%; transform:translate(-50%,-50%); z-index:9999; font-size:18px; padding:12px 20px; background:linear-gradient(45deg, #ff6b6b, #4ecdc4); color:white; border:none; border-radius:5px; box-shadow:0 4px 15px rgba(0,0,0,0.2); cursor:pointer; transition:all 0.3s ease;",
value: "🎲 Random Record"
}).appendTo('body');
randomButton.on('click', function(e) {
let rows = $('.datatable tbody tr');
let randomRow = rows.eq(Math.floor(Math.random() * rows.length));
let pdfLink = randomRow.find('td:first a').attr('href');
console.log(pdfLink);
if (pdfLink) {
if (e.ctrlKey) {
window.open(pdfLink, '_blank').blur(); // Open in new tab but stay in current window
window.focus();
} else {
window.open(pdfLink, '_blank').focus(); // Original behavior
}
} else {
alert('No PDF link found for the selected record.');
}
});
// Your code here...
})();