Skip to content

Instantly share code, notes, and snippets.

@erikvold
Created July 14, 2009 09:42
Show Gist options
  • Save erikvold/146877 to your computer and use it in GitHub Desktop.
Save erikvold/146877 to your computer and use it in GitHub Desktop.
CmdUtils.CreateCommand({
names: [ "alexa siteinfo" ],
arguments: [ {role: 'object', nountype: noun_arb_text, label: 'text'} ],
homepage: "http://erikvold.com/tools/ubiquity/alexa/alexa-siteinfo",
icon: "http://www.alexa.com/favicon.ico",
author: {name:"Erik Vergobbi Vold",email:"erikvvold@gmail.com"},
description: "Search Alexa for site information on the provided domain.",
help: "Just provide a domain or url for a site information lookup on Alexa.",
version: "0.2",
execute: function( args ){
var selectedURL=jQuery.trim( args.object.text );
if(selectedURL == ""){
selectedURL = context.focusedWindow.document.location;
}
selectedURL = selectedURL + "";
try{
selectedURL = Utils.url(selectedURL).host;
}
catch(e){
displayMessage( _( "Your url string is invalid, please correct it and try again." ) );
return false;
}
var urlString = "http://www.alexa.com/siteinfo/" + selectedURL;
Utils.openUrlInBrowser( urlString );
return true;
},
preview:function( pblock, args ){
var selectedURL = jQuery.trim( args.object.text );
if(selectedURL == ""){
selectedURL = context.focusedWindow.document.location;
}
selectedURL = selectedURL + "";
try{
selectedURL = Utils.url(selectedURL).host;
}
catch(e){
displayMessage( _( "Your url string is invalid, please correct it and try again." ) );
return false;
}
var previewTemplate = "Search Alexa for site information on ${query}";
var previewData = { query: selectedURL };
pblock.innerHTML = _( CmdUtils.renderTemplate( previewTemplate, previewData ) );
return true;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment