a small software application stored as a bookmark in a web browser, which typically allows a user to interact with the currently loaded web page in some way.
That is, when the URL field of a bookmark contains JavaScript. This one is for printing internal docs to PDF by simply clicking on a bookmark:
javascript: (() => { let auth_num = document.body.outerHTML.match(/NMED\d{9}/g); let datetime = new Date().toJSON().replace(/[^a-zA-Z0-9]/g, '_'); document.title = `${datetime}_${auth_num}`; window.print(); window.close(); })();
javascript: (() => { /* add arbitrary code here */ })();
// These parts are irrelevant as they
// are specific to internal HTML documents.
let auth_num = document.body.outerHTML.match(/NMED\d{9}/g);
let datetime = new Date().toJSON().replace(/[^a-zA-Z0-9]/g, '_');
// Change title of the HTML document as this
// will be the default name of the printed PDF.
document.title = `${datetime}_${auth_num}`;
// Open print dialog (same and CTRL+P).
window.print();
// (Optional) Close the browser tab.
// Only works if that has been opened programmatically!
// (Such as using Vimium plugin in Chrome.)
window.close();