Kick.com Mouse audio controls

Kick.com Mouse audio controls (middle click: mute | scroll: adjust volume)

  1. // ==UserScript==
  2. // @name Kick.com Mouse audio controls
  3. // @namespace Sky3
  4. // @version 1.0
  5. // @description Kick.com Mouse audio controls (middle click: mute | scroll: adjust volume)
  6. // @author Sky3
  7. // @match https://kick.com/*
  8. // @license MIT
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. let prevScrollDate = 0;
  16.  
  17. function addHandlers() {
  18. const videoElement = document.getElementById('video-player');
  19. videoElement.addEventListener('mousedown', (event) => {
  20. if (event.button == 1) {
  21. videoElement.muted = !videoElement.muted;
  22. event.preventDefault();
  23. event.stopPropagation();
  24. }
  25. });
  26.  
  27. videoElement.addEventListener('wheel', (event) => {
  28. if (videoElement.muted) return;
  29.  
  30. event.preventDefault();
  31. event.stopPropagation();
  32.  
  33. const shouldIncrease = event.deltaY < 0;
  34. const volume = videoElement.volume;
  35.  
  36. if ((volume == 0 && !shouldIncrease) || (volume == 1 && shouldIncrease)) return;
  37.  
  38. const now = Date.now(), since = now - prevScrollDate
  39. const step = (shouldIncrease ? 1 : -1) * (since < 50 ? 4 : 1) * .01
  40.  
  41. videoElement.volume += step;
  42.  
  43. prevScrollDate = now
  44. });
  45. }
  46.  
  47. setTimeout(() => {
  48. addHandlers();
  49. }, 2000);
  50. })();

QingJ © 2025

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