aboutsummaryrefslogtreecommitdiffstats
path: root/跳.js
diff options
context:
space:
mode:
authoranekos2010-12-19 16:04:34 +0900
committeranekos2010-12-19 16:04:34 +0900
commit9ab8980ceddc43f6cb6649100d3609eeb6c7472e (patch)
tree0359adfc132b9ebbbce380ab114d3218a2fcfbd6 /跳.js
parentd78de25735695573dfd5313204929df756653a93 (diff)
downloadvimperator-plugins-9ab8980ceddc43f6cb6649100d3609eeb6c7472e.tar.bz2
API追加
Diffstat (limited to '跳.js')
-rw-r--r--跳.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/跳.js b/跳.js
index 3a3932d..648a840 100644
--- a/跳.js
+++ b/跳.js
@@ -58,6 +58,11 @@ let INFO =
(function () {
function getc (url, callback) {
+ function toResult (html) {
+ let [, c] = html.match(/\/\/([^.]+)\.\u8DF3/);
+ return ['http://' + c + '.\u8DF3.jp/', c];
+ }
+
let req = new plugins.libly.Request(
'http://xn--vt3a.jp/entry/new',
{
@@ -65,16 +70,14 @@ let INFO =
Referer : 'http://xn--vt3a.jp/'
},
{
+ asynchronous: !!callback,
postBody: 'utf8=%E2%9C%93&url=' + encodeURIComponent(url)
}
);
req.addEventListener(
'onSuccess',
- function (res) {
- let html = res.req.transport.responseText;
- let [, c] = html.match(/\/\/([^.]+)\.\u8DF3/);
- callback(c);
- }
+ function (res)
+ callback.apply(null, toResult(res.req.transport.responseText))
);
req.addEventListener(
'onFailure',
@@ -83,6 +86,7 @@ let INFO =
}
);
req.post();
+ return toResult(req.transport.responseText);
}
let innantoka = atob('aW5zdWxpbixpbmJhZ3MsaW5wYXJhenpvLGlucHVtb25pbixpbnRlbCxpbmNhdGVpa29rdSxpbmZyYXN0cnVjdHVyZSxpbmZsdWVuemEsaW5kb2NoaW5lLGltcHJlc3MsaW5kcmEsaW52ZXJ0ZXIsaW5kaWFuYXBvbGlzLGltcGhhbCxpbnRlcnByZXRlcixpbmRvc2hpbmFoYW5udG91LHlpbmxpbmdvZmpveXRveSxpbXBlZGFuY2UsaW5nZW5tYW1lLGludGVycGhvbmUsaW5kb2xlLGludGVybixpbXBhbGE=').split(',')
@@ -92,8 +96,7 @@ let INFO =
'Tundere',
function (args) {
let arg = args.literalArg.trim();
- getc(arg.length ? arg : buffer.URL, function (c) {
- let url = 'http://' + c + '.\u8DF3.jp/';
+ getc(arg.length ? arg : buffer.URL, function (url, c) {
liberator.echo('Copied: ' + url);
util.copyToClipboard(url);
});
@@ -114,6 +117,8 @@ let INFO =
true
);
+ plugins.haneru = {getc: getc};
+
})();
// vim:sw=2 ts=2 et si fdm=marker: