Greasy Fork is available in English.
ischinese
当前为
// ==UserScript==
// @name autoplay
// @namespace http://tampermonkey.net/
// @version 0.1.3
// @description ischinese
// @author qiu6406
// @match https://ischinese.cn/*
// @icon https://www.google.com/s2/favicons?domain=ischinese.cn
// @grant none
// ==/UserScript==
(function () {
'use strict';
var sections = document.getElementsByClassName("sectionNum");
var items = document.getElementsByClassName("buyCourse_itemMain")
var cursec = 0;
//获取当前播放位置
function getCurSec() {
if (getCurSec == sections.length) {
console.log('学习完毕!')
return -1;
}
for (var i = 0; i < sections.length; i++) {
if (sections[i].parentNode.className == "active") {
cursec = i;
}
}
}
//页面判断
function checkUrl() {
if (window.location.href.indexOf('play')) {
return 1;
} else if (window.location.href.indexOf('buycourse')) {
return 2;
} else {
return -1;
}
}
//自动播放执行
function check() {
var video = document.getElementsByTagName("video")[0];
getCurSec();
if (video.currentTime == video.duration) {
console.log("播放下一节");
cursec = cursec + 1;
sections[cursec].click();
}
else {
if (video.paused) {
video.play();
}
console.log('播放中第' + (cursec + 1) + '节:' + video.currentTime / video.duration * 100 + '%')
}
}
function init() {
switch (checkUrl()) {
case -1:
console.log("未找到正确页面");
break;
case 1:
console.log('准备播放');
check();
break;
case 2:
console.log('课程页面');
break;
}
}
setInterval(init, 10000);
})();