Greasy Fork

Greasy Fork is available in English.

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

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

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         扇贝单词笔记编辑框加高, 取词自动朗读
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  扇贝单词笔记编辑框加大. 取词放大语音按钮 & 自动朗读英音.
// @author       wowo878787
// @match        https://www.shanbay.com/review/learning/*
// @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();
        }
    },3000);
})();