Skip to content

Instantly share code, notes, and snippets.

@g-plane
Last active May 19, 2025 14:05
Show Gist options
  • Select an option

  • Save g-plane/1ae99e870abf5309ad8922e2f16867bc to your computer and use it in GitHub Desktop.

Select an option

Save g-plane/1ae99e870abf5309ad8922e2f16867bc to your computer and use it in GitHub Desktop.
Bilibili Volume Control
// ==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