Skip to content

Instantly share code, notes, and snippets.

@erikvold
Created July 14, 2009 08:35
Show Gist options
  • Save erikvold/146842 to your computer and use it in GitHub Desktop.
Save erikvold/146842 to your computer and use it in GitHub Desktop.
CmdUtils.CreateCommand({
names: [ "mcafee siteadvisor", "siteadvisor" ],
arguments: [ {role: 'object', nountype: noun_arb_text, label: 'text'} ],
homepage:"http://erikvold.com/tools/ubiquity/mcafee/mcafee-siteadvisor",
icon:"http://www.siteadvisor.com/favicon.ico",
author:{name:"Erik Vergobbi Vold",email:"erikvvold@gmail.com"},
description:"Search McAfee SiteAdvisor for site information on the provided domain.",
help:"Just provide a domain or url for a site information lookup on McAfee SiteAdvisor.",
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.siteadvisor.com/sites/" + selectedURL;
Utils.openUrlInBrowser( urlString );
return;
},
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 McAfee SiteAdvisor for site information on ${query}";
var previewData = { query: selectedURL };
pblock.innerHTML = _( CmdUtils.renderTemplate( previewTemplate, previewData ) );
return;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment