Last active
May 19, 2025 14:05
-
-
Save g-plane/1ae99e870abf5309ad8922e2f16867bc to your computer and use it in GitHub Desktop.
Bilibili Volume Control
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Bilibili Volume Control | |
| // @version 2025-05-19 | |
| // @description Smaller step for volume control on Bilibili video player. | |
| // @author Pig Fang | |
| // @match https://www.bilibili.com/video/* | |
| // @match https://www.bilibili.com/list/watchlater* | |
| // @match https://www.bilibili.com/bangumi/play/* | |
| // @grant none | |
| // ==/UserScript== | |
| ;(function() { | |
| const STEP = 0.03 | |
| let toastId | |
| window.addEventListener('keydown', (event) => { | |
| if (event.key === 'ArrowUp' || event.key === 'ArrowDown') { | |
| event.stopImmediatePropagation() | |
| event.preventDefault() | |
| window.player.setVolume(window.player.getVolume() + STEP * (event.key === 'ArrowUp' ? 1 : -1)) | |
| const toastOptions = { text: `${~~(window.player.getVolume() * 100)}%`, duration: 5000 } | |
| if (!window.player.toast.update(toastId, toastOptions)) { | |
| toastId = window.player.toast.create(toastOptions) | |
| } | |
| } | |
| }) | |
| })() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment