Created
March 28, 2011 19:27
-
-
Save mcepl/891100 to your computer and use it in GitHub Desktop.
Ubiquity shorten URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
function getShortURL(which, args) { | |
var baseURL = ""; var params = {}; | |
if (which == "is.gd") { | |
baseURL = "http://is.gd/create.php"; | |
params = { | |
format: "simple", | |
url: encodeURIComponent(args.object.text) | |
}; | |
} | |
else if (which == "hurl") { | |
baseURL = 'http://hurl.test.redhat.com/new?' + encodeURIComponent(args.object.text); | |
params = ""; | |
} | |
jQuery.get(baseURL, params, function(tinyUrl) { | |
Utils.clipboard.set({ | |
text: tinyUrl | |
}); | |
}); | |
}; | |
CmdUtils.CreateCommand({ | |
names: ["is.gd"], | |
description: "Replaces the selected URL with a is.gd.", | |
arguments: [{role: "object", | |
nountype: noun_type_url, | |
label: "url to shorten"}], | |
execute: function (args) { | |
getShortURL("is.gd", args); | |
} | |
}); | |
CmdUtils.CreateCommand({ | |
names: ["hurl"], | |
description: "Replaces the selected URL with a hurl", | |
arguments: [{role: "object", | |
nountype: noun_type_url, | |
label: "url to shorten"}], | |
execute: function (args) { | |
getShortURL("hurl", args); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment