enetedu.com自动播放下一集

自动播放下一集

// ==UserScript==
// @name         enetedu.com自动播放下一集
// @namespace    http://tampermonkey.net/
// @version      0.1.2
// @description  自动播放下一集
// @author       moxiaoying
// @match        https://a.gp.enetedu.com/MyCourse/Process*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=enetedu.com
// @grant        none
// @run-at       document-end
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    const sleep = async (time_delay) => {
        return new Promise(resolve => {
            setTimeout(() => {
                resolve()
            }, time_delay*1000)
        })
    }
    const iframe = document.querySelector('body > div > table:nth-child(13) > tbody > tr > td > table:nth-child(2) > tbody > tr > td > table:nth-child(2) > tbody > tr > td:nth-child(2) > table:nth-child(1) > tbody > tr > td > table:nth-child(1) > tbody > tr > td:nth-child(3) > form > table > tbody > tr > td:nth-child(2) > iframe')
    async function main(){
        await sleep(3)
        // const video = await elmGetter.get('video',iframe.contentDocument);
        // video.play()

        // 倍速
        // video.playbackRate = 4
        const video = iframe.contentDocument.getElementsByTagName('video')[0]
        //debugger
        //video.play()
        video.onended = (e)=> {
            const nextEl = document.querySelectorAll('.tishivalju')
            if(nextEl.length===1 && nextEl[nextEl.length-1].textContent.includes('没有了')){
                alert('当前章节已学习完毕,请手动选择下一章节')
                return
            }
            nextEl[nextEl.length-1].click()
        }

    }
    main()

})();