coursera 布局优化

视频和提词器左右布局方便跳转切换

// ==UserScript==
// @name         coursera 布局优化
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  视频和提词器左右布局方便跳转切换
// @author       jnoodle
// @include      *://www.coursera.org/*
// @match        https://www.coursera.org/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function addGlobalStyle(css) {
        var head, style;
        head = document.getElementsByTagName('head')[0];
        if (!head) { return; }
        style = document.createElement('style');
        style.type = 'text/css';
        style.id = "jnoodle_coursera";
        style.innerHTML = css;
        head.appendChild(style);
    }

    addGlobalStyle(`
     .__coursera__container { max-width: 100% !important; }
     .__coursera__container .rc-VideoMiniPlayer { width: 50% !important; position: fixed !important; left: 10px !important; right: auto !important; bottom: auto !important; }
     .__coursera__container .rc-VideoMiniPlayer.mini .video-main-player-container { right: auto !important; bottom: auto !important; width: 50% !important; left: 10px !important;}
     .__coursera__container .rc-VideoHighlightingManager { width: 48% !important; float: right !important; }
    `);

    var checkExist = setInterval(function() {
        if (document.getElementsByClassName('rc-VideoItemWithHighlighting')[0]) {
            clearInterval(checkExist);

            setTimeout(function(){

                var container = document.getElementsByClassName('rc-VideoItemWithHighlighting')[0];

                console.log('jnoodle coursera')
                console.log(container)

                container.classList.add('__coursera__container');
            }, 2000)
        }
    }, 500);

    setTimeout(function(){
        clearInterval(checkExist);
    }, 20000)

})();