mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
25 lines
898 B
TypeScript
25 lines
898 B
TypeScript
import { KeyBindingAction } from 'registry/lib/components/utils/keymap/bindings'
|
|
import { PluginMetadata } from '@/plugins/plugin'
|
|
import { playerAgent } from '@/components/video/player-agent'
|
|
|
|
export const plugin: PluginMetadata = {
|
|
name: 'keymap.actions.toggleSubtitle',
|
|
displayName: '快捷键扩展 - 开关 CC 字幕',
|
|
description: '在快捷键的动作列表里添加一个 "开关 CC 字幕".',
|
|
setup: ({ addData }) => {
|
|
addData('keymap.actions', (actions: Record<string, KeyBindingAction>) => {
|
|
actions.toggleSubtitle = {
|
|
displayName: '开关 CC 字幕',
|
|
run: async () => {
|
|
const button = playerAgent.query.control.buttons.subtitle.sync()
|
|
button?.click()
|
|
return button
|
|
},
|
|
}
|
|
})
|
|
addData('keymap.presets', (presetBase: Record<string, string>) => {
|
|
presetBase.toggleSubtitle = 'shift c'
|
|
})
|
|
},
|
|
}
|