扇贝快捷键增强

扇贝快捷键增强增强

目前为 2021-03-04 提交的版本。查看 最新版本

// ==UserScript==
// @name         扇贝快捷键增强
// @namespace    DIYgod
// @version      1.0
// @description  扇贝快捷键增强增强
// @author       DIYgod
// @match        https://web.shanbay.com/wordsweb/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    document.addEventListener('keydown', (e) => {
        const nextBtn = document.querySelector('.StudyPage_nextBtn__1ygGn');
        if (e.key === '1' && nextBtn) {
            nextBtn.click();
            e.stopPropagation();
        }
        // 单词
        const pronounceBtn1 = document.querySelector('.Pronounce_audio__3xdMh');
        if (e.key === '3' && pronounceBtn1) {
            pronounceBtn1.click();
            e.stopPropagation();
        }
        // 例句
        const pronounceBtn2 = document.querySelector('.index_icon__1IK2K');
        if (e.key === '4' && pronounceBtn2) {
            pronounceBtn2.click();
            e.stopPropagation();
        }
        // 单词
        const pronounceBtn3 = document.querySelector('.index_trump__3bTaM');
        if (e.key === '3' && pronounceBtn3) {
            pronounceBtn3.click();
            e.stopPropagation();
        }
        // 全屏
        if (e.key === 'f') {
            const studyPage = document.querySelector('.study-page');
            studyPage.style.backgroundColor = '#fff';
            studyPage.style.overflow = 'scroll';
            studyPage.requestFullscreen();
        }
    }, true);
    // Your code here...
})();