Skip to content

Instantly share code, notes, and snippets.

@ba3r
Created October 30, 2009 02:51
Show Gist options
  • Save ba3r/222069 to your computer and use it in GitHub Desktop.
Save ba3r/222069 to your computer and use it in GitHub Desktop.
/* AddToAny v0.5
Original source script can be found here: http://code.google.com/p/zainulfranciscusubiquity/source/browse/trunk/%20zainulfranciscusubiquity/Ubiquity/addToAny.js */
var noun_type_service = new CmdUtils.NounType( "service",
["facebook", "twitter", "digg", "reddit", "subscribe", "email", "google_gmail", "google_buzz", "google bookmarks", "evernote", "posterous", "tumblr", "netvibes_share", "yahoo_bookmarks", "delicious", "mister_wong", "friendfeed", "google_reader", "wordpress", "blogger_post", "livejournal"]
);
CmdUtils.CreateCommand({
names: ["addToAny"],
homepage: "http://addtoany.com",
author: {name:"zainul franciscus", homepage:"http://zfranciscus.wordpress.com"},
contributors: {name: "Michael Baer", homepage: "http://twitter.com/synapsos"},
licence: "Creative Common Licence Attribution-Noncommercial-No Derivative Works 3.0 New Zealand (http://creativecommons.org/licenses/by-nc-nd/3.0/nz/)",
icon: "http://www.addtoany.com/favicon.ico",
description: "Share to any service",
arguments: [{role: 'object', nountype: noun_type_url, label:"site to share"},
{role: 'goal', nountype: noun_type_service, label:"sharing service"},
{role: 'alias', nountype: noun_arb_text, label:"title (optional)"}],
execute: function (args) {
var baseUrl = "http://www.addtoany.com/add_to/";
var service = args.goal.text;
if(args.goal.text == "") {
displayMessage("No sharing service specified.");
service = "share_save";
return service;
}
var urlToShare = args.object.text;
if(args.object.text == "") {
urlToShare = win.location.href;
if(args.alias.text = "") {
docName = CmdUtils.getDocument().title;
}
else {
var docName = args.alias.text;
}
}
else {
var docName = args.alias.text;
}
var sharingURL = baseUrl + service + "?linkurl=" + urlToShare + "&linkname=" + docName;
Utils.openUrlInBrowser(sharingURL);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment