慕课倍速播放

调整超星慕课的播放速度

As of 2020-10-17. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey 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 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.

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

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

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         慕课倍速播放
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  调整超星慕课的播放速度
// @author       You
// @match        https://mooc1-1.chaoxing.com/mycourse/studentstudy?*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var $ = window.$;
    var speed = `
    <div id="control-bar" style="position:fixed;top:10px;left:10px;font-size:14px;border:1px solid black;padding:2px;">
        播放速度
        <input type="number" id="speed-input" min="0.5" step="0.1" value="1">
    </div>`;

    $('html').append(speed);
    $('#speed-input').on('change', function() {

        let firstIframe = document.getElementById('iframe');
        let firstIframeDoc = (firstIframe.contentDocument) ? firstIframe.contentDocument : firstIframe.contentWindow.document;

        let secondIframe = firstIframeDoc.getElementsByClassName("ans-attach-online")[0];
        let secondIframeDoc = (secondIframe.contentDocument) ? secondIframe.contentDocument : secondIframe.contentWindow.document;

        let video = secondIframeDoc.getElementById('video_html5_api');

        video.playbackRate = this.value;
        video.play();
    });
})();