document.addEventListener('keydown', function (event) {
if (event.key === 'g') {
document.querySelector("#bilibili-player > div > div > div.bpx-player-primary-area > div.bpx-player-sending-area > div > div.bpx-player-dm-root > div.bpx-player-dm-setting > div > div > div > div > div > div.bui-panel-item.bui-panel-item-active > div > div.bpx-player-dm-setting-left-block > div.bpx-player-dm-setting-left-block-content > div.bpx-player-block-filter-type.bpx-player-block-typeScroll").click();
🤪 这是因为给的选择器("#bilibili-player > div > div > div.bpx-player-primary-area > div.bpx-player-sending-area > div > div.bpx-player-dm-root > div.bpx-player-dm-setting > div > div > div > div > div > div.bui-panel-item.bui-panel-item-active > div > div.bpx-player-dm-setting-left-block > div.bpx-player-dm-setting-left-block-content > div.bpx-player-block-filter-type.bpx-player-block-typeScroll")太具体了,全屏模式下网页会调整 HTML 内容,导致这组选择器无法再匹配到相应的按钮,你可以改成:
document.addEventListener('keydown', function (event) {