coursera开启中英双字幕(coursera subtitle CN+EN)

添加了coursera视频开启和关闭中英双字幕的功能

Autor
zhhsh
Dnevne instalacije
0
Ukupnih instalacija
1.697
Ocjene
2 1 0
Verzija
0.1
Stvoreno
29.04.2019.
Ažurirano
29.04.2019.
Licenza
N/A
Primjenjuje se

if you want to change the subtitles of other languages or add more subtitles, change the language tag of subtitles in line 36:'["en", "zh-CN"]'

核心代码如下:

    var myvideo = document.getElementsByTagName('video')[0];
    for (var i = 0; i < myvideo.textTracks.length; i++) {
        ["en", "zh-CN"].indexOf(myvideo.textTracks[i].language) > -1 ? myvideo.textTracks[i].mode = "showing" : myvideo.textTracks[i].mode = "hidden";
    }

不使用脚本或脚本失效时,只需在控制台执行以上代码,就能开启双字幕,但是每次切换视频都要重新执行一遍 核心代码是从别人的文章里看来的,来源