From dbcf68ae59ea7f0397f0134dac4e31c6652680a3 Mon Sep 17 00:00:00 2001 From: hogelog Date: Tue, 16 Dec 2008 22:38:44 +0000 Subject: * add tinyurl.js git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@26912 d0d07461-0603-4401-acd4-de1884942a52 --- tinyurl.js | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tinyurl.js (limited to 'tinyurl.js') diff --git a/tinyurl.js b/tinyurl.js new file mode 100644 index 0000000..8c8e132 --- /dev/null +++ b/tinyurl.js @@ -0,0 +1,58 @@ +// PLUGIN_INFO//{{{ +var PLUGIN_INFO = + + {NAME} + tinyurl from vimperator + hogelog + 0.1 + 2.0pre + 2.0pre + +; +//}}} + +(function() { + const TinyAPI = 'http://tinyurl.com/api-create.php?url='; + function echopy(str) + { + liberator.echo(str); + util.copyToClipboard(str); + } + + commands.add(['tinyurl'], 'echo and copy TinyURL', + function(args) echopy(tiny.getTiny(args.length==0 ? buffer.URL : args.string)), + { + argCount: '?', + }); + commands.add(['expandurl'], 'expand TinyURL', + function(args) echopy(tiny.getExpand(args.string)), + { + argCount: '1', + }); + + let tiny = plugins.tinyurl = { + getTiny: function(url) + { + return util.httpGet(TinyAPI+encodeURIComponent(url)).responseText; + }, + getExpand: function (url) + { + return util.httpGet(url).channel.name; + } + }; +})(); +// vim: fdm=marker sw=4 ts=4 et: -- cgit v1.2.3