Fixing Udemy Subtitle Google Translation Issues

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

目前为 2023-05-18 提交的版本。查看 最新版本

// ==UserScript==
// @name         Fixing Udemy Subtitle Google Translation Issues
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Fix Udemy Subtitle Translate Bug, Open the Google translate and Viedo transcript to use.
// @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()
            if (lastText !== currentText) {
                toEl.html(currentText);
            }
            lastText = fromEl.html()
        }
        window.i = setInterval(check, 200);
    }
})();