Skip to content

Instantly share code, notes, and snippets.

@mitry
Last active December 13, 2025 11:11
Show Gist options
  • Select an option

  • Save mitry/59d5d6f12cb787e90175b2de97ff5eec to your computer and use it in GitHub Desktop.

Select an option

Save mitry/59d5d6f12cb787e90175b2de97ff5eec to your computer and use it in GitHub Desktop.
Bookmarklet: save webpage as clean Markdown file.
javascript: Promise.all([
import('https://esm.run/turndown'),
import('https://esm.run/@mozilla/readability'),
import('https://esm.run/turndown-plugin-gfm')
]).then( ([
{default: Turndown},
{Readability},
{gfm}]) => {
const a=document.createElement('a'),
options = {classesToPreserve: ['block-code',]},
td = new Turndown({codeBlockStyle:'fenced'}),
ra = new Readability(document.cloneNode(true), options).parse();
td.use(gfm);
let md = td.turndown(ra.content);
md += `\n\n[original]: ${document.location.href} "${ra.title}"\n`;
md = unescape(encodeURIComponent(md));
a.href=`data:text/markdown;base64,${btoa(md)}`;
a.download=ra.title.replace(/\s+/g,"-")+".md";
a.click();
})
@mitry
Copy link
Author

mitry commented Feb 8, 2025

Minified version:

javascript:Promise.all([import('https://esm.run/turndown'),import('https://esm.run/@mozilla/readability'),import('https://esm.run/turndown-plugin-gfm')]).then( ([{default: Turndown},
{Readability},{gfm}])=>{const a=document.createElement('a'),options={classesToPreserve:['block-code',]},td=new Turndown({codeBlockStyle:'fenced'}),
ra=new Readability(document.cloneNode(true)).parse();td.use(gfm);let md=td.turndown(ra.content);md+=`\n\n[original]: ${document.location.href} "${ra.title}"\n`,md=unescape(encodeURIComponent(md));a.href=`data:text/markdown;base64,${btoa(md)}`;a.download=ra.title.replace(/\s+/g,"-")+".md";a.click();})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment