Fix ZZZ Opera Music

Fixes the music not playing in the Opera Browser on the Zenless Zone Zero website.

  1. // ==UserScript==
  2. // @name Fix ZZZ Opera Music
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description Fixes the music not playing in the Opera Browser on the Zenless Zone Zero website.
  6. // @author WhiteTapeti
  7. // @match *://zenless.hoyoverse.com/*
  8. // @exclude *://zenless.hoyoverse.com/*.*
  9. // @icon https://animetopbtns.github.io/website/Fix%20ZZZ%20Opera%20Music/fixZZZOperaMusicV3.png
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. var loaded = 0;
  14. var audio = new Audio(
  15. "https://webstatic.hoyoverse.com/upload/static-resource/2022/04/19/aeefeb96a2a294cf1d7ab7324fd9a492_568718570249589416.mp3",
  16. );
  17. audio.loop = true;
  18. var cAudioV = 1;
  19.  
  20. var elemDivMusicTooltipMainElem = document.createElement("span");
  21. elemDivMusicTooltipMainElem.classList.add("tooltiptext");
  22. elemDivMusicTooltipMainElem.classList.add("tooltip-bottom");
  23. elemDivMusicTooltipMainElem.onclick = function(e) {
  24. e.stopPropagation();
  25. };
  26.  
  27. elemDivMusicTooltipMainElem.innerHTML = `
  28. <div class="slidecontainer">
  29. <input type="range" min="0" max="100" value="100" class="slider" id="myRange">
  30. <p style="font-size: medium;">Volume: <span id="demo"></span></p>
  31. </div>
  32. `;
  33.  
  34. setInterval(function testLoading() {
  35. if (loaded == 0) {
  36. if (document.getElementsByClassName("loading").length == 0 || document.getElementsByClassName("loading")[0].attributes.style.nodeValue == "display: none;" || document.body.contains(document.getElementsByClassName("loading")) == false) {
  37. audio.volume = 0;
  38. audio.play();
  39. getSoundAndFadeAudio(1);
  40. document.body
  41. .getElementsByClassName("m-audio-player header__bgm")[0]
  42. .appendChild(elemDivMusicTooltipMainElem);
  43. var slider = document.getElementById("myRange");
  44. var output = document.getElementById("demo");
  45. output.innerHTML = slider.value;
  46.  
  47. slider.oninput = function() {
  48. output.innerHTML = this.value;
  49. cAudioV = (this.value) / 100;
  50. audio.volume = cAudioV;
  51. };
  52. }
  53. }
  54. }, 200);
  55.  
  56. document.addEventListener("click", function(event) {
  57. if (event.target.classList.contains("m-audio-player__icon--active")) {
  58. if (!audio.paused) {
  59. //check audio is playing
  60. audio.pause();
  61. }
  62. } else if (event.target.classList.contains("m-audio-player__icon")) {
  63. if (audio.paused) {
  64. //check audio is playing
  65. audio.volume = 0;
  66. audio.play();
  67. getSoundAndFadeAudio(0);
  68. }
  69. }
  70. });
  71.  
  72. function getSoundAndFadeAudio(e) {
  73. if (e == 1) {
  74. loaded = 1;
  75. }
  76. // Set the point in playback that fadein begins.
  77. var fadePoint = audio.duration - cAudioV;
  78.  
  79. var fadeAudio = setInterval(function() {
  80.  
  81. // Only fade if past the fade in point or not at one already
  82. if ((audio.currentTime <= fadePoint) && (audio.volume !== cAudioV)) {
  83. audio.volume = Number(audio.volume + 0.01).toFixed(2);
  84. }
  85. // When volume at one stop all the intervalling
  86. if (audio.volume === cAudioV) {
  87. clearInterval(fadeAudio);
  88. }
  89. }, 20);
  90.  
  91. }
  92. var elemDivMusicTooltipMainStyle = document.createElement("style");
  93.  
  94. elemDivMusicTooltipMainStyle.innerHTML = `
  95. .header__bgm .tooltiptext {
  96. visibility: hidden;
  97. position: absolute;
  98. width: 120px;
  99. background-color: #0a0a0a;
  100. outline: solid #646464;
  101. color: #fff;
  102. text-align: center;
  103. padding: 5px 0;
  104. border-radius: 6px;
  105. z-index: 1;
  106. opacity: 0;
  107. transition: opacity .6s;
  108. cursor: auto;
  109. }
  110.  
  111. .tooltip-bottom {
  112. top: 135%;
  113. left: 50%;
  114. margin-left: -60px;
  115. }
  116.  
  117. .tooltip-bottom::after {
  118. content: "";
  119. position: absolute;
  120. bottom: 100%;
  121. left: 50%;
  122. margin-left: -9px;
  123. border-width: 9px;
  124. border-style: solid;
  125. border-color: transparent transparent #0a0a0a transparent;
  126. }
  127.  
  128. .tooltip-bottom::before {
  129. content: "";
  130. position: absolute;
  131. bottom: 100%;
  132. left: 50%;
  133. margin-left: -13px;
  134. border-width: 13px;
  135. border-style: solid;
  136. border-color: transparent transparent #646464 transparent;
  137. }
  138.  
  139. .header__bgm:hover .tooltiptext {
  140. visibility: visible;
  141. opacity: 1;
  142. padding: 9px;
  143. }
  144.  
  145. .slidecontainer {
  146. width: 100%;
  147. display: grid !important;
  148. }
  149.  
  150. .slider {
  151. -webkit-appearance: none;
  152. width: 100%;
  153. height: 15px;
  154. border-radius: 5px;
  155. background: #464646;
  156. outline: none;
  157. opacity: 0.7;
  158. -webkit-transition: .2s;
  159. transition: opacity .2s;
  160. margin-bottom: 6px;
  161. }
  162.  
  163. .slider:hover {
  164. opacity: 1;
  165. }
  166.  
  167. .slider::-webkit-slider-thumb {
  168. -webkit-appearance: none;
  169. appearance: none;
  170. width: 25px;
  171. height: 25px;
  172. border-radius: 50%;
  173. background: #d8fa00;
  174. cursor: pointer;
  175. }
  176.  
  177. .slider::-moz-range-thumb {
  178. width: 25px;
  179. height: 25px;
  180. border-radius: 50%;
  181. background: #d8fa00;
  182. cursor: pointer;
  183. }
  184. `;
  185.  
  186. document.body.append(elemDivMusicTooltipMainStyle);

QingJ © 2025

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