Skip to content

Instantly share code, notes, and snippets.

@ww24
Created June 26, 2011 03:55
Show Gist options
  • Save ww24/1047211 to your computer and use it in GitHub Desktop.
Save ww24/1047211 to your computer and use it in GitHub Desktop.
ux.nu Bookmarklet
var uxnuURLShortener = function(j) {
var sc = j.status_code;
if (sc == 200) {
prompt('Short URL', j.data.url);
} else {
alert(sc+': '+j.description);
}
};
(function() {
var d = document;
var t = d.createElement('script');
t.type = 'text/javascript';
t.src = ('https:' == location.protocol ? 'https://' : 'http://')+'ux.nu/api/short?url='+encodeURIComponent(location.href)+'&callback=uxnuURLShortener&format=jsonp';
var s = d.getElementsByTagName('script')[0];
s.parentNode.insertBefore(t, s);
})();
@ww24
Copy link
Author

ww24 commented Jun 26, 2011

URLエンコード、HTTPSに対応。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment