Skip to content

Instantly share code, notes, and snippets.

@ab
Last active October 19, 2016 02:39
Show Gist options
  • Save ab/ea1e48f6e492e29616e7e024de0db5d5 to your computer and use it in GitHub Desktop.
Save ab/ea1e48f6e492e29616e7e024de0db5d5 to your computer and use it in GitHub Desktop.
Github Print Bookmarklet (like others, but does not require jQuery). Paste the minified javascript: into a bookmark to use it.
/* Remove stuff from the page to make github pages pretty for printing */
console.log("Github pretty print 0.1");
function removeClassElems(name) {
console.log("looking for class:", name);
Array.from(document.getElementsByClassName(name)).forEach(function(e) {
console.log("Removing", e);
e.parentNode.removeChild(e);
});
}
/* Classes to remove from DOM */
[
"anchor",
"header",
"pagehead",
"site-footer",
"file-header",
"file-navigation",
"commit-tease",
"all_commit_comments",
"thread-subscription-status",
"discussion-timeline",
].forEach(removeClassElems);
/* remove border */
Array.from(document.getElementsByClassName("file")).forEach(function(e) {
console.log("Removing border from", e);
e.style.border = "none";
});
javascript:console.log("Github pretty print 0.1");function removeClassElems(name){console.log("looking for class:",name);Array.from(document.getElementsByClassName(name)).forEach(function(e){console.log("Removing",e);e.parentNode.removeChild(e)})}["anchor","header","pagehead","site-footer","file-header","file-navigation","commit-tease","all_commit_comments","thread-subscription-status","discussion-timeline",].forEach(removeClassElems);Array.from(document.getElementsByClassName("file")).forEach(function(e){console.log("Removing border from",e);e.style.border="none"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment