Skip to content

Instantly share code, notes, and snippets.

@ashtonmeuser
Last active February 2, 2025 23:14
Show Gist options
  • Save ashtonmeuser/b941181ffb8f8ceee08859f9ea9cc908 to your computer and use it in GitHub Desktop.
Save ashtonmeuser/b941181ffb8f8ceee08859f9ea9cc908 to your computer and use it in GitHub Desktop.
Reader view using Mozilla's readability
// bookmarklet-title: Reader
// bookmarklet-about: Mozilla's readability (https://github.com/mozilla/readability) piped into a modal.
import Modal from '/ashtonmeuser/0613e3aeff5a4692d8c148d7fcd02f34/raw/d6dd01eaab665a14bded5487a8c03b6bb7197388/Modal.ts';
import { Readability } from 'https://esm.sh/@mozilla/readability';
const id = ''; // bookmarklet-var(uuid): id
const reader = new Readability(document.cloneNode(true)).parse();
const content = `<h1>${reader.title}</h1>${reader.content}`;
const modal = new Modal(id, {
content,
style: 'img{display:block;margin:0 auto;max-width:100%;height:auto;}figcaption{font-size:0.8em;}',
});
modal.dialogElement.focus(); // Remove focus from first element
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment