3rdUnknown / SlowMobius

// ==UserScript==
// @name         SlowMobius
// @namespace    https://my.stratoplan.net/
// @version      0.009
// @description  Time control is now possible!
// @author       3rdUnknown
// @author       Special thanks go to Sergey
// @copyright    2019
// @license      MIT
// @match        https://my.stratoplan.net/lesson/*
// @grant        none
// @run-at       document-idle
// @updateURL    https://openuserjs.org/meta/3rdUnknown/SlowMobius.meta.js
// ==/UserScript==

function slowMobius(speed) {
    document.querySelector('video').playbackRate = speed;

    jQuery('div.vjs-playback-rate-value').text((speed+'x'));
    console.log('Time: '+speed+'x');
}

function unlockRate() {
    let el1 = document.getElementsByClassName("vjs-playback-rate");
    el1[0].classList.remove('vjs-hidden');

    el1[0].innerHTML ='<button class="vjs-playback-rate vjs-menu-button vjs-menu-button-popup vjs-button" type="button" aria-disabled="false" title="Playback Rate" aria-haspopup="true" aria-expanded="false"> \
<span aria-hidden="true" class="vjs-icon-placeholder"></span> \
<span class="vjs-control-text" aria-live="polite">Playback Rate</span> \
</button> \
<div class="vjs-menu"> \
<ul class="vjs-menu-content" role="menu"> \
<li class="vjs-menu-item vjs-quality-item" tabindex="-1" role="menuitemradio" aria-disabled="false" aria-checked="true"> \
<span class="vjs-menu-item-text vjs-playback-rate-item">1x</span> \
<span class="vjs-control-text" aria-live="polite"></span> \
</li> \
<li class="vjs-menu-item vjs-quality-item" tabindex="-1" role="menuitemradio" aria-disabled="false" aria-checked="false"> \
<span class="vjs-menu-item-text  vjs-playback-rate-item">1.1x</span> \
<span class="vjs-control-text" aria-live="polite"></span> \
</li> \
<li class="vjs-menu-item vjs-quality-item" tabindex="-1" role="menuitemradio" aria-disabled="false" aria-checked="false"> \
<span class="vjs-menu-item-text  vjs-playback-rate-item">1.2x</span> \
<span class="vjs-control-text" aria-live="polite"></span> \
</li> \
<li class="vjs-menu-item vjs-quality-item" tabindex="-1" role="menuitemradio" aria-disabled="false" aria-checked="false"> \
<span class="vjs-menu-item-text  vjs-playback-rate-item">1.3x</span> \
<span class="vjs-control-text" aria-live="polite"></span> \
</li> \
<li class="vjs-menu-item vjs-quality-item" tabindex="-1" role="menuitemradio" aria-disabled="false" aria-checked="false"> \
<span class="vjs-menu-item-text  vjs-playback-rate-item">1.4x</span> \
<span class="vjs-control-text" aria-live="polite"></span> \
</li> \
<li class="vjs-menu-item vjs-quality-item" tabindex="-1" role="menuitemradio" aria-disabled="false" aria-checked="false"> \
<span class="vjs-menu-item-text  vjs-playback-rate-item">1.5x</span> \
<span class="vjs-control-text" aria-live="polite"></span> \
</li> \
<li class="vjs-menu-item vjs-quality-item" tabindex="-1" role="menuitemradio" aria-disabled="false" aria-checked="false"> \
<span class="vjs-menu-item-text  vjs-playback-rate-item">1.6x</span> \
<span class="vjs-control-text" aria-live="polite"></span> \
</li> \
<li class="vjs-menu-item vjs-quality-item" tabindex="-1" role="menuitemradio" aria-disabled="false" aria-checked="false"> \
<span class="vjs-menu-item-text  vjs-playback-rate-item">1.7x</span> \
<span class="vjs-control-text" aria-live="polite"></span> \
</li> \
<li class="vjs-menu-item vjs-quality-item" tabindex="-1" role="menuitemradio" aria-disabled="false" aria-checked="false"> \
<span class="vjs-menu-item-text  vjs-playback-rate-item">1.8x</span> \
<span class="vjs-control-text" aria-live="polite"></span> \
</li> \
<li class="vjs-menu-item vjs-quality-item" tabindex="-1" role="menuitemradio" aria-disabled="false" aria-checked="false"> \
<span class="vjs-menu-item-text  vjs-playback-rate-item">1.9x</span> \
<span class="vjs-control-text" aria-live="polite"></span> \
</li> \
<li class="vjs-menu-item vjs-quality-item" tabindex="-1" role="menuitemradio" aria-disabled="false" aria-checked="false"> \
<span class="vjs-menu-item-text vjs-playback-rate-item">2x</span> \
<span class="vjs-control-text" aria-live="polite"></span> \
</li> \
</ul> \
</div> \
<div class="vjs-playback-rate-value">1x</div>'
    console.log('Time control module was injected');
}

function setSpeed() {
    jQuery('span.vjs-playback-rate-item').each(function(index, value) {
        jQuery(this).on('click.rate', function(){slowMobius((1 + index * 0.1).toFixed(2))});
    });
}

setTimeout(function() {
    unlockRate();
    setSpeed();
}, 2000);