Greasy Fork is available in English.
ischinese
当前为
// ==UserScript==
// @name autoplay
// @namespace http://tampermonkey.net/
// @version 0.1.4
// @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 checkUrl() {
if (window.location.href.indexOf('play') > 0) {
return 1;
} else if (window.location.href.indexOf('buycourse') > 0) {
return 2;
} else {
return -1;
}
}
//获取课程位置并跳转
function getPlayItem() {
var pg = new RegExp("\\d*%","g");
for (var i = 0; i < items.length; i++) {
if(pg.exec(items[i].innerText) != '100%'){
console.log("点击");
items[1].getElementsByClassName('buyCourse_classStudy')[0].click();
break;
}
}
}
//获取当前播放位置
function getCurSec() {
if (getCurSec == sections.length) {
console.log('学习完毕!')
window.location = "https://ischinese.cn/learncenter/buycourse";
}
for (var i = 0; i < sections.length; i++) {
if (sections[i].parentNode.className == "active") {
cursec = i;
}
}
}
//自动播放执行
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:
check();
break;
case 2:
console.log('课程页面');
getPlayItem();
break;
}
}
setInterval(init, 10000);
})();