🏠 Home 

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

Add the "Add My List" button to niconico video mylist page


Install this script?
Author's suggested script

You may also like [niconico video] Add the "Add My List" button to search r###lt page.


Install this script
  1. // ==UserScript==
  2. // @name [niconico video] Add the "Add My List" button to mylist page
  3. // @name:ja [ニコニコ動画] マイリストページからマイリストするボタンを追加
  4. // @description Add the "Add My List" button to niconico video mylist page
  5. // @description:ja マイリストページからマイリストするボタンを追加
  6. // @namespace masshiro.blog
  7. // @version 20200412
  8. // @author masshiro
  9. // @license MIT License
  10. // @match http://www.nicovideo.jp/mylist/*
  11. // @match https://www.nicovideo.jp/mylist/*
  12. // @grant none
  13. // ==/UserScript==
  14. (function () {
  15. 'use strict';
  16. var addButtons = function () {
  17. var span = document.createElement('span');
  18. span.style='color:#F00;text-decoration:underline;cursor:pointer';
  19. span.innerHTML='追加';
  20. var a = document.createElement('a');
  21. a.className = 'addmylist';
  22. a.appendChild(span);
  23. a.addEventListener('click',function () {
  24. window.open('http://www.nicovideo.jp/mylist_add/video/' + encodeURIComponent(document.querySelectorAll('.SYS_box_item')[0].querySelectorAll('a')[0].getAttribute('href').replace('watch/','')), 'nicomylistadd', 'width=500, height=400, menubar=no, scrollbars=no');
  25. },false);
  26. Array.prototype.forEach.call(document.querySelectorAll('.SYS_box_item_buttons p'), function(item,i) {
  27. if(typeof item.querySelectorAll('a.addmylist')[0] === 'undefined'){
  28. var as = a.cloneNode(true);
  29. as.addEventListener('click',function () {
  30. window.open('http://www.nicovideo.jp/mylist_add/video/' + encodeURIComponent(document.querySelectorAll('.SYS_box_item')[i].querySelectorAll('a')[0].getAttribute('href').replace('watch/','')), 'nicomylistadd', 'width=500, height=400, menubar=no, scrollbars=no');
  31. },false);
  32. item.appendChild(as);
  33. }
  34. });
  35. };
  36. var DOMObserverTimer = false;
  37. var DOMObserverConfig = {
  38. attributes: true,
  39. childList: true,
  40. subtree: true
  41. };
  42. var DOMObserver = new MutationObserver(function () {
  43. if (DOMObserverTimer !== 'false') {
  44. clearTimeout(DOMObserverTimer);
  45. }
  46. DOMObserverTimer = setTimeout(function () {
  47. DOMObserver.disconnect();
  48. addButtons();
  49. DOMObserver.observe(document.body, DOMObserverConfig);
  50. }, 100);
  51. });
  52. DOMObserver.observe(document.body, DOMObserverConfig);
  53. })();