Skip to content

Instantly share code, notes, and snippets.

@ebith
Created Oct 24, 2011
Embed
What would you like to do?
ニコニコ動画のWatchページから画面遷移無くとりあえずじゃないマイリストに登録するVimperatorコマンド
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