Skip to content

Instantly share code, notes, and snippets.

@solace
Last active July 8, 2024 04:13
Show Gist options
  • Save solace/0989a1548a4ad994c67feb316738e81e to your computer and use it in GitHub Desktop.
Save solace/0989a1548a4ad994c67feb316738e81e to your computer and use it in GitHub Desktop.
A bookmarklet to clip Tumblr posts
javascript:navigator.clipboard.write([new ClipboardItem({ ["text/html"]: new Blob([`---<br />created: "${new Date().toISOString()}"<br />published: "${document.querySelector('time').dateTime}"<br />authors: ${document.querySelector('a[rel="author"]').text}<br />url: ${window.location}<br /><br />---<br /><br /># ${document.querySelector('link[type="application/json+oembed"]').title} <br /><br />` + document.querySelectorAll(`[data-id="${window.location.pathname.match(/(\d+)/)[1]}"] article > div`)[0].outerHTML.replace(/srcset="(.*?)"/g, (matcher,p1) => { const last = p1.split(/\s*,\s*/).pop(); return `src="${last.split(/\s+/)[0]}"`})], {type: 'text/html'})})]).then(() => console.log('Copied to clipboard'));
@solace
Copy link
Author

solace commented Jul 8, 2024

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