diff options
Diffstat (limited to 'bitly.js')
-rw-r--r-- | bitly.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/bitly.js b/bitly.js new file mode 100644 index 0000000..f4e5bcc --- /dev/null +++ b/bitly.js @@ -0,0 +1,40 @@ +// ==VimperatorPlugin== +// @name Bit.ly +// @description-ja Bit.ly で短縮URLを得る +// @license Creative Commons 2.1 (Attribution + Share Alike) +// @version 1.0 +// ==/VimperatorPlugin== +// + +(function () { + + function bitly (uri) { + var req = new XMLHttpRequest(); + req.onreadystatechange = function(){ + if (req.readyState == 4) + return; + if(req.status == 200) { + var short = req.responseText; + util.copyToClipboard(short); + liberator.echo('`' + short + "' was copied to clipboard."); + return; + } + throw new Error(req.statusText) + }; + uri = 'http://bit.ly/api?url=' + uri; + req.open("GET", uri, true); + req.send(null); + } + + //commands.removeUserCommand('bitly'); + commands.addUserCommand( + ['bitly'], + 'Copy bitly url', + function () { + bitly(buffer.URL); + } + ); + +})(); + + |