From 05494c71f1a1e8b06cb4b7e7815c61524725ff4c Mon Sep 17 00:00:00 2001 From: anekos Date: Sat, 8 Nov 2008 16:35:49 +0000 Subject: added git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/branches/1.2@23016 d0d07461-0603-4401-acd4-de1884942a52 --- bitly.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 bitly.js (limited to 'bitly.js') 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); + } + ); + +})(); + + -- cgit v1.2.3