Skip to content

Instantly share code, notes, and snippets.

@davidcann
Created June 10, 2022 17:43
Show Gist options
  • Save davidcann/2d65fb189cdee31a6dcaa248f46afec3 to your computer and use it in GitHub Desktop.
Save davidcann/2d65fb189cdee31a6dcaa248f46afec3 to your computer and use it in GitHub Desktop.

Print GitHub Markdown Bookmarklet

javascript:document.body.appendChild(document.querySelector("#readme"));document.querySelector("header").remove();document.querySelector(".application-main").remove();document.querySelector("footer").remove();window.print();

Make it into a bookmarklet. It removes everything around the markdown article and opens the print dialog.

@aubertc
Copy link

aubertc commented Aug 13, 2024

For what it's worth, with following code it works for me:

javascript:document.body.appendChild(document.querySelector(".markdown-body"));document.querySelector("[data-turbo-body]").remove();window.print();

This is very nice, but only the first message in the thread is displayed with this snippet. Is that the intended behavior, @thomasverleye ?

@aubertc
Copy link

aubertc commented Aug 13, 2024

To get the whole thread, I've used

javascript:document.body.appendChild(document.querySelector("#discussion_bucket"));document.querySelector("[data-turbo-body]").remove();window.print();

(that is, I used #discussion_bucket insteal of .markdown-body.)

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