Coursera Translator

coursera课程翻译

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Coursera Translator
// @namespace    jiaowobanxianer.com
// @version      1.0
// @description  coursera课程翻译
// @author       JiaoWoBanXianEr
// @match        https://www.coursera.org/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=baidu.com
// @grant        none
// ==/UserScript==
//字幕颜色RGB
let color = '#ffff22';
//字幕背景颜色ARGB
let bgColor = "#7f7f7f7f";
//字幕大小PX
let fontSize = 60
//字幕距底部距离Percent
let up = 10;


let t;

function translate() {
    if (document.getElementById('sub_container') == null) {
        init();
    }
    if (t == null) {
        return;
    }
    let text = document.querySelector('.rc-Phrase.active.css-ugczj4');
    if (text == null) {
        return;
    }
    t.textContent = text.outerText;
}
var i = setInterval(function () { translate(); }, 100);

function init() {
    if (document.querySelector('.vjs-react.c-video.vjs-fluid.vjs-circle-play-centered') == null) { return; }
    t = document.createElement("div");
    t.id = "sub_container";
    t.style.position = 'absolute';
    t.style.margin = 'auto';
    t.style.textAlign = 'center';
    t.style.zIndex = 99;
    t.style.height = fontSize + 'px';
    t.style.left = 0;
    t.style.right = 0;
    t.style.top = up + '%';
    t.style.backgroundColor = bgColor;
    t.style.fontSize = fontSize + 'px';
    t.style.color = color;
    //t.innerHTML = '<div id="sub_container" style="z-index: 99; position: absolute; top: 10%; left: auto; right: auto; height: 60px; margin: auto; text-align: center; background-color: rgb(127, 127, 127); font-size: 60px; color: rgb(255, 255, 34);">初始化</div>'
    document.querySelector('.vjs-react.c-video.vjs-fluid.vjs-circle-play-centered').appendChild(t);
}
(function () {
    'use strict';

    // Your code here...
})();