Skip to content

Instantly share code, notes, and snippets.

@ebith
Created October 24, 2011 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebith/1308817 to your computer and use it in GitHub Desktop.
Save ebith/1308817 to your computer and use it in GitHub Desktop.
ニコニコ動画の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