Coursera - auto play next video

Coursera Extension to automatically go to the next video when the video is over (prevents annoying purchase certificate banners)

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

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

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

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name            Coursera - auto play next video
// @description     Coursera Extension to automatically go to the next video when the video is over (prevents annoying purchase certificate banners)
// @version         1.0
// @namespace       https://www.github.com/sh0oki/coursera-autoplay
// @source          https://www.github.com/sh0oki/coursera-autoplay
// @include         https://*.coursera.org/learn/*/lecture/*/*
// @match           https://*.coursera.org/learn/*/lecture/*/*
// @require         https://code.jquery.com/jquery-2.2.3.min.js
// @copyright       2016, sh0oki
// ==/UserScript==

function mainWrapper() {
    var debug = false;
    var US_SHORT_NAME = 'CEXT';
    var US_VERSION = 1.0;
    
    function debugLog(msg) {
        if (!debug) return;
        console.log(US_SHORT_NAME + ": " + msg);
    }
    
    function main() {
        v = $('video');
        if (v.length === 0) {
            setTimeout(main, 300);
            return;
        }
        v[0].addEventListener("ended", function(){
            debugLog("Video ended");
            if (configuredAutoNext()) {
                $('div.right-actions a').last()[0].click()
            }
        });
    }
    
    function configuredAutoNext() {
        b = $('.c-autoplay-button-container button.selected')[0];
        return b.classList.contains("c-autoplay-on-button");
    }
    
    main();
};

$(document).ready(function() {
    mainWrapper()
});