diff --git a/background.js b/background.js index d2f5092..77fde5f 100755 --- a/background.js +++ b/background.js @@ -54,11 +54,32 @@ isEnabled = true; // マイリス追加 currentMovieUrl = tab.url; - chrome.tabs.executeScript(null, {file: "content_script.js"}); + getMylistList(selectMylist, function(list) { + if (list.mylistitem.length < 500) { + chrome.tabs.executeScript(null, {file: "content_script.js"}); + } else { + stop("選択されたマイリストにはこれ以上動画を追加できません"); + } + }); } }); } +function getMylistList(id, callback) { + var xhr = new XMLHttpRequest; + xhr.open("GET", "http://www.nicovideo.jp/api/mylist/list/?group_id="+id, true); + xhr.onload = function(e) { + if (xhr.readyState === 4) { + if (xhr.status === 200) { + var list = JSON.parse(xhr.responseText); + callback(list); + } + } + } + xhr.send(); +} + + chrome.tabs.onUpdated.addListener(function(tabId, cahngeInfo, tab) { if(tabId == targetTabId && tab.status == 'complete') { var mvRe = /http:\/\/www.nicovideo.jp\/watch\//; @@ -100,4 +121,4 @@ default: break; } -}); \ No newline at end of file +}); diff --git a/popup.html b/popup.html index 86aab7e..33ed232 100755 --- a/popup.html +++ b/popup.html @@ -3,6 +3,7 @@ +
@@ -17,4 +18,4 @@ - \ No newline at end of file + diff --git a/save_mylist.js b/save_mylist.js index e4b44ef..9a6dd1b 100755 --- a/save_mylist.js +++ b/save_mylist.js @@ -5,4 +5,4 @@ type: 'hasAdded' }, function () {}); window.close(); -}, 500); \ No newline at end of file +}, 500);