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

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

当前为 2018-12-23 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);