Skip to content

Instantly share code, notes, and snippets.

@gaute
Created November 11, 2011 10:45
Show Gist options
  • Save gaute/1357711 to your computer and use it in GitHub Desktop.
Save gaute/1357711 to your computer and use it in GitHub Desktop.
Printable GitHub issues
// ==UserScript==
// @name GitHub print CSS
// @namespace https://github.com/gaute
// @include https://github.com/*/issues/*
// ==/UserScript==
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
function main() {
var css = '#header, #footer, .instapaper_ignore, .subnav-bar, '
+ '.context-loader, .actions, .infobar, .error, .pull-participation, '
+ '.notification-settings, .ajax-error-message, form, .back, '
+ '.js-comment-container {'
+ ' display: none;'
+ '}'
+ '.new-comments .js-comment-container {'
+ ' border-top: 1px solid #ccc;'
+ ' padding: 1em;'
+ ' display: block;'
+ '}';
$('<style media="print">' + css + '</style>').appendTo('head');
}
addJQuery(main);
@gaute
Copy link
Author

gaute commented Nov 11, 2011

This script will make GitHub issues printable.

It works by setting the screen stylesheet as print stylesheet, and then adding some inline CSS to make the print look nice.

@cbilgili
Copy link

cbilgili commented Feb 3, 2012

How can we use this?

@gaute
Copy link
Author

gaute commented Feb 3, 2012

Once installed, use the browser's normal print feature.

@cbilgili
Copy link

cbilgili commented Feb 3, 2012 via email

@gaute
Copy link
Author

gaute commented Feb 3, 2012

Ah, in Google Chrome, I just hit the "raw" link above, then Chrome asks to install the script.

If this doesn't work in your browser, try googling for info on userscripts.

@cbilgili
Copy link

cbilgili commented Feb 3, 2012

I have installed the script. But normal print feature doesn't change, same as old. My chrome is 16.0 and OS is Mac osx lion.

@gaute
Copy link
Author

gaute commented Feb 3, 2012

This one only works on issues. I expanded it for commits, pull requests and wikis:
https://gist.github.com/1385148

I use this in Chrome on two OS X computers.

@cyco
Copy link

cyco commented Oct 26, 2012

Awesome, thank you very much.
Using Safari 6.0.1 btw.

@daryltucker
Copy link

This is great, but doesn't seem to work with the new Github layout. Any suggestions?

@tobinharris
Copy link

We also just created this for printing Kanban cards, it's an easy to install Gem

https://github.com/pocketworks/git2pdf

@huguesgauthiertransit
Copy link

got this message when click raw button..

image

@isosphere
Copy link

got this message when click raw button..

image

You can get around this by downloading it and then dragging-and-dropping it onto Chrome from your file system.

The script is working well for me, thank you for making it!

@StachuDotNet
Copy link

Yesterday I was having issues printing a github issue for review on paper. It kept cutting things off!
After some googling, I ended up on this gist (among many other things), to no avail.

In the end, I found that the issue was that I was zoomed into the web page. resetting my zoom to 100% made it so I could print the Issue without... issues. Hope this helps someone else in the future.

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