Skip to content

Instantly share code, notes, and snippets.

@veltman
Last active December 15, 2023 10:54
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save veltman/5772849 to your computer and use it in GitHub Desktop.
Bookmarklet to create a printable version of a Markdown file on GitHub. Create a bookmark in your toolbar with this code as the URL, then click the bookmark while viewing a Markdown document (like a README) on GitHub to strip away the rest of the page for a clean, printable version. Or, if what I just said sounded scary, visit this page: http://…
javascript:(function(){ document.body.innerHTML = document.getElementById("readme").getElementsByTagName("article")[0].outerHTML; })();
@frankMilde
Copy link

It says undefined for me.. however, im running on an super old firefox OSX version:
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28.

@insaurabh
Copy link

It's working fine and very handy sometime.

I just changed as per my need ( to trigger the print )

javascript:(function(){ 
  let readMe = document.getElementById("readme")?.getElementsByTagName("article")[0]?.outerHTML; 
  if(!readMe) return false;
   document.body.innerHTML = readMe;window.print();
})();

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