diff options
| author | ebith | 2011-10-30 20:44:54 +0900 | 
|---|---|---|
| committer | ebith | 2011-10-30 21:23:49 +0900 | 
| commit | d40704254c20330dba9bc4d4c73d8ad70bf45dd4 (patch) | |
| tree | c5125a657db107113260e8e20619bf2481cad5cc | |
| parent | 61d0d4b5fcfaaf46e64cc6756dabc16fe1a3158c (diff) | |
| download | vimperator-plugins-d40704254c20330dba9bc4d4c73d8ad70bf45dd4.tar.bz2 | |
ニコニコ動画のマイリストを何かするプラグイン
| -rw-r--r-- | nicolist.js | 57 | 
1 files changed, 57 insertions, 0 deletions
diff --git a/nicolist.js b/nicolist.js new file mode 100644 index 0000000..0e17719 --- /dev/null +++ b/nicolist.js @@ -0,0 +1,57 @@ +/* + * ニコニコ動画のマイリストを何かするプラグイン + * http://twitter.com/ebith + */ + +commands.addUserCommand( +  ['nicolist'], +  'ニコニコ動画のマイリストを何かする', +  function(args) { +    liberator.echoerr('nicolist : サブコマンドが足りない!'); +  }, +  { +    subCommands: [ +      new Command( +        ['a[dd]'], +        'マイリストに追加する', +        function (args) { +          let video_id = content.window.wrappedJSObject.video_id; +          if (!video_id) +            return liberator.echoerr('nicolist : watchページじゃない!'); +          let token = content.window.wrappedJSObject.so.variables.csrfToken; +          let url = 'http://www.nicovideo.jp/api/mylist/add?group_id=' + args.literalArg + '&token=' + token + '&item_id=' + video_id; +          liberator.echo('nicolist add : ' + JSON.parse(util.httpGet(url).responseText).status); +        }, +        { +          literal: 0, +          completer: mylistCompleter, +        } +      ), +      new Command( +        ['j[ump]'], +        'マイリストのページに飛ぶ', +        function (args) { +          let url = 'http://www.nicovideo.jp/mylist/' + args.literalArg; +          liberator.open(url, liberator.NEW_TAB); +        }, +        { +          literal: 0, +          completer: mylistCompleter, +        } +      ), +    ] +  }, +  true +); + +function mylistCompleter (context) { +  let url = 'http://www.nicovideo.jp/api/mylistgroup/list'; +  let mylistgroup = JSON.parse(util.httpGet(url).responseText).mylistgroup; +  context.title = ["id", "title"]; +  context.filters = [CompletionContext.Filter.textDescription]; +  context.compare = void 0; +  context.completions = [ +    [v.id, v.name] +    for ([k, v] in Iterator(mylistgroup)) +  ]; +}  | 
