動畫瘋 回頁頂按鈕

為 動畫瘋 加上回頁頂按鈕

  1. // ==UserScript==
  2. // @name 動畫瘋 回頁頂按鈕
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description 為 動畫瘋 加上回頁頂按鈕
  6. // @license MIT
  7. // @author movwei
  8. // @match https://ani.gamer.com.tw/*
  9. // @grant GM_addStyle
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. const quickToolWrapper = document.createElement('div');
  15. quickToolWrapper.className = 'baha_quicktool';
  16. const backToTopButton = document.createElement('div');
  17. backToTopButton.className = 'quicktool iconbtn hidden';
  18. backToTopButton.innerHTML = `
  19. <svg viewBox="0 0 26.95 22.21" style="pointer-events: none;">
  20. <g>
  21. <path d="M26.37,7.06L13.55,0,.73,7.06c-.54,.3-.74,.98-.44,1.53l.31,.56c.3,.54,.98,.74,1.53,.44L13.55,3.29l11.43,6.3c.54,.3,1.23,.1,1.53-.44l.31-.56c.3-.54,.1-1.23-.44-1.53Z"></path>
  22. <g>
  23. <path d="M8.26,13.95v1.79h-3.24v6.47h-1.79v-6.47H0v-1.79H8.26Z"></path>
  24. <path d="M15.66,13.95c.93,0,1.7,.76,1.7,1.7v4.87c0,.94-.77,1.7-1.7,1.7h-4.87c-.94,0-1.7-.76-1.7-1.7v-4.87c0-.94,.76-1.7,1.7-1.7h4.87Zm-4.78,6.47h4.68v-4.68h-4.68v4.68Z"></path>
  25. <path d="M25.17,13.96c.94,0,1.71,.77,1.71,1.7v2.13c0,.93-.77,1.7-1.71,1.7h-4.77s.03,.03,.03,.08c0,0-.02,0-.03-.01v2.65h-1.78V13.96h6.55Zm-4.77,3.74h4.68v-1.96h-4.68v1.96Z"></path>
  26. </g>
  27. </g>
  28. </svg>
  29. `;
  30. GM_addStyle(`
  31. .baha_quicktool {
  32. position: fixed;
  33. right: 44px;
  34. bottom: 20px;
  35. display: flex;
  36. flex-direction: column;
  37. z-index: 1000;
  38. }
  39. .baha_quicktool .quicktool {
  40. display: flex;
  41. align-items: center;
  42. justify-content: center;
  43. padding: 16px 0;
  44. cursor: pointer;
  45. width: 60px;
  46. height: 58px;
  47. background-color: #272728;
  48. border-radius: 8px;
  49. transition: background-color 0.3s ease;
  50. }
  51. .baha_quicktool .quicktool:hover {
  52. background-color: #00B0B6;
  53. }
  54. .baha_quicktool .quicktool svg {
  55. width: 26px;
  56. height: 22px;
  57. fill: white;
  58. }
  59. .baha_quicktool .quicktool.hidden {
  60. display: none;
  61. }
  62. .top-btn {
  63. display: none !important;
  64. }
  65. `);
  66. quickToolWrapper.appendChild(backToTopButton);
  67. document.body.appendChild(quickToolWrapper);
  68.  
  69. function adjustButtonVisibility() {
  70. const promotionButton = document.querySelector('.fab-seasonal-promotion');
  71.  
  72. if (window.pageYOffset > 300) {
  73. backToTopButton.classList.remove('hidden');
  74. if (promotionButton) {
  75. promotionButton.style.bottom = '75px';
  76. }
  77. } else {
  78. backToTopButton.classList.add('hidden');
  79. if (promotionButton) {
  80. promotionButton.style.bottom = '';
  81. }
  82. }
  83. }
  84.  
  85. backToTopButton.addEventListener('click', () => {
  86. window.scrollTo({
  87. top: 0,
  88. left: 0,
  89. behavior: 'smooth'
  90. });
  91. });
  92.  
  93. adjustButtonVisibility();
  94.  
  95. window.addEventListener('scroll', adjustButtonVisibility);
  96.  
  97. const intervalCheck = setInterval(adjustButtonVisibility, 1000);
  98.  
  99. window.addEventListener('beforeunload', () => {
  100. clearInterval(intervalCheck);
  101. });
  102. })();

QingJ © 2025

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