[niconico video] Adds a botton that add mylist to search result

Adds a button that add mylist to search result

当前为 2017-02-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name [niconico video] Adds a botton that add mylist to search result
  3. // @name:ja [ニコニコ動画] 検索結果からマイリスト追加するボタンを追加
  4. // @description Adds a button that add mylist to search result
  5. // @description:ja 検索結果からマイリストするボタンを追加
  6. // @namespace masshiro.wpblog.jp
  7. // @version 0.1
  8. // @author masshiro
  9. // @match http://www.nicovideo.jp/search/*
  10. // @match http://www.nicovideo.jp/tag/*
  11. // @grant none
  12. // ==/UserScript==
  13. (function () {
  14. 'use strict';
  15.  
  16. var span = document.createElement('span');
  17. span.className = "value";
  18. span.style="color:#F00;text-decoration:underline;cursor:pointer";
  19. span.innerHTML="追加";
  20.  
  21. var li = document.createElement('li');
  22. li.appendChild(span);
  23. li.className = 'count';
  24.  
  25. li.addEventListener('click',function () {
  26. window.open("http://www.nicovideo.jp/mylist_add/video/" + encodeURIComponent(document.querySelectorAll("li[data-video-item]")[0].getAttribute("data-id")), "nicomylistadd", "width=500, height=400, menubar=no, scrollbars=no");
  27. },false);
  28.  
  29. Array.prototype.forEach.call(document.querySelectorAll("li[data-video-item] div.itemContent div.itemData ul.list"), function(item,i) {
  30. var lis = li.cloneNode(true);
  31. lis.addEventListener('click',function () {
  32. window.open("http://www.nicovideo.jp/mylist_add/video/" + encodeURIComponent(document.querySelectorAll("li[data-video-item]")[i].getAttribute("data-id")), "nicomylistadd", "width=500, height=400, menubar=no, scrollbars=no");
  33. },false);
  34. item.appendChild(lis);
  35. });
  36.  
  37. document.body.addEventListener('AutoPagerize_DOMNodeInserted',function(evt){
  38. Array.prototype.forEach.call(evt.target.querySelectorAll("li[data-video-item] div.itemContent div.itemData ul.list"), function(item,i) {
  39. var lis = li.cloneNode(true);
  40. lis.addEventListener('click', function () {
  41. window.open("http://www.nicovideo.jp/mylist_add/video/" + encodeURIComponent(evt.target.querySelectorAll("li[data-video-item]")[i].getAttribute("data-id")), "nicomylistadd", "width=500, height=400, menubar=no, scrollbars=no");
  42. },false);
  43. item.appendChild(lis);
  44. });
  45. }, false);
  46. })();
  47.  
  48.