Skip to content

Instantly share code, notes, and snippets.

@stuarthendren
Created December 11, 2008 14:22
Show Gist options
  • Save stuarthendren/34723 to your computer and use it in GitHub Desktop.
Save stuarthendren/34723 to your computer and use it in GitHub Desktop.
PrintWhatYouLike.com Ubiquity Command
CmdUtils.CreateCommand({
names: ["print what you like"],
homepage: "http://stuarthendren.net/",
author: { name: "Stuart Hendren", email: "stuarthendren@gmail.com"},
contributors: ["Stuart Hendren"],
license: "CC by-sa, http://creativecommons.org/licenses/by-sa/2.0/",
description: "Sends the current page to PrintWhatYouLike.com",
icon: "http://www.printwhatyoulike.com/static/img/favicon.png",
help: "Print the current tab using <a href='http://printwhatyoulike.com'>PrintWhatYouLike.com</a>",
preview: function( pblock ) {
var msg = "Opens a new tab to print ";
msg += context.focusedWindow.document.location.href;
msg += " using PrintWhatYouLike.com.";
pblock.innerHTML = msg;
},
execute: function( ) {
var url = context.focusedWindow.document.location.href;
var encodedUrl=escape(url);
encodedUrl=encodedUrl.replace(/\+/g, "%2B");
encodedUrl=encodedUrl.replace(/\//g, "%2F");
var send = "http://www.printwhatyoulike.com/print?url=";
send += encodedUrl;
Utils.openUrlInBrowser(send);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment