Source for "Google Reader Print Button"

By Julien Gilles
Has no other scripts.


// ==UserScript==
// @author	   Julien Gilles
// @name           Google Reader Print Button
// @description    Add two print buttons to Google Reader (one for current entry, one for all entries)
// @include        http://www.google.com/reader/view/*
// @version        2.1
// ==/UserScript==

function greaderPrint(entry) {
   var disp_setting = "toolbar=yes,location=no,directories=yes,menubar=yes,"; 
   disp_setting += "scrollbars=yes,width=650, height=600, left=100, top=25"; 
   if (!entry) {
	  alert("Please select one entry first");
   }
   else {
	  var content = entry.innerHTML;
	  var docprint = window.open("about:blank","","");
	  var style = 'ins { text-decoration:none; }' 
		 + '* {font-size:8pt; }'
		 + '.entry-actions { display:none; }'
		 + '#scroll-filler { display:none; }'
		 + '.entry-title-go-to { display:none; }';
	  
	  docprint.document.write('<head>');
	  docprint.document.write('<title>');
	  docprint.document.write(document.getElementById('chrome-stream-title').firstChild.text);
	  docprint.document.write('</title>');
	  docprint.document.write('<style type="text/css">' + style + '</style>');
	  docprint.document.write('<body>');
	  docprint.document.write(content);
	  docprint.document.close(); 
	  docprint.focus(); 
	  docprint.print();
   }
}


function initializePrintButtons() {
   var linksContainer = document.getElementById('chrome-footer-container');
   
   if (!linksContainer) {
      return;
   }
   printButton = document.createElement('table');
   printButton.className = "button-container unselectable button-container-float-left button-container-tight";
   printButton.addEventListener("click", function() { greaderPrint(document.getElementById('current-entry')) }, false);
   printButton.innerHTML ='<tbody><tr><td class="btl"></td><td class="btr"></td></tr><tr><td class="bbl"></td><td class="bbr"><div class="button-body-container"><span class="button-body unselectable">Print</span></div></td></tr></tbody>';

   linksContainer.appendChild(printButton);

   printButton2 = document.createElement('table');
   printButton2.className = "button-container unselectable button-container-float-left button-container-tight";
   printButton2.addEventListener("click", function() { greaderPrint(document.getElementById('entries')) }, false);
   printButton2.innerHTML ='<tbody><tr><td class="btl"></td><td class="btr"></td></tr><tr><td class="bbl"></td><td class="bbr"><div class="button-body-container"><span class="button-body unselectable">Print All</span></div></td></tr></tbody>';
   linksContainer.appendChild(printButton2);

}

initializePrintButtons();