// ==UserScript== // @name UOOCauto // @namespace http://tampermonkey.net/ // @version 0.1 // @description UOOC优课联盟,视频自动二倍速播放,离开页面继续播放,自动回答视频中途弹出问题;目前执行的时候页面可能比较奇怪,但是可以无视;如果视频一开始处于停止状态,可以手动点击播放;【有问题可以进行反馈】 // @author cc // @include * // @grant none // @downloadURL none // ==/UserScript== (function () { 'use strict'; const jsName = 'UOOCauto.js'; const host = window.location.host; if (host == 'www.uooc.net.cn') { console.log(`excute ${jsName}`); let recursive = () => { let extraTime = 0; let video = document.querySelector('#player_html5_api'); if (video) { video.playbackRate = 2; video.autoplay = true; let quizLayer = document.querySelector('#quizLayer'); if (quizLayer) { let sourcc = JSON.parse(document.querySelector('div[uooc-video]').getAttribute('source')); let quizList = sourcc.quiz; let quizIndex = 0; let currentTime = video.currentTime; for (let i = 0; i < quizList.length; i++) { if (Math.abs(eval((quizList[i].set_time) - currentTime)) <= 5) { quizIndex = i; break; }; }; let quizAnswer = eval(quizList[quizIndex].answer); let quizOptions = quizLayer.querySelector('div.ti-alist'); for (let ans of quizAnswer) { let labelIndex = ans.charCodeAt() - 'A'.charCodeAt(); quizOptions.children[labelIndex].click(); }; // end for quizLayer.querySelector('button').click(); extraTime = 1000; }; // end if if (video.paused && !video.ended) { try { video.play(); } catch (e) { // do nothing } }; // end if }; // end if setTimeout(recursive, 250 + extraTime); }; // end recursive recursive(); } })();