Created
October 24, 2011 11:30
-
-
Save ebith/1308817 to your computer and use it in GitHub Desktop.
ニコニコ動画のWatchページから画面遷移無くとりあえずじゃないマイリストに登録するVimperatorコマンド
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commands.addUserCommand( | |
['addmylist'], | |
'見てる動画をマイリストに追加する', | |
function(args) { | |
let video_id = content.window.wrappedJSObject.video_id; | |
if (!video_id) | |
return liberator.echoerr('Where are you?'); | |
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('add to mylist : ' + JSON.parse(util.httpGet(url).responseText).status); | |
}, | |
{ | |
completer: function(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)) | |
]; | |
}, | |
literal: 0, | |
}, | |
true | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment