Skip to content

Conversation

@mohamedashraf011
Copy link

Summary

This PR adds an optional hotkey to change YouTube playback speed using the mouse wheel:

  • Default behavior: Hold Alt and scroll to adjust speed by ±0.1.
  • Optional toggle: Users can switch to Ctrl + scroll via a setting.

Rationale: Ctrl + scroll is handled by the browser as page zoom and cannot be reliably prevented from a content script. Therefore, Alt + scroll is enabled by default, with an opt-in to Ctrl for users who prefer it or have page zoom disabled.

UX

  • While the modifier key is held, scrolling increases/decreases playbackRate in 0.1 steps.
  • Speed is clamped (e.g., 0.1–16).
  • A small overlay appears on the player (e.g., “1.2×”) and fades after ~1s.
  • Works on watch pages and Shorts (same player hook); excluded on /tv and audiolibrary like other features.

Settings (Player → Playback)

  • “Change speed with Alt + Scroll” [On/Off] (default: On)
  • “Use Ctrl instead of Alt (may conflict with browser zoom)” [On/Off] (default: Off)

Technical notes

  • Listens to wheel events on the player/video element.
  • Uses the modifier guard: e.altKey || (useCtrl && e.ctrlKey).
  • For trackpads/low deltas, change is applied per directional step (with a small threshold) to avoid over-sensitivity.
  • No preventDefault() on Ctrl + scroll (browser zoom takes precedence by design).
  • Keeps integration with existing playback speed state; clamping ensures no out-of-range values.

i18n

Added minimal English strings (other locales fall back to en):

  • alt_scroll_speed_name: "Change speed with Alt + Scroll"
  • alt_scroll_speed_desc: "Hold Alt and use the mouse wheel to change playback speed."
  • use_ctrl_instead_of_alt_name: "Use Ctrl instead of Alt (may conflict with browser zoom)"
  • use_ctrl_instead_of_alt_desc: "Hold Ctrl and scroll to change playback speed. Note: browsers use Ctrl + scroll for page zoom."

Testing

  • ✅ Chrome 139 / Windows: watch page, theatre, fullscreen
  • ✅ Shorts player
  • ✅ Page zoom unaffected with Alt; browser zoom remains active with Ctrl (as expected)
  • ✅ Overlay renders and disappears correctly; no layout shift
  • ✅ No new permissions; manifest unchanged (content script only)

Limitations

  • Ctrl + scroll continues to trigger browser zoom; this is expected and documented. Alt is the safe default.
  • On some trackpads, very small deltas are coalesced; we step by direction to keep UX predictable.

Screenshots/GIF (optional)

If needed I can add a short GIF demo of Alt + scroll on a watch page.

Checklist

  • Follows project contributing guidelines (feature + i18n strings)
  • English locale keys added
  • No permissions or manifest changes required for default path
  • Manually tested on watch/Shorts
  • Linked issue

Closes #3105

@ImprovedTube ImprovedTube marked this pull request as draft August 23, 2025 06:57
@ImprovedTube
Copy link
Member

hi and thanks! @mohamedashraf011

a toggle is missing in the extension popup menu. (most of all) our code only runs, when a toggle is enabling a feature.

(an english message wasnt added for that either. instead the Chinese messages were reformatted.

Can you share the methodology? /Which AI, parameters and prompt were used for what step?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💡 Allow "Dim YouTube Pages" to only dim the Watch page

2 participants