11:23 PM - Nov 3, 2009

Printliminator button on Firefox

Printliminator is a handy little tool when it comes to printing websites. Basically, you keep a bookmark that when clicked allows you to remove content from a website, leaving behind only the parts that matter to you and your printer.
Not that I knew any of this, mind you, at least not until my friend Astharis told me about it and mentioned how it would be cool if she could have a button instead of a bookmark in her browser.

I figured it wouldn't be too hard to do using Firefox extensions, and I managed to do it using Custom Buttons2 which, as the the name implies, allows you to create custom buttons for your Firefox.

The process is not entirely straightforward though, so I figured I'd include a little guide here for anyone who runs into a similar situation.

Step 1) Download and install Custom Buttons2 - https://addons.mozilla.org/en-US/firefox/addon/5066

Step 2) Right click the menu bar, you should see a new option (Add New Button) in the context menu.

Step 3) After clicking this option you'll see a new box pop up. From the three tabs that appear in it (Code, Initialization Code and Help), we'll only work with the init code, so pick that one.

/*Initialization code*/
this.leftclick = function(evt)
{
let link = "javascript:(function(){function%20loadScript(a,b){var%20c=document.createElement('script');c.type='text/javascript';c.src=a;var%20d=document.getElementsByTagName('head')[0],done=false;c.onload=c.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=='loaded'||this.readyState=='complete')){done=true;b()}};d.appendChild(c)}loadScript('http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js?ver=1.3.2',function(){loadScript('http://css-tricks.com/examples/ThePrintliminator/js/printliminator.js',function(){printlimator()})})})()";
gBrowser.loadURI(link);
}

this.setAttribute( 'onclick', 'custombuttons.gQuot.mHandler( event, this )' );

Copy all this code into the box, set a name for the button and add a proper icon if you want. (Remember to click "=> base64" if you're not going to keep the icon around in the same path; That will convert the whole image into code that will be stored by the button so you can delete it)





Once you're done click "OK", right click the menu bar once more and pick Customize. You'll see your newly created icon in the list, so just drag and drop it on your browser and enjoy some customized printing.

And for a little bonus, here's the icon I'm currently using, courtesy of Astharis:

Special thanks to the folks of the Custom Buttons2 forums, for all the helpful examples of code.