// ==UserScript== // @name 🥇【安徽继续教育在线刷课】影刃平台 // @namespace https://doc.yingren.xyz/ // @version 0.1 // @description 安徽继续教育在线刷课 // @author 影刃 // @match *://main.ahjxjy.cn/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // @license GPL 3 // @downloadURL https://update.greasyfork.icu/scripts/525118/%F0%9F%A5%87%E3%80%90%E5%AE%89%E5%BE%BD%E7%BB%A7%E7%BB%AD%E6%95%99%E8%82%B2%E5%9C%A8%E7%BA%BF%E5%88%B7%E8%AF%BE%E3%80%91%E5%BD%B1%E5%88%83%E5%B9%B3%E5%8F%B0.user.js // @updateURL https://update.greasyfork.icu/scripts/525118/%F0%9F%A5%87%E3%80%90%E5%AE%89%E5%BE%BD%E7%BB%A7%E7%BB%AD%E6%95%99%E8%82%B2%E5%9C%A8%E7%BA%BF%E5%88%B7%E8%AF%BE%E3%80%91%E5%BD%B1%E5%88%83%E5%B9%B3%E5%8F%B0.meta.js // ==/UserScript== (function () { 'use strict'; var Video; var NextClassButton; var Interval; function findVideo() { var obj = document.getElementsByClassName("jw-video jw-reset"); if (obj.length == 0) { console.log("未找到视频播放器"); } else { Video = obj[0]; clearInterval(Interval); console.log("视频播放器已找到"); playVideo(); } } function findNextClassButton() { var obj = document.getElementsByClassName("btn btn-green"); if (obj.length == 0) { console.log("未找到下一节按钮"); } else { NextClassButton = obj[0]; console.log("下一节按钮已找到"); NextClassButton.click(); relaod(); } } function listenNextVideo() { Video.currentTime = Video.duration; Video.addEventListener("ended", function () { findNextClassButton(); }); } function playVideo() { try { Video.muted = true var playPromise = Video.play(); if (playPromise !== undefined) { playPromise.then(_ => { listenNextVideo(); }).catch(error => { console.log(error); if (error.message.match(/interact/) != null) { alert("浏览器已禁止自动播放,请手动点击播放后自动刷课"); } else { alert("未知错误,请手动点击播放后自动刷课"); } Video.addEventListener("play", function () { listenNextVideo(); }); }); } } catch (e) { console.log(e); } } function relaod() { Video = null; NextClassButton = null; Interval = null; main(); } function main() { Interval = setInterval(function () { findVideo(); }, 100); } main(); })();