顯示動畫瘋封面 & 視覺圖

在動畫瘋網站顯示該集封面 & 視覺圖

目前为 2022-11-24 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 顯示動畫瘋封面 & 視覺圖
  3. // @namespace https://github.com/zica87/self-made-userscipts
  4. // @version 1.0
  5. // @description 在動畫瘋網站顯示該集封面 & 視覺圖
  6. // @author zica
  7. // @match https://ani.gamer.com.tw/animeVideo.php?sn=*
  8. // @grant none
  9. // @license GPL-2.0
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. // 顯示視覺圖
  16. const visual = document.createElement('img');
  17. visual.src = document.getElementsByName('thumbnail')[0].content;
  18. Object.assign(visual.style, {
  19. maxHeight: '40rem',
  20. float: 'right',
  21. margin: '10px 10px auto 10px'
  22. });
  23. document.getElementsByClassName('anime-title')[0].prepend(visual);
  24. document.getElementsByClassName('anime-ad')[0].style.position = 'static';
  25.  
  26. // 顯示封面
  27. const cover = document.createElement('img');
  28. Object.assign(cover.style, {
  29. width: '100%',
  30. maxWidth: 'initial',
  31. height: '100%',
  32. objectFit: 'contain',
  33. });
  34.  
  35. const video_container_observer = new MutationObserver((video_container_elements, video_container_observerInstance) => {
  36. video_container_observerInstance.disconnect();
  37. const ani_video_observer = new MutationObserver((ani_video_elements, ani_video_observerInstance) => {
  38. const ncc = document.getElementsByClassName('video-cover-ncc')[0];
  39. if (ncc) {
  40. ani_video_observerInstance.disconnect();
  41. const dummyVideo = document.getElementById('ani_video_html5_api');
  42. if (dummyVideo) {
  43. cover.src = dummyVideo.poster;
  44. const agreeButton = document.getElementById('adult');
  45. cover.onclick = () => {
  46. cover.remove();
  47. agreeButton.click();
  48. };
  49. }
  50. else {
  51. // 需要年齡驗證
  52. cover.src = get_cover_url();
  53. cover.onclick = () => {
  54. cover.remove();
  55. ncc.hidden = false;
  56. };
  57. }
  58. ncc.before(cover);
  59. ncc.hidden = true;
  60. }
  61. });
  62. ani_video_observer.observe(video_container_elements[0].addedNodes[0], {
  63. childList: true,
  64. subtree: true
  65. });
  66. });
  67. video_container_observer.observe(document.getElementById('video-container'), {
  68. childList: true
  69. });
  70.  
  71. function get_cover_url() {
  72. const allScript = document.getElementsByTagName('script');
  73. const someScript = allScript[allScript.length - 1].textContent;
  74. // example:
  75. // <script>
  76. // animefun.videoSn = 31725;
  77. // animefun.poster = 'https://p2.bahamut.com.tw/B/2KU/40/1b6bfb1aa1636596a99ef069081j21w5.JPG';
  78. const ed = someScript.search('\';');
  79. // [18] == '=' (in front of 31725)
  80. const st = someScript.slice(18, ed).search('\'');
  81. const cover_url = someScript.slice(st + 18 + 1, ed);
  82. return cover_url;
  83. }
  84. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址