ニコニコ動画 いいねしてくれた人を見ながら表示

アナリティクスに飛ばずにいいね一覧を重ねて表示します

  1. // ==UserScript==
  2. // @name ニコニコ動画 いいねしてくれた人を見ながら表示
  3. // @namespace tanbatu
  4. // @version 0.1
  5. // @description アナリティクスに飛ばずにいいね一覧を重ねて表示します
  6. // @author You
  7. // @match https://*.nicovideo.jp/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=nicovideo.jp
  9. // @license MIT
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. "use strict";
  15.  
  16. setInterval(function () {
  17. let list = document.querySelectorAll(".common-header-d2321f");
  18. list.forEach((list) => {
  19. if (
  20. list.href.startsWith(
  21. "https://www.upload.nicovideo.jp/nv-garage/videos/"
  22. )
  23. ) {
  24. let id = list.href.split("/")[5];
  25. list.addEventListener("click", function () {
  26. ex_showList(id);
  27. });
  28. list.href = "javascript:void(0)";
  29. list.target = "";
  30. }
  31. });
  32. }, 100);
  33.  
  34. function formatDate(date) {
  35. let y = date.getFullYear();
  36. let m = date.getMonth() + 1;
  37. let d = date.getDate();
  38. let h = date.getHours();
  39. let mn = date.getMinutes();
  40.  
  41. return `${y}/${m}/${d} ${h}:${mn}`;
  42. }
  43. function ex_showList(id) {
  44. document.querySelector(".CommonHeader").insertAdjacentHTML(
  45. "afterend",
  46. `<div id='ex_likelist'>
  47. <a href="https://www.upload.nicovideo.jp/nv-garage/analytics/videos/"`+id+`>アナリティクスへ</a>
  48. <a href="javascript:document.querySelector('#ex_likelist').remove()" style="position:absolute;right:0">閉じる</a>
  49.  
  50. </div>
  51. <style>
  52. #ex_likelist{
  53. overflow-y:scroll;
  54. box-shadow: rgba(0,0,0,0.2) 0px 0px 6px;
  55. position:fixed;
  56. z-index:999;
  57. bottom:0px;
  58. right:0px;
  59. width:300px;
  60. height:calc(100vh - 36px);
  61. background-color:rgba(255, 255, 255)
  62. }
  63. .likeuser{
  64. border-bottom: solid 1px #00000026;
  65. padding:8px;
  66. width: 100%;
  67. background: white;
  68. margin: 0 auto;
  69. }
  70. </style>`
  71. );
  72.  
  73. fetch(
  74. `https://nvapi.nicovideo.jp/v2/users/me/videos/${id}/likes?sort=premiumPriority&pageSize=25&page=1`,
  75. {
  76. headers: {
  77. accept: "*/*",
  78. "sec-fetch-mode": "cors",
  79. "x-frontend-id": "25",
  80. "x-request-with": "nv-garage",
  81. },
  82. referrer: "https://www.upload.nicovideo.jp/",
  83. method: "GET",
  84. credentials: "include",
  85. }
  86. )
  87. .then((response) => response.json())
  88. .then((data) => {
  89. console.log(data);
  90. data.data.items.forEach((items) => {
  91. document.querySelector("#ex_likelist").insertAdjacentHTML(
  92. "beforeend",
  93. `
  94. <a href="https://www.nicovideo.jp/user/${items.user.id}" target="_blank">
  95. <div class="likeuser" style="display:flex" >
  96. <img style="border-radius: 100%;
  97. height: 50px;" src=${items.user.icons.large}></img>
  98. <div style="margin-left:7px;"><h3 style="color:#363636">
  99. ${items.user.nickname}
  100. </h3>
  101. <p>${formatDate(new Date(items.like.likedAt))}
  102. </p></div></div></a>
  103. `
  104. );
  105. });
  106. });
  107. }
  108. })();