YouTube Volume Mouse Controller - Alt Key Modifier

Modifies YouTube Volume Mouse Controller to only work with Alt + Mousewheel

目前為 2025-03-14 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name YouTube Volume Mouse Controller - Alt Key Modifier
  3. // @version 1.0.0
  4. // @description Modifies YouTube Volume Mouse Controller to only work with Alt + Mousewheel
  5. // @match *://www.youtube.com/*
  6. // @grant none
  7. // @run-at document-start
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. 'use strict';
  12.  
  13. function handleWheelEvent(event) {
  14. if (!event.altKey) {
  15. // Stop the event from propagating further (to the original script)
  16. event.stopPropagation();
  17. event.stopImmediatePropagation();
  18. }
  19. // If Alt *is* pressed, do nothing, allowing the event to continue normally
  20. }
  21.  
  22. // Use capturing phase to intercept events *before* they reach other listeners
  23. document.addEventListener('wheel', handleWheelEvent, { capture: true, passive: false });
  24. document.addEventListener('mousewheel', handleWheelEvent, { capture: true, passive: false });
  25. document.addEventListener('DOMMouseScroll', handleWheelEvent, { capture: true, passive: false });
  26. })();