Skip to content

Instantly share code, notes, and snippets.

/x

Created April 27, 2009 01:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/102242 to your computer and use it in GitHub Desktop.
Save anonymous/102242 to your computer and use it in GitHub Desktop.
var noun_type_service = new CmdUtils.NounType( "service",
["facebook", "twitter", "digg", "reddit"]
);
CmdUtils.CreateCommand({
name: "share",
icon: "http://static.addtoany.com/buttons/share_16_16.png",
description: "Share to any service",
modifiers: {"to": noun_type_service},
_getAddToAnyUrl: function(mods) {
var document = CmdUtils.getDocument();
var location = document.location.href;
var title = document.title || '';
var selection = document.getSelection().substring(0, 1200) || '';
var service = mods.to.text || '';
var params = Utils.paramsToString({
linkurl: location,
linkname: title,
linknote: selection
});
if ( service )
var addtoany = "http://www.addtoany.com/add_to/"
+ service
+ params;
else
var addtoany = "http://www.addtoany.com/share_save"
+ params;
return addtoany;
},
execute: function(directObject, mods) {
Utils.openUrlInBrowser( this._getAddToAnyUrl(mods) );
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment