Greasy Fork

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

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

// ==UserScript==
// @name         扇贝单词笔记编辑框加高, 取词自动朗读
// @namespace    http://tampermonkey.net/
// @version      0.31
// @description  扇贝单词笔记编辑框加大. 取词放大语音按钮 & 自动朗读英音.
// @author       wowo878787
// @require      https://code.jquery.com/jquery-1.11.0.min.js
// @match        https://www.shanbay.com/review/learning/*
// @match        https://web.shanbay.com/wordsweb/*
// @match        https://www.shanbay.com/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...

$.noConflict();

(function($) {
  $(function() {
    $("<style></style>")
      .text(
        "\
        textarea.note-textarea{height: 350px;}\
        \
        .resultModal .resultContent .resultContent-pronunciation .pronunciationItem .pronunciationItem-icon{width: 33px;height: 33px;}\
        \
        .index_transBox__2yUO4 .index_audio__305yO .index_trumpet__2KSpA{width: 33px;}\
        .index_transBox__2yUO4 .index_audio__305yO{height: 35px;}\
        "
      )
      .appendTo($("head"));

    var will_read = false;
    var input_new, input_old;

    var interval = setInterval(function() {
      var is_pop_in_head = $(".resultModal").length; // 页头
      var is_pop_in_detail = $(".index_transBox__2yUO4").length; // 详情取词

      if (is_pop_in_head === 1) {
        input_new = $(".resultContent .head-word").text();
      } else if (is_pop_in_detail === 1) {
        input_new = $(".index_vocab__3Dqmq span:first").text();
      }

      if (input_old != input_new) {
        will_read = true;
        input_old = input_new;
      } else {
        will_read = false;
      }

      if (will_read) {
        if (is_pop_in_head === 1) {
          $(".resultContent-pronunciation")
            .find(".pronunciationItem")
            .eq(1)
            .children("i")
            .click();
        } else if (is_pop_in_detail === 1) {
          $(".index_transBox__2yUO4")
            .find(".index_audio__305yO")
            .eq(1)
            .children(".index_trumpet__2KSpA")
            .click();
        }
      }
    }, 900);
  });
})(jQuery);

// Your code end...

})();