aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorebith2014-02-15 07:09:03 +0900
committerebith2014-02-15 07:09:03 +0900
commit3b290246be03aedb80f365f3397539417ce2d2fa (patch)
treead3795fe19675b78414e1105cb97208c462a40eb
parentc550b8f4cc522063223884521785df5664f75666 (diff)
downloadvimperator-plugins-3b290246be03aedb80f365f3397539417ce2d2fa.tar.bz2
今のニコニコ動画に対応
-rw-r--r--nicolist.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/nicolist.js b/nicolist.js
index c4892d9..3c19fcc 100644
--- a/nicolist.js
+++ b/nicolist.js
@@ -45,13 +45,13 @@ commands.addUserCommand(
['a[dd]'],
'マイリストに追加する',
function (args) {
- let video_id = content.window.wrappedJSObject.video_id;
+ let video_id = content.window.wrappedJSObject.WatchJsApi.video.getVideoID();
if (!video_id) {
return liberator.echoerr('nicolist : watchページじゃない!');
}
let [mylist_id, description] = args;
if (!description){ description = ''; } //undefinedが入っているとそれをマイリストコメントにしてしまうので。
- let token = content.window.wrappedJSObject.so.variables.csrfToken;
+ let token = getToken(true);
let url = 'http://www.nicovideo.jp/api/mylist/add?group_id=' + mylist_id + '&token=' + token + '&item_id=' + video_id + '&description=' + description;
liberator.echo('nicolist add : ' + JSON.parse(util.httpGet(url).responseText).status);
},
@@ -160,7 +160,12 @@ function sorter (a, b) {
return - (a.create_time - b.create_time);
}
-function getToken () {
- let url = 'http://www.nicovideo.jp/my/mylist';
- return util.httpGet(url).responseText.match(/NicoAPI\.token.+/)[0].match(/\d{5}-\d{10}-[\d\w]{40}/)[0];
+function getToken (isWatchPage) {
+ if (isWatchPage) {
+ let watchAPIData = JSON.parse(content.document.wrappedJSObject.getElementById('watchAPIDataContainer').firstChild.nodeValue);
+ return watchAPIData.flashvars.csrfToken;
+ } else {
+ let url = 'http://www.nicovideo.jp/my/mylist';
+ return util.httpGet(url).responseText.match(/NicoAPI\.token.+/)[0].match(/\d{5}-\d{10}-[\d\w]{40}/)[0];
+ }
}