diff options
| author | hogelog | 2008-12-16 22:38:44 +0000 | 
|---|---|---|
| committer | hogelog | 2008-12-16 22:38:44 +0000 | 
| commit | dbcf68ae59ea7f0397f0134dac4e31c6652680a3 (patch) | |
| tree | 6994a53b5f494cf9047e54fd3d0d6f00a29732e8 | |
| parent | 8f00c0504b199f54fbf508f90634bd478b3a361f (diff) | |
| download | vimperator-plugins-dbcf68ae59ea7f0397f0134dac4e31c6652680a3.tar.bz2 | |
 * add tinyurl.js
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@26912 d0d07461-0603-4401-acd4-de1884942a52
| -rw-r--r-- | tinyurl.js | 58 | 
1 files changed, 58 insertions, 0 deletions
| 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 = +<VimperatorPlugin> +    <name>{NAME}</name> +    <description>tinyurl from vimperator</description> +    <author mail="konbu.komuro@gmail.com" homepage="http://d.hatena.ne.jp/hogelog/">hogelog</author> +    <version>0.1</version> +    <minVersion>2.0pre</minVersion> +    <maxVersion>2.0pre</maxVersion> +    <detail><![CDATA[ + +== COMMANDS == +tinyurl [URL]: +    echo and copy URL +expandurl URL: +    expand URL + +== LIBRARY == +plugins.tinyurl.getTiny(url): +    return TinyURL +plugins.tinyurl.getExpand(url): +    return ExpandURL + +     ]]></detail> +</VimperatorPlugin>; +//}}} + +(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: | 
