make coursera subtitle better look and add forward and backword time control

将英文字幕显示在视频下方,并且鼠标悬浮/离开字幕视频暂停/继续播放,鼠标点击字幕视频暂停可以和剪切板查单词一起用,并且可以通过左箭头和右箭头按钮进行调整看的进度

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         make coursera subtitle better look and add forward and backword time control
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  将英文字幕显示在视频下方,并且鼠标悬浮/离开字幕视频暂停/继续播放,鼠标点击字幕视频暂停可以和剪切板查单词一起用,并且可以通过左箭头和右箭头按钮进行调整看的进度
// @author       babybing666
// @match        https://www.coursera.org/learn/*
// @grant        none
// ==/UserScript==

var flag=1;

function changesub(){
    var title = document.querySelector(".rc-PageHeaderControls");
    var element = document.querySelector(".rc-Phrase.active");
    var element1 = document.querySelector(".rc-InteractiveTranscript");
    var videocontrol = document.querySelector("#c-video_html5_api");
    if(flag){
        var video = document.querySelector(".video-container");
        if(element){
            title.style.display="none";
            element1.style.display = "none";
            var newnode = document.createElement('div');
            newnode.textContent=element.textContent;
            newnode.style.textAlign = "center";
            newnode.className="newSubtitle";
            newnode.onmouseleave = function(){videocontrol.play();};
            newnode.onclick=function(){
                videocontrol.pause();
                newnode.onmouseleave = "";};
            };
            newnode.onmouseover = function(){
                videocontrol.pause();
                newnode.onmouseleave = function(){videocontrol.play();};
            };
            videocontrol.onkeypress=function(e){
                if (e.keyCode == '37') {
                    //left arrow
                    videocontrol.currentTime=videocontrol.currentTime - 0.1;}
                else if (e.keyCode == '39') {
                    //right arrow
                    videocontrol.currentTime=videocontrol.currentTime + 0.1;}
            };
            video.after(newnode);
            flag = 0;
    }
    else {
        var newsub=document.querySelector('.newSubtitle');
        if(newsub){
        newsub.textContent=element.textContent;}
        else{flag=1;}
    }


}

setInterval(changesub,30);