// ==UserScript== // @name 2026华医网公需课: 加快培育发展新质生产力自动考试脚本 // @namespace http://https://scriptcat.org/zh-CN/ // @version 0.1 // @description 2026年华医网公需课:<<加快培育发展新质生产力>> 自动考试脚本 // @author 公众号学分集结号 // @include http://cme*.91huayi.com/* // @include https://cme*.91huayi.com/* // @include https://dk.91huayi.com/* // @include https://sdnew.91huayi.com/* // @run-at document-start // @grant GM_xmlhttpRequest // @grant GM.setValue // @grant GM.getValue // @grant unsafeWindow // @license MIT // ==/UserScript== (function() { 'use strict'; const DK_HOST = "dk.91huayi.com"; var courseInterID = 0; let first = true; var _alert =window.alert; function overrideSelectNativeJS_Functions () { window.alert = function alert (message) { console.log (message); return true; } } (function (funcToRun) { var D = document; var scriptNode = D.createElement ('script'); scriptNode.type = "text/javascript"; scriptNode.textContent = '(' + funcToRun.toString() + ')()'; var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement; targ.appendChild (scriptNode); })(overrideSelectNativeJS_Functions); const requestAsync = function(url, data) { return new Promise((resolve, reject) => { var reportAJAX_Error = (rspObj) => { console.error (`Request error: ${data}`); reject(`Request => Error ${data} RES ${rspObj.status}! ${rspObj.statusText}`); } var processJSON_Response = (rspObj) => { if (rspObj.status != 200 && rspObj.status != 304) { reportAJAX_Error (rspObj); } else { resolve(rspObj.responseText); } }; GM_xmlhttpRequest ( { method: "GET", url: url, timeout: 6000, headers: { "Referer": document.location.href, "Content-Type": "application/x-www-form-urlencoded" }, responseType: "text/html", onload: processJSON_Response, onabort: reportAJAX_Error, onerror: reportAJAX_Error, ontimeout: reportAJAX_Error }); }); } const getUrlParameter = function getUrlParameter(sParam) { var sPageURL = window.location.search.substring(1), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return typeof sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); } } return false; }; const findFirstLesson = function(studyImgArr) { if (studyImgArr) { for (let i = 0; i < studyImgArr.length; i++) { if (studyImgArr[i].src.endsWith("anniu_01a.gif")) { return i; } } } return -1; } const nextLesson = async function(cwid) { await wait(10 * 1000); let cid = await GM.getValue('cid'); console.log("CID", cid); let hrefs = await GM.getValue(cid); for (let i = 0; i < hrefs.length - 1; i++) { if (hrefs[i].indexOf(cwid) != -1) { window.location.href = hrefs[i + 1]; } } } const wait = ms => new Promise(resolve => setTimeout(resolve, ms)); function isPromise(obj) { return !!obj && ((typeof obj === 'object' && typeof obj.then === 'function') || (typeof obj === 'function' && typeof obj().then === 'function')); } function waitResource(resourceFn, options) { var optionsRes = Object.assign( { interval: 3000, max: 10 }, options ); var current = 0; return new Promise((resolve, reject) => { var timer = setInterval(() => { if (isPromise(resourceFn)) { resourceFn().then(res => { if(res) { clearInterval(timer); resolve(); } }); } else if (resourceFn()) { clearInterval(timer); resolve(); } current++; if (current >= optionsRes.max) { clearInterval(timer); reject('Time out'); } }, optionsRes.interval); }); } const ANSWER_DICT = { '796074b2-047b-4478-884a-289696413716': ['a22bb502-31f2-4f55-b182-b44b00f52abd'], 'fb99f153-e165-4f0b-883f-2366bd2e8240': ['066025c3-fc24-4843-81aa-b44b00f52abd'], '0c496bf4-e624-4750-abc8-4c0b5f46f3c0': ['6c83c388-27e1-471a-ada0-b44b00f52abd'], 'db3d2a07-c3c6-4f2c-8135-4d0da590e6ae': ['0847c7ed-ce4f-4d15-baa4-b44b00f52abd'], '64108539-fb09-4f67-b06a-5988b92a305a': ['75ca94d6-21b6-40e2-ba5e-b44b00f52abd'], '4cc79118-869c-48df-91b9-79549476ec86': ['b85d67bf-ef35-45b7-8200-b44b00f52abd'], '2d429191-62cc-4992-b433-6ab10054c5bb': ['307b5cff-23f0-479c-beaf-b44b00f52abd'], 'd73a9eaa-6e23-485d-90da-9efdee3085a1': ['03e72cc2-e5a3-4b87-898e-b44b00f52abd'], '76e433c4-4a87-43a8-98cc-b676d133c63c': ['a783d116-07d3-4918-88b1-b44b00f52abd'], 'a4e381e0-8ff9-4183-969e-e865842c0af5': ['f98fe885-9383-4187-928a-b44b00f52abd'], 'aa8756c1-83b1-4025-8470-2bc10a150c12': ['51884dc6-4719-4ade-bf16-b44b00f52abd','89527b39-c2bc-4412-aa4f-b44b00f52abd','fdcc6dd2-36ce-46eb-876c-b44b00f52abd','5d1dfbec-f04c-4bc1-b168-b44b00f52abd'], '715d09de-d971-4fcb-84a7-59b4ef666e7d': ['57f7bfb5-35d5-48a7-85d2-b44b00f52abd','580baa05-de0f-4f2e-a28f-b44b00f52abd','8cf040af-7c42-49e7-88af-b44b00f52abd'], 'ddef490a-1543-4dd3-8144-8ad58664edd3': ['2b6c039e-f38b-4dc2-8c36-b44b00f52abd','be7d33ff-0d76-4d45-bf37-b44b00f52abd','dbf121e0-c611-4cff-a034-b44b00f52abd'], '297fefee-eb37-4ced-bece-8300db67a74f': ['71e20dfe-54e3-422f-b3de-b44b00f52abd','29ab9335-8f30-4bf7-bc90-b44b00f52abd','c78ff668-bd16-4575-9738-b44b00f52abd','49ee0180-313e-4b3a-8bb6-b44b00f52abd'], '3ff53d31-3b2b-4f33-92ff-b9a012cb0587': ['f5c98791-261d-412e-8437-b44b00f52abd','239270a3-7b4a-472d-bdf3-b44b00f52abd','58aae8cc-1bb3-47bf-a12e-b44b00f52abd'], '883076dd-d8bb-4686-93bb-b9df1762de4f': ['1a4a26af-9e78-4a6b-b327-b44b00f52abd','6a2a1e3f-ab68-45d1-afe0-b44b00f52abd','c0128822-b5ae-47cd-bcd4-b44b00f52abd','03b1c809-e1f6-418f-9a49-b44b00f52abd','ad617457-1419-4acd-bbdc-b44b00f52abd'], 'ca06cfa5-085c-4297-b4da-d4b6527b2a4a': ['d6f163ad-e28a-41b4-8687-b44b00f52abd','f5e8a4ea-2ae4-4860-b7f7-b44b00f52abd','6f6650b0-effa-4e19-ab9d-b44b00f52abd'], 'd2a0c55d-2c1d-4c7c-8ca2-e7ca19984a1b': ['6c0706a1-b128-457c-be55-b44b00f52abd','79bf9e07-8418-414b-9288-b44b00f52abd','18738398-d58a-47aa-a065-b44b00f52abd','a3d42ecc-19a8-4dfe-960a-b44b00f52abd'], 'f4183b6b-96cc-4b31-a15c-df5858b2b079': ['e8c5b4f7-1625-44a4-8b01-b44b00f52abd','1e15253b-287a-4379-b09b-b44b00f52abd','455f96e4-e479-4374-94b1-b44b00f52abd','059ead72-ee17-41a4-b489-b44b00f52abd'], 'b526be89-2308-4433-a7bb-112954931722': ['c476430a-0509-4d3f-b325-b44b00f52abd','3c4dc42c-4ee9-4dde-802d-b44b00f52abd','71ecf9f5-3b2d-4d1c-aa91-b44b00f52abd','ab2a18fd-fbb6-4430-a717-b44b00f52abd'], '27498630-4972-49e0-b25c-100dfe8e486e': ['N'], '174cafe4-03cd-479a-bbf3-6f87843c09a1': ['Y'], '0f202937-7e28-45bd-ae73-2abf3f7b2e67': ['Y'], 'f3e6bdf3-3b29-4820-8aa9-47f5976742fc': ['Y'], '0b1be944-f7d8-4feb-882d-7055b88d12cb': ['N'], '7b81bc04-1210-4375-a2c1-7992e59b75bd': ['Y'], '37659345-e6ae-446c-9ee8-9993e403dc16': ['N'], '39885f76-5dc0-4d25-88f5-aa7fb10bf546': ['Y'], 'fbfa32fc-590c-4924-9c6e-afc294a20743': ['Y'], '63843c45-3a7b-4ca8-acf3-b30be359e914': ['N'], }; if (getUrlParameter('cwid') || getUrlParameter('cid')) { let alrtScope; if (typeof unsafeWindow === "undefined") { alrtScope = window; } else { alrtScope = unsafeWindow; } alrtScope.alert = function (str) { console.log ("Greasemonkey intercepted alert: ", str); }; } if (window.top !== window.self) { return; } if (window.location.host !== DK_HOST && window.location.pathname == '/course_ware/course_ware_polyv.aspx') { console.log("单个课程页面"); let inter = setInterval(function() { try { if (first && typeof player !== "undefined") { first = false; console.log("FIRST:", first); player.sendQuestion = function(data) {}; clearInterval(inter); } } catch (err) { console.log(err); } }, 10); let initRateFlag = true; let lastTime = 0; courseInterID = setInterval(async function() { if (first) { console.log("sendQuestion should be empty function"); return; } if (typeof closeProcessbarTip === "function") { closeProcessbarTip(); } if (!$("#jrks")[0].getAttribute('disabled')) { let cwid = getUrlParameter('cwid'); if (ANSWER_DICT[cwid]) { try { let examHref = $("#jrks")[0].href; if (examHref && examHref.indexOf("exam.aspx") != -1) { let content = await requestAsync(examHref, {}); if (content.indexOf("请进行课件观看学习完成后再进行考试") != -1) { window.location.reload(); clearInterval(courseInterID); } else { window.location = $("#jrks")[0].href; clearInterval(courseInterID); } } } catch (err) { console.error(err); } } else { await nextLesson(cwid); clearInterval(courseInterID); } } await GM.setValue("curCWID", getUrlParameter('cwid')); let curTime = player.j2s_getCurrentTime(); if (curTime === lastTime && curTime < player.j2s_getDuration()) { console.log(curTime, "try to resume"); player.j2s_setVolume(0); player.j2s_resumeVideo(); console.log("resume successfully"); } lastTime = curTime; if (initRateFlag) { let rate = await GM.getValue('rate', 1); if (player) { player.changeRate(rate); initRateFlag = false; } } else { await GM.setValue('rate', player.currentRate); } }, 3000); } if (window.location.pathname == '/pages/noplay.aspx') { setTimeout(async function() { let cwid = await GM.getValue("curCWID"); window.location.href = "/course_ware/course_ware.aspx?cwid=" + cwid; }, 5000); } if (window.location.pathname == '/pages/exam.aspx') { setTimeout(async function() { await waitResource(() => !!document.querySelector("#btn_submit")); let cwid = getUrlParameter('cwid'); console.log("CWID:", cwid); let answer = ANSWER_DICT[cwid]; if (answer) { for (let item of answer) { if (item.startsWith('gvQuestion')){ $('#' + item).click(); } else { $(`[value=${item}]`).click(); } await wait(200); } $('#btn_submit').click(); } }, 3000); } if (window.location.pathname == '/ExamInterface/ComputerExamIndex') { setInterval(async function() { let qid = $('.dd_01').attr('questionid'); let answer = ANSWER_DICT[qid]; if (answer) { for (let item of answer) { if (item.startsWith('gvQuestion')){ $('#' + item).click(); } else { $(`[value=${item}]`).click(); } await wait(500); } if ($('#btnNext') && $('#btnNext').css('display') != 'none') { $('#btnNext').click(); } else { $('.submitExam').click(); await wait(500); $('#subPaper').click(); } } }, 5 * 1000); } if (window.location.pathname == '/pages/exam_result.aspx') { setTimeout(async function() { let cwid = getUrlParameter('cwid'); await nextLesson(cwid); }, 3000); } if (window.location.pathname == '/pages/course.aspx') { console.log("目录面"); let interId = setInterval(async function() { let hrefs = document.querySelectorAll(".course h3 a"); let vals = []; for (let i = 0; i < hrefs.length; i++) { vals.push(hrefs[i].href); } let cid = getUrlParameter('cid') await GM.setValue(cid, vals); await GM.setValue('cid', cid); console.log("Course list have been set."); clearInterval(interId); }, 3000); } if (window.location.pathname == '/course_ware/course_ware_list.aspx') { console.log("目录面"); let interId = setInterval(async function() { let eles = document.querySelectorAll(".xx"); if (eles.length === 0) { eles = document.querySelectorAll(".wx"); } if (eles.length > 0) { eles[0].nextElementSibling.click(); clearInterval(interId); } }, 3000); } if (window.location.host === DK_HOST && window.location.pathname == '/course_ware/course_ware_polyv.aspx') { console.log("单个课程页面"); let inter = setInterval(function() { try { if (first && typeof player !== "undefined") { first = false; console.log("FIRST:", first); player.sendQuestion = function(data) {}; clearInterval(inter); } } catch (err) { console.log(err); } }, 10); let initRateFlag = true; let lastTime = 0; courseInterID = setInterval(async function() { if (first) { console.log("sendQuestion should be empty function"); return; } if (typeof closeProcessbarTip === "function") { closeProcessbarTip(); } let curTime = player.j2s_getCurrentTime(); if (curTime === lastTime && curTime < player.j2s_getDuration()) { console.log(curTime, "try to resume"); player.j2s_setVolume(0); player.j2s_resumeVideo(); console.log("resume successfully"); } lastTime = curTime; if (initRateFlag) { let rate = await GM.getValue('rate', 1); if (player) { player.changeRate(rate); initRateFlag = false; } } else { await GM.setValue('rate', player.currentRate); } }, 3000); } function createAd(side) { const el = document.createElement('div'); el.className = 'huayi-ad-float huayi-ad-' + side; el.innerHTML = '' + '