[niconico video] Add the "Add My List" button to search result page

Add the "Add My List" button to niconico video search result page

当前为 2020-04-11 提交的版本,查看 最新版本

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