Greasy Fork

Greasy Fork is available in English.

扇贝单词笔记编辑框加高, 取词自动朗读

扇贝单词笔记编辑框加大. 取词放大语音按钮 & 自动朗读英音.

目前为 2020-01-02 提交的版本,查看 最新版本

// ==UserScript==
// @name         扇贝单词笔记编辑框加高, 取词自动朗读
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  扇贝单词笔记编辑框加大. 取词放大语音按钮 & 自动朗读英音.
// @author       wowo878787
// @match        https://www.shanbay.com/review/learning/*
// @match        https://www.shanbay.com/bdc/vocabulary/*
// @match        https://www.shanbay.com/
// @grant        none
// ==/UserScript==

(function() {
    $("<style></style>").text("textarea.note-textarea{height: 350px;}\
                               .icon-volume-off:before{font-size: xx-large;}\
                               .icon-volume-up:before{font-size: xx-large;}\
                               .popover-title .speaker{display: inline-block; width: 30px;}\
                              ").appendTo($("head"));

    var will_read = false;
    var position_new, position_old

    var interval = setInterval(function(){

        is_pop = $('.popover').length

        if(is_pop === 1){
            rect = document.getElementsByClassName('popover')[0].getBoundingClientRect()
            position_new = rect.top * rect.right

            // 判断是否有取词框, 并决定朗读
            if (position_old != position_new){
                will_read = true;
                position_old = position_new
            }
            else {
                will_read = false
            }
        }
        else {
            position_old = 0
        }

        if(will_read){
            $(".speaker[data-target='uk']").click();
        }
    },900);
})();