var lang = (navigator.systemLanguage ? navigator.systemLanguage: navigator.language);
var text = lang.substr(0, 2);
var status = 0;
if (text == 'zh') {
status = 0;
} else {
status = 1;
}
(function() {
Refresh();
window.onload = readPdf();
})();
async function readPdf() {
let j = 0;
let i = 0;
for (; j < document.getElementsByTagName("dd").length;) {
if (status == 0) {
if (document.getElementsByTagName("dd")[j].children[1].innerText != "已完成") {
i = j;
break;
} else {++j;
}
} else {
if (document.getElementsByTagName("dd")[j].children[1].innerText != "Finished") {
i = j;
break;
} else {++j;
}
}
}
if(j == document.getElementsByTagName("dd").length ){
alert("本章已全部完成!请手动切换到下一章。");
return;
}
for (; i < document.getElementsByTagName("dd").length; i++) {
document.getElementsByTagName("dd")[i].click();
console.log(document.getElementsByClassName("pdfwarp dpn").length);
if (document.getElementsByClassName("pdfwarp dpn").length > 0) {
document.getElementsByClassName("pdfwarp dpn")[0].children[2].click();
if (document.getElementsByTagName("dd")[i].children[1].innerText != "已完成") {
if (document.getElementsByTagName("video").length > 0) {
break;
}
await sleep(3000);
while (document.getElementsByTagName("dd")[i].children[1].innerText != "已完成") {
console.log(document.getElementsByTagName("dd")[i].children[1].innerText);
document.getElementById("pdf").contentWindow.document.getElementsByClassName("toolbarButton pageDown")[0].click();
await sleep(1000);
document.getElementById("pdf").contentWindow.document.getElementsByClassName("toolbarButton pageDown")[0].click();
await sleep(1000);
document.getElementById("pdf").contentWindow.document.getElementsByClassName("toolbarButton pageDown")[0].click();
await sleep(1000);
document.getElementById("pdf").contentWindow.document.getElementsByClassName("toolbarButton pageUp")[0].click();
await sleep(1000);
if(document.getElementsByTagName("dd")[i].children[1].innerText == "已完成") break;
}
} else if (document.getElementsByTagName("dd")[i].children[1].innerText != "Finished") {
if (document.getElementsByTagName("video").length > 0) {
break;
}
await sleep(3000);
while (document.getElementsByTagName("dd")[i].children[1].innerText != "Finished") {
document.getElementById("pdf").contentWindow.document.getElementsByClassName("toolbarButton pageDown")[0].click();
await sleep(1000);
document.getElementById("pdf").contentWindow.document.getElementsByClassName("toolbarButton pageDown")[0].click();
await sleep(1000);
document.getElementById("pdf").contentWindow.document.getElementsByClassName("toolbarButton pageDown")[0].click();
await sleep(1000);
document.getElementById("pdf").contentWindow.document.getElementsByClassName("toolbarButton pageUp")[0].click();
await sleep(1000);
if(document.getElementsByTagName("dd")[i].children[1].innerText == "Finished") break;
}
} else {
if (document.getElementsByTagName("video").length > 0) {
break;
}
continue;
}
}
}
if(i == document.getElementsByTagName("dd").length){
alert("本章已全部完成!请手动切换到下一章。");
return;
}
main();
}
async function main() {
'use strict';
let video = document.getElementsByTagName("video");
let i = 0;
let j = 0;
for (; j < document.getElementsByTagName("dd").length;) {
if (status == 0) {
if (document.getElementsByTagName("dd")[j].children[1].innerText != "已完成") {
i = j;
break;
} else {++j;
}
} else {
if (document.getElementsByTagName("dd")[j].children[1].innerText != "Finished") {
i = j;
break;
} else {++j;
}
}
}
if(j == document.getElementsByTagName("dd").length ){
alert("本章已全部完成!请手动切换到下一章。");
return;
}
if (document.getElementsByClassName("vjs-userName").length > 0) {
document.getElementsByClassName("vjs-userName")[0].style.display = "none";
document.getElementsByClassName("vjs-userName")[0].style.visibility = "hidden";
document.getElementsByClassName("vjs-userName")[0].innerText = "";
}
for (; i < document.getElementsByTagName("dd").length; i++) {
document.getElementsByTagName("dd")[i].click();
video = document.getElementsByTagName("video");
if(document.getElementById("pdf").style.display != "none"){
readPdf();
}
if (status == 0) {
if (video.length != 0 && document.getElementsByTagName("dd")[i].children[1].innerText != "已完成") {
let id = video[0].getAttribute("id");
let mp4 = document.getElementById(id);
let select = document.getElementsByTagName("select")[0];
for (let z = 0; z < select.options.length; ++z) {
if (select.options[z].value == "hd") {
select.options[z].selected = true;
break;
}
}
mp4.muted = true;
while (document.getElementsByTagName("dd")[i].children[1].innerText != "已完成") {
console.log(document.getElementsByTagName("dd")[i].children[1].innerText);
await sleep(1000)
mp4.play();
if(document.getElementsByTagName("dd")[i].children[1].innerText == "已完成") break;
}
}
} else {
if (video.length != 0 && document.getElementsByTagName("dd")[i].children[1].innerText != "Finished") {
document.getElementsByTagName("dd")[i].click();
let id = video[0].getAttribute("id");
let mp4 = document.getElementById(id);
let select = document.getElementsByTagName("select")[0];
for (let z = 0; z < select.options.length; ++z) {
if (select.options[z].value == "hd") {
select.options[z].selected = true;
break;
}
}
mp4.muted = true;
while (document.getElementsByTagName("dd")[i].children[1].innerText != "Finished") {
console.log(document.getElementsByTagName("dd")[i].children[1].innerText);
await sleep(1000)
mp4.play();
if(document.getElementsByTagName("dd")[i].children[1].innerText == "Finished") break;
}
}
}
}
if(i == document.getElementsByTagName("dd").length){
alert("本章已全部完成!请手动切换到下一章。");
return;
}
};
function Refresh() {
let k2 = 0;
for (; k2 < document.getElementsByTagName("dd").length;) {
if (status == 0) {
if (document.getElementsByTagName("dd")[k2].children[1].innerText != "已完成") {
setTimeout(()=>{
location.reload()
},600000);
break;
} else {++k2;
}
} else {
if (document.getElementsByTagName("dd")[k2].children[1].innerText != "Finished") {
setTimeout(()=>{
location.reload()
},600000);
break;
} else {
++k2;
}
}
}
if(k2 == document.getElementsByTagName("dd").length){
alert("本章已全部完成!请手动切换到下一章。");
}
}
function sleep(time) {
return new Promise((resolve)=>setTimeout(resolve, time));
}
参考 https://greasyfork.org/zh-CN/scripts?q=%E5%AF%8C%E5%AD%A6%E5%AE%9D%E5%85%B8
|