华医助手 Dr.wu

2024.11.26 基于之前首创作者Dr.s,二创作者:境界程序员的开发。在应用过程中发现,二创版本对官方页面改动太大,且在实际应用过程中有播放视频结束,还没有答题就自动跳到下一个视频了,声明:此版本只针对北方华医,不需要扫码答题的。

  1. // ==UserScript==
  2. // @name 华医助手 Dr.wu
  3. // @namespace http://tampermonkey.net/
  4. // @version 24.12.5.1
  5. // @description 2024.11.26 基于之前首创作者Dr.s,二创作者:境界程序员的开发。在应用过程中发现,二创版本对官方页面改动太大,且在实际应用过程中有播放视频结束,还没有答题就自动跳到下一个视频了,声明:此版本只针对北方华医,不需要扫码答题的。
  6. // @author 三创作者,Dr.wu 二创作者:境界程序员 原创作者:Dr.S。
  7. // @license AGPL License
  8. // @match *://*.91huayi.com/course_ware/course_ware_polyv.aspx?*
  9. // @match *://*.91huayi.com/course_ware/course_ware_cc.aspx*
  10. // @match *://*.91huayi.com/pages/exam.aspx?*
  11. // @match *://*.91huayi.com/pages/exam_result.aspx?*
  12. // @match *://*.91huayi.com/*
  13. // @grant none
  14. //脚本捐赠不会开启新的功能,所以无需声明antifeature
  15. // ==/UserScript==
  16.  
  17.  
  18. //更新历史
  19. //2024.11.26 基于之前首创作者Dr.s,二创作者:境界程序员的开发。在应用过程中发现,二创版本对官方页面改动太大,广告太多。且在实际应用过程中有播放视频结束,还没有答题就自动跳到下一个视频了,声明:此版本只针对北方华医,不需要扫码答题的。
  20. //
  21. //2022年和首创作者沟通过,他当时因为疫情,没有电脑也迟迟未能更新。
  22.  
  23.  
  24.  
  25. (function () {
  26. 'use strict';
  27. var submitTime = 6100;//交卷时间控制
  28. var reTryTime = 2100;//重考,视频进入考试延时控制
  29. var examTime = 10000;//听课完成进入考试延时
  30. var randomX = 5000;//随机延时上限
  31. var vSpeed = 1; //首次使用脚本的默认播放速度
  32. var autoSkip = false; //一个可能会封号的功能。
  33. //记录字段
  34. var keyPlayRate = "JJ_Playrate";
  35. var keyTest = "JJ_Test";
  36. var keyResult = "JJ_Result";
  37. var keyThisTitle = "JJ_ThisTitle";
  38. var keyTestAnswer = "JJ_TestAnswer";
  39. var keyRightAnswer = "JJ_RightAnswer";
  40. var keyAllAnswer = "JJ_AllAnswer";
  41. //按钮样式
  42. var btstyleA = "font-size: 16px;font-weight: 300;text-decoration: none;text-align: center;line-height: 40px;height: 40px;padding: 0 40px;display: inline-block;appearance: none;cursor: pointer;border: none;box-sizing: border-box;transition-property: all;transition-duration: .3s;background-color: #4cb0f9;border-color: #4cb0f9;border-radius: 4px;margin: 5px;color: #FFF;";
  43. var btstyleB = "font-size: 12px;font-weight: 300;text-decoration: none;text-align: center;line-height: 20px;height: 20px;padding: 0 5px;display: inline-block;appearance: none;cursor: pointer;border: none;box-sizing: border-box;transition-property: all;transition-duration: .3s;background-color: #4cb0f9;border-color: #4cb0f9;border-radius: 4px;margin: 5px;color: #FFF;";
  44. var btstyleC = "font-size: 12px;font-weight: 300;text-decoration: none;text-align: center;line-height: 20px;height: 20px;padding: 0 5px;display: inline-block;appearance: none;cursor: pointer;border: none;box-sizing: border-box;transition-property: all;transition-duration: .3s;background-color: #f15854;border-color: #f15854;border-radius: 4px;margin: 5px;color: #FFF;";
  45. //页面判别
  46. var urlInfos = window.location.href.split("/");
  47. var urlTip = urlInfos[urlInfos.length - 1].split("?")[0];
  48. var huayi = getHuayi();
  49. var nspeed = 0;
  50. var clock = null;
  51. advis();
  52. if (urlTip == "course_ware_polyv.aspx") { //保利威播放器视频页面
  53. console.log("当前任务: 华医看视频");
  54. huayi.seeVideo(1);
  55. } else if (urlTip == "course_ware_cc.aspx") { //CC播放器视频页面
  56. console.log("当前任务: 华医看视频");
  57. huayi.seeVideo(2);
  58. } else if (urlTip == "exam.aspx") { //考试页面
  59. console.log("当前任务: 华医考试");
  60. huayi.doTest();
  61. } else if (urlTip == "course.aspx" || urlTip == "cme.aspx") { //课程列表页面
  62. console.log("当前任务: 课程列表");
  63. huayi.courseList();
  64. } else if (urlTip == "exam_result.aspx") { //考试结果页面
  65. console.log("当前任务: 华医考试结果审核");
  66. huayi.doResult();
  67. } else {
  68. console.log("其它情况");
  69. try {
  70. document.querySelector("img[id='Pic']").style.display = "block";
  71. } catch (error) { };
  72. };
  73.  
  74. function getHuayi() {
  75. return {
  76. courseList: function () {
  77. addAnwserCopybtn();
  78. DelAllAnwser();
  79.  
  80. },
  81. seeVideo: function (e) {
  82. var tr = localStorage.getItem(keyPlayRate);
  83. //console.log("存储读取" + tr);//读取倍速
  84. //var playRateNow = tr ? tr : vSpeed;
  85. var playRateNow = 1;
  86. cleanKeyStorage();
  87.  
  88.  
  89.  
  90. asynckillsendQuestion();//屏蔽课堂问答的函数;
  91. killsendQuestion2();//屏蔽课堂问答的函数2;
  92.  
  93. killsendQuestion3(); //循环检测问答对话框是否弹出。
  94. // addrateinfo();//插入一些按钮
  95. // addratebtn(1);
  96. // addratebtn(1.5);
  97. // addratebtn(2);
  98. // addratebtn(3);
  99. // addratebtn(5);
  100. // addratebtn(10);
  101. //addSkipbtn();//跳过按钮
  102. // addinfo();//脚本信息
  103. // changelayout();
  104. //速度调节部分
  105.  
  106. window.onload = function () {
  107. localStorage.setItem(keyThisTitle, JSON.stringify(window.document.title));//储存章节标题
  108. // console.log("准备激活加速");
  109. ratechg(playRateNow);
  110. if (autoSkip == true) {//秒过功能,签完别尝试
  111. setTimeout(function () {
  112. skipVideo();
  113. }, (submitTime + Math.ceil(Math.random() * randomX)));
  114. console.log("秒过了!");
  115.  
  116. };
  117. clock = setInterval(examherftest, 3000);//阿み杰此处要改11才能考试,循环法用examherftest检测考试按钮是否能点击
  118. function cheack_cxam(){
  119. console.log('检测是否可以考试')
  120. }
  121. cheack_cxam(clock);
  122. // try {
  123. // videoObj.onended = function () {
  124. // console.log("播放完成,准备进入考试");
  125. // // if (document.querySelector("a[id='mode']").innerText != "当前模式:视频+考试\n[点击此处切换]") {
  126. // clickexam();//阿み杰不想考试
  127. // // };
  128. // };
  129. // } catch (error) { console.log("播放器1检测错误"); }
  130.  
  131. switch (e) {
  132. case 1:
  133. window.s2j_onPlayerInitOver()
  134. {
  135. // console.log("polyv加载完毕,静音,稍后尝试触发一次播放");
  136. player?.j2s_setVolume(0);
  137. document.querySelector("video").defaultMuted = true;
  138. setTimeout(function () {
  139. try {
  140. // document.querySelector("video").volume = 0;//实际测试,主要靠这一条静音
  141. player.j2s_resumeVideo();
  142. //document.querySelector("video").muted = true;
  143. examherftest();
  144. console.log("在检测是否可以考试?")
  145. //document.querySelector("button[onclick='closeBangZhu()']").click();//关闭温馨提醒
  146. } catch (error) {
  147. console.log("上一段代码有误");
  148. };
  149. }, 2000); //延时点击播放,之前是5秒
  150. };
  151. break;
  152. case 2:
  153. window.on_CCH5player_ready()
  154. {
  155. //console.log("CCplayer加载完毕,静音,稍后尝试触发一次播放");
  156. cc_js_Player?.setVolume(0);
  157. document.querySelector("video").defaultMuted = true;
  158. setTimeout(function () {
  159. try {
  160. //document.querySelector("video").volume = 0;//实际测试,主要靠这一条静音
  161. cc_js_Player.play();
  162. //document.querySelector("video").muted = true;
  163. examherftest();
  164. //document.querySelector("button[onclick='closeBangZhu()']").click();//关闭温馨提醒
  165. } catch (error) {
  166. console.log("上一段代码有误");
  167. };
  168. }, 2000); //延时点击播放,之前是5秒
  169. };
  170. break;
  171. default:
  172. console.log("其他播放器?");
  173. };
  174.  
  175. };
  176. },
  177. doTest: function () {
  178. var questions = JSON.parse(localStorage.getItem(keyTest)) || {};
  179. var qRightAnswer = JSON.parse(localStorage.getItem(keyRightAnswer)) || {};
  180. if (JSON.stringify(qRightAnswer) == "{}") {
  181. qRightAnswer = LoadRightAnwser();
  182. };
  183. var qTestAnswer = {};
  184. var index = 0;
  185.  
  186.  
  187. while (true) {
  188. var question = document.querySelectorAll("table[class='tablestyle']")[index];
  189.  
  190. if (question == null) break;
  191. else {
  192. var q = question.querySelector(".q_name").innerText.substring(2).replace(/\s*/g, "");//问题的具体文本
  193. //thisQuestions=thisQuestions+q+"@"
  194.  
  195.  
  196. if (qRightAnswer.hasOwnProperty(q)) { //当查询到记录了正确答案时的操作
  197.  
  198. //console.log("问题:"+ q + ",有答案:"+ qRightAnswer[q]);
  199. var rightSelection = findAnwser("tbody", index, qRightAnswer[q]) //返回答案选项label
  200. rightSelection.click();
  201.  
  202. } else {
  203. if (questions.hasOwnProperty(q)) {
  204. questions[q] = getNextChoice(questions[q]);//通过Unicode数字+1切换到下一个选项,返回的是字母选项
  205. //console.log("不知道答案:"+ q+",测试:"+questions[q]);
  206. } else { //如果系统没有记录
  207. questions[q] = "A";
  208. };
  209.  
  210. var answer = getChoiceCode(questions[q]);//将字母选项转换为Unicode数字并减去A代表的65,等于选项顺序,0是第一个选项
  211. var element = document.querySelectorAll("tbody")[index].getElementsByTagName("label")[answer];//获取到的是4-5个选项的数组answer等于选项顺序,0是第一个选项
  212. //document.querySelector("#gvQuestion_rbl_" + index + "_" + answer + "_" + index);
  213.  
  214.  
  215. if (!element) { //选项除错机制
  216. console.log("找不到选项,选项更改为A index: " + index + " answer: " + answer);
  217. questions[q] = "A";
  218. answer = getChoiceCode("A");
  219. element = document.querySelectorAll("tbody")[index].getElementsByTagName("label")[answer];//获取到的是4-5个选项的数组answer等于选项顺序,0是第一个选项
  220. //document.querySelector("#gvQuestion_rbl_" + index + "_" + answer + "_" + index);
  221. //localStorage.removeItem(keyTest)
  222. };
  223. try {
  224. var answerText = element.innerText.substring(3);//"A、"占用3个字符
  225. //console.log("测试语法:" + (answerText == element.innerText.trim().substring(2)));
  226.  
  227. //element.nextSibling.innerText.trim().substring(2); //获得当前答案文本
  228. qTestAnswer[q] = answerText;
  229. //console.log("qTestAnswer:"+error);
  230. } catch (error) { console.log("答案文本获取失败A:" + error); };
  231. element.click();
  232. };
  233. index = index + 1;
  234. };
  235. };
  236.  
  237. //存储相关记录
  238.  
  239. localStorage.setItem(keyTest, JSON.stringify(questions));
  240. localStorage.setItem(keyTestAnswer, JSON.stringify(qTestAnswer));
  241.  
  242. setTimeout(function () {
  243. document.querySelector("#btn_submit").click();
  244. }, (submitTime + Math.ceil(Math.random() * randomX))); //交卷延时
  245. ///专用函数区
  246. function findAnwser(qakey, index, rightAnwserText) {
  247. var answerslist = document.querySelectorAll(qakey)[index];
  248. var arr = answerslist.getElementsByTagName("label");
  249.  
  250. for (var i = 0; i < arr.length; i++) {
  251. //console.log(arr[i].innerText);
  252. if (arr[i].innerText.substring(3) == rightAnwserText) {
  253. //if (arr[i].innerText.trim().substring(2) == rightAnwserText) {
  254. return arr[i];
  255. };
  256. };
  257. };
  258.  
  259. function getChoiceCode(an) { //用于获取选项字符编码
  260. var charin = an || "A";
  261. return charin.charCodeAt(0) - "A".charCodeAt(0);
  262.  
  263. };
  264.  
  265. function getNextChoice(an) { //用于获取下一个选项字符
  266. var code = an.charCodeAt(0) + 1;
  267. return String.fromCharCode(code);
  268. };
  269. ///专用函数区结束
  270. },
  271. doResult: function () {
  272. //var res = document.getElementsByTagName("b")[0].innerText;
  273. //var dds = document.getElementsByTagName("dd");
  274. var res = $(".tips_text")[0].innerText;
  275. var dds = $(".state_cour_lis");
  276. localStorage.removeItem(keyResult);//移除错题表缓存
  277. if (res == "考试通过" || res == "考试通过!" || res == "完成项目学习可以申请学分了") { //考试通过
  278. console.log("考试通过");
  279. //localStorage.setItem(keyResult, "");//记录最后一次答对的题目。
  280. saveRightAnwser();//记录最后一次答对的题目。
  281. SaveAllAnwser(); //存储所有记录的答案
  282. cleanKeyStorage();//如果通过清理答案
  283. var next = document.getElementsByClassName("state_lis_btn state_lis_han")[0];
  284. if (next) {
  285. setTimeout(function () {next.click();}, 1000);//下一节课延时
  286. try{
  287. var playing = document.querySelector("#top_play");
  288. if (playing) {
  289. setTimeout(function () {playing.click();}, 1000);//点击播放按钮
  290. // let volume_0 = document.querySelector("video").volume
  291. // setTimeout(function() {volume_0 = 0},3000)
  292. }
  293. }catch (err) {
  294. console.log("无法播放:"+err);
  295. }
  296. }
  297. } else { //考试没过
  298. console.log("考试未通过")
  299. document.querySelector("p[class='tips_text']").innerText = "本次未通过,正在尝试更换答案\r\n(此为正常现象,脚本几秒后刷新,请勿操作)"
  300. var qWrong = {};
  301. for (var i = 0; i < dds.length; ++i) {
  302. if (!dds[i].querySelector("img").src.includes("bar_img")) {//这里表示否定
  303. qWrong[dds[i].querySelector("p").title.replace(/\s*/g, "")] = i
  304. };
  305. };
  306.  
  307. if (qWrong != {}) {
  308. localStorage.setItem(keyResult, JSON.stringify(qWrong));
  309. saveRightAnwser();
  310. setTimeout(function () {
  311. $("input[type=button][value='重新考试']").click();
  312. }, (reTryTime + Math.ceil(Math.random() * randomX)) * 1);
  313.  
  314. //重新考试
  315. };
  316. };
  317.  
  318. },
  319. };
  320. };
  321.  
  322. //---------------------------------全局函数区------------------------------//
  323. //答案记录函数区开始//
  324. function SaveAllAnwser() {//保存历史题目答案
  325. var qAllAnswer = JSON.parse(localStorage.getItem(keyAllAnswer)) || {};
  326. var qRightAnswer = JSON.parse(localStorage.getItem(keyRightAnswer)) || {};
  327. var qTitle = JSON.parse(localStorage.getItem(keyThisTitle)) || "没有记录到章节名称";
  328. var qOldAnswer = qAllAnswer[qTitle] || {};
  329. for (var q in qRightAnswer) {
  330. qOldAnswer[q] = qRightAnswer[q];
  331. };
  332. qAllAnswer[qTitle] = qOldAnswer;
  333.  
  334. if (qAllAnswer != null) {//保存正确答案
  335. localStorage.setItem(keyAllAnswer, JSON.stringify(qAllAnswer));
  336. };
  337. };
  338. function LoadRightAnwser() {//加载历史题目答案
  339. var qAllAnswer = JSON.parse(localStorage.getItem(keyAllAnswer)) || {};
  340. //var qRightAnswer = JSON.parse(localStorage.getItem(keyRightAnswer)) ||{};
  341. var qTitle = JSON.parse(localStorage.getItem(keyThisTitle)) || "没有记录到章节名称";
  342. if (qTitle == "没有记录到章节名称") {
  343. console.log("没找到章节名称");
  344. return {};
  345. };
  346. var qOldAnswer = qAllAnswer[qTitle] || {};
  347. return qOldAnswer
  348. };
  349. function saveRightAnwser() { //记录本次测试到的正确答案
  350.  
  351. var qRightAnswer = JSON.parse(localStorage.getItem(keyRightAnswer)) || {};
  352. var qTestAnswer = JSON.parse(localStorage.getItem(keyTestAnswer)) || {};
  353. var qkeyTest = JSON.parse(localStorage.getItem(keyTest)) || {};
  354.  
  355. //错题表
  356. var qWrongs = JSON.parse(localStorage.getItem(keyResult)) || {};
  357.  
  358. for (var q in qTestAnswer) {
  359. //debugger;
  360. var iswrong = false;
  361. if (!qWrongs.hasOwnProperty(q)) { //当查询到记录了正确答案时的操作
  362. console.log("正确的题目:" + q + ",答案:" + qTestAnswer[q]);
  363. qRightAnswer[q] = qTestAnswer[q];
  364. } else { console.log("错误的题目:" + q + ",答案:" + qTestAnswer[q]); };
  365.  
  366. };
  367. localStorage.removeItem(keyTestAnswer);//清理临时记录
  368. if (qRightAnswer != null) {//保存正确答案
  369. localStorage.setItem(keyRightAnswer, JSON.stringify(qRightAnswer));
  370. };
  371. };
  372. //答案记录函数区结束//
  373.  
  374. //答案复制相关按钮
  375. function addAnwserCopybtn() {//插入答案复制按钮
  376. let alink = document.createElement("a");
  377. alink.innerHTML = '显示已记录答案';
  378. alink.style = btstyleB;
  379.  
  380. alink.onclick = function (event) {
  381. var qAllAnswer = JSON.parse(localStorage.getItem(keyAllAnswer)) || {};
  382. var Aout = JSON.stringify(qAllAnswer, null, "\t")
  383. //Aout=encodeURIComponent(Aout);
  384. //window.prompt("请复制",Aout);
  385. if (document.getElementById("AnwserOut")) {
  386. document.getElementById("AnwserOut").innerHTML = Aout;
  387. } else {
  388. let textout = document.createElement("textarea");
  389. textout.id = "AnwserOut";
  390. textout.innerHTML = Aout;
  391. textout.rows = 20;
  392. textout.cols = 30;
  393. document.getElementById("main_div").parentNode.append(textout);
  394. };
  395.  
  396. };
  397. document.getElementById("main_div").parentNode.append(alink);
  398.  
  399. };
  400. function DelAllAnwser() {//插入清除答案按钮
  401. let alink = document.createElement("a");
  402. alink.innerHTML = '清除已记录答案';
  403. alink.style = btstyleB;
  404.  
  405. alink.onclick = function (event) {
  406.  
  407. var r = confirm("确定清除历史答案?!");
  408. if (r) {
  409. localStorage.removeItem(keyAllAnswer);
  410. };
  411. };
  412. document.getElementById("main_div").parentNode.append(alink);
  413. };
  414. //答案复制相关按钮 end
  415. function skipVideo() {//这是跳过视频的代码
  416. var oVideo = document.getElementsByTagName('video')[0];
  417. if (oVideo) {
  418. oVideo.currentTime = oVideo.duration - 1
  419. };
  420. };
  421.  
  422. function clickexam() { //延时点击考试按钮。
  423. console.log("已点击考试按钮");
  424. setTimeout(function () {
  425. document.querySelector("#jrks").click();
  426. }, (Math.ceil(Math.random() * randomX)));
  427. //}, (examTime + Math.ceil(Math.random() * randomX)));
  428. };
  429. //按钮插入函数相关
  430. function addSkipbtn() {//插入按钮快进视频按钮
  431. let alink = document.createElement("a");
  432. alink.innerHTML = '快进视频';
  433. alink.style = btstyleA;
  434.  
  435. alink.onclick = function (event) {
  436. skipVideo();
  437. };
  438. document.querySelector("div[id='jj']").parentNode.append(alink);
  439. };
  440.  
  441. function addratebtn(ra) {//倍率调整按钮
  442. let alink = document.createElement("a");
  443. alink.innerHTML = '' + ra + 'x';
  444. alink.style = btstyleB;
  445. alink.className = "speed";
  446. alink.id = ra + "x";
  447. alink.onclick = function (event) {
  448. ratechg(ra);
  449. try {
  450. var arr = document.querySelectorAll("a[class='speed']");
  451. arr.forEach(function (item, index, arr) {
  452. arr[index].style = btstyleB;
  453. });
  454. } catch (error) {
  455. };
  456. alink.style = btstyleC;
  457. };
  458. document.querySelector("div[id='jj']").parentNode.append(alink);
  459. }
  460. function ratechg(ra) {//倍率调整
  461. var videoObj = document.querySelector("video")
  462. try {
  463. clearInterval(nspeed);
  464. nspeed = setInterval(() => {
  465. videoObj.playbackRate = ra;
  466. }, 1 * 1000);
  467. localStorage.setItem(keyPlayRate, ra);
  468. //document.querySelector("a[id=" + "'" + ra + "x']").style = btstyleC;
  469. //document.getElementById("playrate").innerHTML = "当前播放速率" + ra + "x";
  470. //console.log("倍率调整为" + ra);
  471. } catch (error) { console.log("倍率调整错误" + error); };
  472. };
  473. function addrateinfo() {//插入说明
  474. let adiv1 = document.createElement("div");
  475. adiv1.innerHTML = '当前播放速率';
  476. adiv1.id = 'playrate';
  477. adiv1.style = "font-size: 15px;text-align: center;margin-top: 10px;";
  478. document.querySelector("div[id='jj']").parentNode.append(adiv1);
  479.  
  480. };
  481. function addinfo() {//插入说明
  482. //模式切换按钮
  483. var moderesult = localStorage.getItem("华医mode");
  484. if (moderesult == 2) {
  485. moderesult = "当前模式:视频+考试";
  486. } else {//包括了结果为1或者无存储的情况
  487. moderesult = "当前模式:单刷视频";
  488. };
  489. var checkbox = document.createElement('div');
  490. checkbox.innerHTML = '<a id="mode" class="btn btn-default" style="background-color: rgba(184, 247, 255, 0.7);font-size:22px;" >' + moderesult + '<br> [点击此处切换]</a > ';
  491.  
  492. // 添加到页面的 body 元素中
  493. // document.querySelector("div[id='jj']").parentNode.append(checkbox);
  494. //插入说明部分
  495. let mode1 = document.querySelector("a[id='mode']");
  496. mode1.onclick = function () {
  497. if (mode1.innerText == "当前模式:单刷视频\n[点击此处切换]") {
  498. mode1.innerText = "当前模式:视频+考试\n[点击此处切换]";
  499. localStorage.setItem("华医mode", "2");
  500. } else {
  501. mode1.innerText = "当前模式:单刷视频\n[点击此处切换]";
  502. localStorage.setItem("华医mode", "1");
  503. };
  504. };
  505. };
  506.  
  507.  
  508. function cleanKeyStorage() {//缓存清理
  509. localStorage.removeItem(keyTest);
  510. localStorage.removeItem(keyResult);
  511. localStorage.removeItem(keyTestAnswer);
  512. localStorage.removeItem(keyRightAnswer);
  513. };
  514. function examherftest() {//考试按钮激活状态检测
  515. var hreftest = document.getElementById("jrks").attributes["href"].value;
  516. var state = document.querySelectorAll("i[id='top_play']")[0].parentNode.nextElementSibling.nextElementSibling.nextElementSibling.innerText;
  517. //console.log("测试考试" + hreftest);
  518. if ( hreftest != "#"|| (typeof getMaxPlayTime == "function" ? getMaxPlayTime() | 0 : 1) == (typeof player.j2s_getDuration == "function" ? player.
  519. j2s_getDuration() | 0 : 0) || (typeof getMaxPlayTime == "function" ? getMaxPlayTime() | 0 : 1) == (typeof player.getDuration == "function" ? player.getDuration() | 0
  520. : 0)) {//value不为#说明考试按钮已经激活
  521. //console.log("已经播放完了");
  522. clickexam();}
  523. else if (state == "已完成"){
  524. console.log("已播放完毕并且已考试完毕")
  525. next_video();
  526. }
  527. else{console.log(" 在循环检测是否可以考试,或是否已完成。")
  528. };
  529. };
  530. //课堂问答跳过,临时版
  531. function sleep(timeout) {
  532. return new Promise((resolve) => { setTimeout(resolve, timeout); });
  533. console.log("课堂问答循环调用");
  534. };
  535. function asynckillsendQuestion() {
  536. (async function () {
  537. while (!window.player || !window.player.sendQuestion) {
  538. await sleep(20);
  539. };
  540. //console.log("课堂问答跳过插入");
  541. player.sendQuestion = function () {
  542. //console.log("播放器尝试弹出课堂问答,已屏蔽。");
  543. };
  544. })();
  545. };
  546. function killsendQuestion2() {
  547. if (typeof (isInteraction) == "undefined") {
  548. //console.log('变量未定义');
  549. } else {
  550. console.log('isInteraction设置off');
  551. isInteraction = "off";
  552. };
  553. };
  554. function killsendQuestion3() { //点击跳过按钮版的跳过课堂答题
  555. var clockms = setInterval(async function () {
  556. try {
  557. if ($('.pv-ask-head').length && $('.pv-ask-head').length > 0) {
  558. console.log("检测到问题对话框,尝试跳过");
  559. $(".pv-ask-skip").click();
  560. };
  561. } catch (err) {
  562. console.log(err);
  563. };
  564. try {
  565. if ($('.signBtn').length && $('.signBtn').length > 0) {
  566. console.log("检测到签到对话框,尝试跳过");
  567. $(".signBtn").click();
  568. };
  569. } catch (err) {
  570. console.log(err);
  571. };
  572. try {
  573. if ($("button[onclick='closeProcessbarTip()']").length && $("button[onclick='closeProcessbarTip()']").length > 0 && $("div[id='div_processbar_tip']").css("display") == "block") {
  574. console.log("检测到温馨提示对话框(不能拖拽),尝试跳过");//
  575. //$("button[onclick='closeBangZhu()']").click();
  576. $("button[onclick='closeProcessbarTip()']").click();
  577. };
  578. } catch (err) {
  579. console.log(err);
  580. };
  581. try {
  582. if ($("button[class='btn_sign']").length && $("button[class='btn_sign']").length > 0) {
  583. console.log("检测到温馨提示对话框(疲劳提醒),尝试跳过");
  584. $("button[class='btn_sign']").click();
  585. };
  586. } catch (err) {
  587. console.log(err);
  588. };
  589. try {
  590. var state = document.querySelectorAll("i[id='top_play']")[0].parentNode.nextElementSibling.nextElementSibling.nextElementSibling.innerText;
  591. if ($('video').prop('paused') == true && state != "已完成") {
  592. console.log("视频意外暂停,恢复播放");
  593. $('video').get(0).play();
  594. $('video').prop('volumed') = 0;
  595. $('video').prop('muted') = true;
  596. } else if (state == "已完成") {
  597. document.querySelector("video").pause();
  598. //clearInterval(clockms);
  599. };
  600. } catch (err) {
  601. //console.log(err);
  602. };
  603. }, 2000);
  604. };
  605.  
  606. function advis() {
  607. let div1 = document.createElement("div");
  608. div1.innerHTML = `
  609. <div id='Div1' style="max-width:220px;text-align:left;padding: 10px 10px;font-family:微软雅黑;font-size:20px;float: left;position:fixed;top:140px;left: 10px;z-index: 99999; background-color: rgba(184, 247, 255, 0.7); overflow-x: auto;">
  610. <span id='clo' style="float: right;position: absolute;top:14px;right:5px;cursor:pointer;font-size:16px">❎</span>
  611. <div style="font-size:22px;font-weight:bolder;color:red;">温馨提示:</div>
  612. <hr style="margin-top: 10px;margin-bottom: 10px;">
  613. <span id="tixing" style="font-size:16px;font-weight:normal;color:black;text-align:right;">倍速已经被禁止<br> 可自动播放及答题 <br> 且用且珍惜<br></span>
  614. <br>
  615. <span style="font-size:18px;font-weight:bold;color:black;">急危重症救治中心</span> <br>
  616. <span style="font-size:18px;font-weight:bold;color:green;text-align:right;"> Dr.wu</span> <br>
  617. </div> `;
  618. document.body.append(div1);
  619. // let share1 = document.querySelector("a[id='Share1']");
  620. // let share2 = document.querySelector("a[id='Share2']");
  621. let clo = document.querySelector("span[id='clo']");
  622. // share1.onclick = function () {
  623. // window.open("https://greasyfork.org/zh-CN/scripts/500010", "_blank");
  624. // };
  625. // share2.onclick = function () {
  626. // window.open("https://greasyfork.org/zh-CN/scripts/494635", "_blank");
  627. // };
  628. clo.onclick = function () {
  629. alert("真的要关掉吗,不再犹豫一下? Dr.wu")
  630. document.querySelector("div[id='Div1']").style.display = "none"; //关闭温馨提示提示框
  631. };
  632. };
  633.  
  634. function next_video(){
  635. //自动播放下一个视频的
  636. const targetElements = document.querySelectorAll("i[id='top_play']");
  637. const parentElement = targetElements[0].parentElement;
  638. const grandparentElement = parentElement.parentElement;
  639.  
  640. const lis = document.querySelectorAll("li[class='lis-inside-content']");
  641. var index = Array.from(lis).findIndex(li => li === grandparentElement);//找出当前页面是第几个课程
  642. //console.log(index);
  643. if (index + 2 <= document.querySelectorAll("li[class='lis-inside-content']").length) {
  644. index += 2;
  645. //console.log("新的Index:" + index);
  646. document.querySelector("#top_body > div.video-container > div.page-container > div.page-content > ul > li:nth-child(" + index + ") > h2").click();
  647. setTimeout(function () {
  648. document.evaluate("//button[contains(., '知道了')]", document, null, XPathResult.ANY_TYPE).iterateNext().click();
  649. }, 2000);
  650. } else {
  651. // 尝试点击第一个按钮
  652. if ($('button:contains("未学习")').length > 0) {
  653. $('button:contains("未学习")').siblings().eq(0).click();
  654. } else if ($('button:contains("学习中")').length > 0) {
  655. // 如果第一个按钮没有找到,尝试点击第二个按钮
  656. $('button:contains("学习中")').siblings().eq(0).click();
  657. } else if ($('button:contains("待考试")').length > 0 && document.querySelector("a[id='mode']").innerText.indexOf("视频+考试") != -1) {
  658. // 如果前两个按钮都没有找到,尝试点击第三个按钮
  659. $('button:contains("待考试")').siblings().eq(0).click();
  660. } else {
  661. // 如果所有按钮都没有找到,执行其他操作或者提示用户
  662. console.log('没有找到任何按钮');
  663. clearInterval(clock);
  664. // 或者执行其他逻辑
  665. };
  666. };
  667.  
  668. }
  669.  
  670.  
  671.  
  672.  
  673.  
  674. //---------------------------------全局函数区end------------------------------//
  675.  
  676.  
  677.  
  678. })();