Skip to main content
3 of 6
include copy of working greasemonkey script and bookmarklet, for posterity

StackPrinter Greasemonkey script is broken

I have previously installed and been working with the "StackPrinter" Greasemonkey script -- which displays a button on each Stack Exchange question to print that question with StackPrinter.

Now, that button no longer shows up. I believe this is caused by the failure of userscripts.org.

Any workarounds to get the button working again?

There is also a javascript bookmarklet on the StackPrinter page. It allows you to create a bookmark which functions similarly to the Printer button. By the way, the javascript bookmarklet needs to be tweaked by changing http to https to make it work on current Stack Exchange pages, which have been recently updated to redirect to https.

Update 2014/09/29:

I have been using the bookmarklet, which continues to work, but I've gotten the Greasemonkey script to work again, by including both http and https URLs and removing references to the broken userscripts.org. For the sake of posterity, here is the Greasemonkey script stackprinter.user.js:

// ==UserScript==
// @name           StackPrinter
// @description    Add Printer-Friendly button to question

// @include         http://stackoverflow.com/questions/*
// @include        https://stackoverflow.com/questions/*

// @include         http://serverfault.com/questions/*
// @include        https://serverfault.com/questions/*

// @include         http://superuser.com/questions/*
// @include        https://superuser.com/questions/*

// @include         http://stackapps.com/questions/*
// @include        https://stackapps.com/questions/*

// @include         http://meta.stackoverflow.com/questions/*
// @include        https://meta.stackoverflow.com/questions/*

// @include         http://*.stackexchange.com/questions/*
// @include        https://*.stackexchange.com/questions/*

// @include         http://askubuntu.com/questions/*
// @include        https://askubuntu.com/questions/*

// @include         http://answers.onstartups.com/questions/*
// @include        https://answers.onstartups.com/questions/*

// @include         http://meta.mathoverflow.net/questions/*
// @include        https://meta.mathoverflow.net/questions/*

// @include         http://mathoverflow.net/questions/*
// @include        https://mathoverflow.net/questions/*

// ==/UserScript==

function with_jquery(f) {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.textContent = "(" + f.toString() + ")(jQuery)";
  document.body.appendChild(script);
};

with_jquery(function($) {
       var re = new RegExp("^http://(.*?)\.(com|net|org)");
       var group = re.exec(window.location.href);
       var service = group[1];
       $('#question .vote:first').append(''
         +'<div id="PrinterFriendly" style="margin-top:8px">'
         +'<a alt="Printer-Friendly" title="Printer-Friendly"'
         +'  href="javascript:'
         +'    (function(){'
         +'      f=\''
                   +'http://www.stackprinter.com/export?format=HTML&service='
                   +service
                   +'&question='
                   +$('.vote').find('input[type=hidden]:first').val()
                   +'\';'
         +'      a=function(){if(!window.open(f))location.href=f};'
         +'      if(/Firefox/.test(navigator.userAgent))'
         +'       {setTimeout(a,0)}else{a()}'
         +'    })()'
         +'  "'
         +'> <img width="33px" height="33px" '
         +'    src="http://www.stackprinter.com/images/printer.gif">'
         +'  </img>'
         +'</a></div>'
       );
});

The bookmarklet is:

javascript:(function(){var%20re%20=%20new%20RegExp('^https?://(.*?)\.com/questions/([0-9]+)/');var%20group%20=%20re.exec(window.location.href);if%20(group!=null){var%20service%20=%20group[1];var%20questionid=group[2];window.open('http://www.stackprinter.com/export?format=HTML&service='+service+'&question='+questionid)}else{alert('Attention:%20question%20id%20not%20found!')}})()