[Python] 纯文本查看 复制代码
// ==UserScript==
// [url=home.php?mod=space&uid=170990]@name[/url] 师德集中学习教育|国家智慧教育公共服务平台|国家中小学智慧教育平台|自动刷视频|16倍速|后台播放
// [url=home.php?mod=space&uid=467642]@namespace[/url] [url]http://tampermonkey.net/[/url]
// [url=home.php?mod=space&uid=1248337]@version[/url] 2023.7.7
// @description 国家智慧教育公共服务平台(国家中小学智慧教育平台)自动刷视频,16倍速!
// [url=home.php?mod=space&uid=686208]@AuThor[/url] You
// [url=home.php?mod=space&uid=195849]@match[/url] [url]https://www.smartedu.cn/[/url]*
// @match [url]https://basic.smartedu.cn/[/url]*
// [url=home.php?mod=space&uid=593100]@Icon[/url] [url]https://www.google.com/s2/favicons?sz=64&domain=smartedu.cn[/url]
// [url=home.php?mod=space&uid=609072]@grant[/url] none
// @license MIT
// ==/UserScript==
(function () {
'use strict';
// Your code here...
// 引入第三方库[url]https://github.com/sweetalert2/sweetalert2/[/url]
// 引入 sweetalert2.min.css 和 sweetalert2.min.js 文件
const css = document.createElement('link');
css.rel = 'stylesheet';
css.href = 'https://cdn.jsdelivr.net/npm/sweetalert2@11.7.12/dist/sweetalert2.min.css';
document.head.appendChild(css);
const js = document.createElement('script');
js.src = 'https://cdn.jsdelivr.net/npm/sweetalert2@11.7.12/dist/sweetalert2.all.min.js';
document.body.appendChild(js);
// 弹窗函数
function msg(txt, ms = 3000) {
Swal.fire({
title: txt,
position: 'center',
icon: 'success',
showConfirmButton: false,
timer: ms,
timerProgressBar: true,
})
}
var log = console.log;
// 课程
var course_name = "师德集中学习教育(2023年7月)";
var home = "https://basic.smartedu.cn/training/71a83441-6d45-4644-80f0-00efa40df164";
var all_course = [
// 思想铸魂
"https://basic.smartedu.cn/teacherTraining/courseDetail?courseId=58979766-6cb2-43f8-8b6c-68336f8824df&tag=%E5%B8%88%E5%BE%B7%E9%9B%86%E4%B8%AD%E5%AD%A6%E4%B9%A0%E6%95%99%E8%82%B2&channelId=&libraryId=bb042e69-9a11-49a1-af22-0c3fab2e92b9&breadcrumb=%E5%B8%88%E5%BE%B7%E9%9B%86%E4%B8%AD%E5%AD%A6%E4%B9%A0%E6%95%99%E8%82%B2",
// 固本强基
"https://basic.smartedu.cn/teacherTraining/courseDetail?courseId=10c4b18a-333a-48d2-a6ea-4a3524ea8e78&tag=%E5%B8%88%E5%BE%B7%E9%9B%86%E4%B8%AD%E5%AD%A6%E4%B9%A0%E6%95%99%E8%82%B2&channelId=&libraryId=bb042e69-9a11-49a1-af22-0c3fab2e92b9&breadcrumb=%E5%B8%88%E5%BE%B7%E9%9B%86%E4%B8%AD%E5%AD%A6%E4%B9%A0%E6%95%99%E8%82%B2",
// 以案促学
"https://basic.smartedu.cn/teacherTraining/courseDetail?courseId=f47898b2-2138-4600-b08d-68856b1c7cb7&tag=%E5%B8%88%E5%BE%B7%E9%9B%86%E4%B8%AD%E5%AD%A6%E4%B9%A0%E6%95%99%E8%82%B2&channelId=&libraryId=bb042e69-9a11-49a1-af22-0c3fab2e92b9&breadcrumb=%E5%B8%88%E5%BE%B7%E9%9B%86%E4%B8%AD%E5%AD%A6%E4%B9%A0%E6%95%99%E8%82%B2",
// 师德引领
"https://basic.smartedu.cn/teacherTraining/courseDetail?courseId=f7a2a557-7948-4d9b-93df-8622430d0df3&tag=%E5%B8%88%E5%BE%B7%E9%9B%86%E4%B8%AD%E5%AD%A6%E4%B9%A0%E6%95%99%E8%82%B2&channelId=&libraryId=bb042e69-9a11-49a1-af22-0c3fab2e92b9&breadcrumb=%E5%B8%88%E5%BE%B7%E9%9B%86%E4%B8%AD%E5%AD%A6%E4%B9%A0%E6%95%99%E8%82%B2",
// 综合育人
"https://basic.smartedu.cn/teacherTraining/courseDetail?courseId=c016de39-7291-466d-be35-045f9c2ffe44&tag=%E5%B8%88%E5%BE%B7%E9%9B%86%E4%B8%AD%E5%AD%A6%E4%B9%A0%E6%95%99%E8%82%B2&channelId=&libraryId=bb042e69-9a11-49a1-af22-0c3fab2e92b9&breadcrumb=%E5%B8%88%E5%BE%B7%E9%9B%86%E4%B8%AD%E5%AD%A6%E4%B9%A0%E6%95%99%E8%82%B2",
// 科学素养提升
"https://basic.smartedu.cn/teacherTraining/courseDetail?courseId=a326cae7-067b-44b6-910c-c9a4747bb02e&tag=%E5%B8%88%E5%BE%B7%E9%9B%86%E4%B8%AD%E5%AD%A6%E4%B9%A0%E6%95%99%E8%82%B2&channelId=&libraryId=bb042e69-9a11-49a1-af22-0c3fab2e92b9&breadcrumb=%E5%B8%88%E5%BE%B7%E9%9B%86%E4%B8%AD%E5%AD%A6%E4%B9%A0%E6%95%99%E8%82%B2",
// 数字素养提升
"https://basic.smartedu.cn/teacherTraining/courseDetail?courseId=785b41e5-aedb-4adc-9e64-7e1cee9b42b1&tag=%E5%B8%88%E5%BE%B7%E9%9B%86%E4%B8%AD%E5%AD%A6%E4%B9%A0%E6%95%99%E8%82%B2&channelId=&libraryId=bb042e69-9a11-49a1-af22-0c3fab2e92b9&breadcrumb=%E5%B8%88%E5%BE%B7%E9%9B%86%E4%B8%AD%E5%AD%A6%E4%B9%A0%E6%95%99%E8%82%B2",
// 高中研究性学习活动的设计与实施
"https://basic.smartedu.cn/teacherTraining/courseDetail?courseId=7f567d88a-a73e-4508-a890-66c515291cc8&tag=%E5%B8%88%E5%BE%B7%E9%9B%86%E4%B8%AD%E5%AD%A6%E4%B9%A0%E6%95%99%E8%82%B2&channelId=&libraryId=bb042e69-9a11-49a1-af22-0c3fab2e92b9&breadcrumb=%E5%B8%88%E5%BE%B7%E9%9B%86%E4%B8%AD%E5%AD%A6%E4%B9%A0%E6%95%99%E8%82%B2",
]
// 答题
function answer() {
let count = 0;
const intervalId = setInterval(() => {
log('自动答题检测...');
// 选A
var a = document.getElementsByClassName("nqti-check")[0];
if (a) {
a.click();
// 下一题、确定
var btn = document.querySelector("div.index-module_footer_3r1Yy > button");
if (btn) {
btn.click();
}
}
count++;
if (count === 3) {
clearInterval(intervalId);
}
}, 1000);
}
function click(auto_next = true) {
var icon = null;
function find_icon() {
// 进行中
icon = document.getElementsByClassName("iconfont icon_processing_fill")[0];
// 未开始
if (!icon) {
icon = document.getElementsByClassName("iconfont icon_checkbox_linear")[0];
}
}
// 查找默认列表
find_icon();
// 展开其他列表
if (!icon) {
var headers = document.getElementsByClassName("fish-collapse-header");
for(let i = 0; i < headers.length; i++){
var header = headers[i];
header.click();
find_icon();
if (icon) {
break;
}
}
}
// 有没学完的
if (icon) {
icon.click();
} else {
if (auto_next) {
next();
} else {
Swal.fire("当前页面所有视频已经播放完!", "", "success");
}
}
}
function play(v = null) {
if (!v) {
v = document.getElementsByTagName("video")[0];
}
if (v) {
v.muted = true;
v.playbackRate = 16;
v.play();
}
}
var pageNumber = null;
var pageCount = null;
function read() {
log(`PDF文档阅读: pageNumber==>${pageNumber}, pageCount==>${pageCount}`);
if (pageCount) {
var pc = pageCount;
// 最后一页
log("PDF文档跳到最后一页:", pc);
window.postMessage({
type: "pdfPlayerPageChangeing",
data: {
pageNumber: pc,
pageCount: pc,
}
}, "*");
// 第一页
setTimeout(function(){
log("PDF文档调到第一页...");
window.postMessage({
type: "pdfPlayerPageChangeing",
data: {
pageNumber: 1,
pageCount: pc,
}
}, "*");
}, 1000);
// 重置
pageCount = null;
}
}
function next() {
var href = window.location.href;
var index = all_course.indexOf(href);
if (index > -1) {
if (index + 1 < all_course.length) {
window.location.href = all_course[index + 1];
} else {
window.location.href = home;
}
} else {
window.location.href = all_course[0];
}
}
function main() {
log("main...");
// 等待页面加载,延时开始
var delay = 1000 * 10
var href = window.location.href;
if (all_course.includes(href)) {
msg(`等待网页资源加载, 约【${delay / 1000}】秒后开始自动播放视频`, delay);
setInterval(function () {
click();
play();
read();
answer();
}, delay);
} else {
Swal.fire({
icon: "question",
title: '开始刷视频?',
text: "好好学习,天天向上!",
showDenyButton: true,
showCancelButton: true,
confirmButtonColor: 'green',
confirmButtonText: `刷脚本配置的课程,当前为:${course_name}`,
denyButtonColor: "blue",
denyButtonText: "只刷当前页的视频",
cancelButtonColor: 'red',
cancelButtonText: '退出',
}).then((result) => {
/* Read more about isConfirmed, isDenied below */
if (result.isConfirmed) {
msg("走你~");
next();
} else if (result.isDenied) {
msg(`【${delay / 1000}】秒后开始自动播放视频`, delay);
setInterval(function () {
click(false);
play();
read();
answer();
}, delay);
}
})
}
}
if (document.readyState === 'complete') {
// DOM 已经加载完成
main();
} else {
// DOM 还未加载完成
// document.addEventListener("DOMContentLoaded", main);
window.onload = main;
}
document.addEventListener('keydown', function (event) {
log("keydown", event.code);
if (event.code === 'KeyG') {
main();
}
});
window.addEventListener("message", function(event) {
var data = event.data;
log("message from PDF================>", data);
if (data.type === "pdfPlayerInitPage") {
pageNumber = data.data.pageNumber;
pageCount = data.data.pageCount;
log(`PDF文档初始化: pageNumber==>${pageNumber}, pageCount==>${pageCount}`);
}
});
})();