Greasy Fork

Greasy Fork is available in English.

修正 Udemy 字幕的翻译显示问题

Fix Udemy Subtitle Translate Bug, Open the Google translate and Viedo transcript to use.

当前为 2023-06-25 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Fixing Udemy Subtitle Google Translation Issues
// @name:zh-TW   修正 Udemy 字幕的翻譯顯示問題
// @name:zh-CN  修正 Udemy 字幕的翻译显示问题
// @namespace    http://tampermonkey.net/
// @version      1.0.2
// @description  Fix Udemy Subtitle Translate Bug, Open the Google translate and Viedo transcript to use.
// @description:zh-tw  修復Udemy Subtitle Translate Bug,打開Google translate和Viedo transcript即可使用。
// @description:zh-cn 修复Udemy Subtitle Translate Bug,打开Google translate和Viedo transcript即可使用。
// @author       You
// @match        *://www.udemy.com/course/*
// @grant        none
// @license MIT
// @require  https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';
   var $ = window.jQuery;
    if (typeof window.i !== 'undefined') { clearInterval(window.i) } else {
        let lastText = ''
        function check() {
            // let toEl = $('.well--container--2edq4 span');
            let toEl = $('div[data-purpose="captions-cue-text"]');
            let fromEl = $('p[data-purpose="transcript-cue-active"] span:last')
            let currentText = fromEl.html()
            let subText = $('span[class^="well--text--"]');
            if (lastText !== currentText) {
                if(subText !== 'undefined')
                {
                    subText.html(currentText)
                }else
                {
                    toEl.html(currentText);
                }
            }
            lastText = fromEl.html()
        }
        window.i = setInterval(check, 200);
    }
})();