Greasy Fork

Greasy Fork is available in English.

91huayi

华医刷课

当前为 2022-06-24 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         91huayi
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  华医刷课
// @author       You
// @match        http://cme23.91huayi.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=91huayi.com
// @grant        none
// @run-at       document-end
// @license      MIT
// ==/UserScript==

(function() {
  'use strict';

  const isWatching = window.location.pathname === "/course_ware/course_ware_polyv.aspx";
  const isTesting = window.location.pathname === "/pages/exam.aspx"

  const allCourse = ['http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=9be362b6-2fde-4b75-9770-ae8e010d9ebc', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=5e2264e6-748f-428f-934d-ae8d0156fff9', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=2f1f5ef1-8966-4c2e-acda-ae8d0156fff9', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=48e195b0-1280-43f4-baa3-ae8d0156fff9', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=4a67b92f-2df2-4eb4-bc7c-ae8d0156fff9', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=89bafb6b-339d-4f3f-8d6a-ae8d01574de3', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=c393d570-f550-46da-813f-ae8d01574de3', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=cfe8a18f-8140-4f60-ade6-ae8d01574de3', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=07c0ebb0-6335-4670-af51-ae8e00d10831', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=e5fc1168-b4bc-4c3c-acb8-ae8e00d11c0c', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=733b3ee6-4523-4133-a587-ae8e00d12da6', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=4bd3ae92-2019-4171-893f-ae8e00d14c7e', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=a0fbfba8-21a5-4b69-aa2d-ae8e00d15bc3', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=cb933f91-5e9c-43dc-a5af-ae8e00d16cf7', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=aa9c36a6-a354-4100-a7fe-ae8e00d17d6f', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=bfaf6a4c-65f3-4976-96d2-ae8e00d18b9d', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=959e45fd-38f7-45a9-9580-ae8e00d19a04', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=8635cd07-ea7d-401a-938d-ae8e00d1b454', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=9ac29ca4-e638-4a3d-bd31-ae8e00dd3ac2', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=0847dd0f-7c05-4a54-ab37-ae8e00dd5743', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=147e4ae3-a220-42ce-a0dc-ae8e00dd5743', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=d7417530-b67b-4670-a6a2-ae8e00dd45f4', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=b5b50fdb-20c4-4656-a044-ae8e00dd3ac2', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=4cdd1cf3-e5e3-408b-b492-ae8e00dd5743', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=1aab8e2a-2b9d-4eb2-830f-ae8e00dd2f09', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=21049461-3e9a-4141-a7b1-ae8e00dd3ac2', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=65d84ace-92db-4271-89a7-ae8e00dd5743', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=0d7f78aa-2691-4517-a7ce-ae8e00dd2f09', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=b0bd1279-17d6-488a-a41a-ae8e00dd2f09', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=a096a404-7859-4d39-bae7-ae8e00dd3ac2', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=95f435ab-6e14-4082-8cb2-ae8e00dd2f09', 'http://cme23.91huayi.com/course_ware/course_ware.aspx?cwid=8fcf83c5-78c2-4a9b-bee0-ae8e00dd2f09']

  const sleep = (time = 1000) => new Promise(resolve => setTimeout(resolve, time))

  const request = async (url) => {
    const response = await fetch(url, {mode: 'cors', credential: 'include'})
    const resData = await response.json()
    return resData.body
  }
  let answer
  const getAnswer = async () => {
      answer = await request(`http://cme23.91huayi.com/ashx/get_course_ware_process.ashx?relation_id=${cwrid}&video_type=polyv`);
      console.log('answeer', answer)
  }



  const goToNext = async () => {
    const curIndex = allCourse.findIndex(i => i.includes(window.location.search))
    if (curIndex < 0) {
      return
    }
    window.open(allCourse[curIndex + 1])
    await sleep()
    window.close()
  }

  const doTest = async () => {
    console.log('beep --', )
    const completed = document.getElementsByClassName('pv-progress-current-bg')[0].style.width == '100%'
    if (completed) {
      localStorage.setItem('answer', window.JSON.stringify(answer))
      document.getElementById('jrks').click()
      return
    }
    const popupContainer = document.getElementsByClassName('pv-ask-modal')[0]
    if (!popupContainer) {
      return
    }
    const innerText = popupContainer.innerText
    const answerItem = answer.find(i => innerText.includes(i?.question) )
    console.log('answerItem',answerItem)
    const rightIndex = answerItem?.choices.findIndex(i => i?.right_answer == 1)
    console.log('rightIndex',rightIndex)
    popupContainer.getElementsByClassName('pv-ask-form')[rightIndex].getElementsByTagName('input')[0].click()
    await sleep()
    popupContainer.getElementsByClassName('pv-ask-submit')[0].click()
    await sleep()
    document.querySelectorAll('.pv-ask-foot .pv-ask-default')[0].click()
    
  }

  if (isWatching) {
    getAnswer()
    setInterval(doTest, 5000)
  }

  const doExam = async() => {
    answer =  window.JSON.parse(localStorage.getItem('answer'))
    
    const questionTable = Array.from(document.getElementById('gvQuestion').getElementsByTagName('table'))
    questionTable.forEach((table, index) => {
      const innerText = table.innerText
      const answerItem = answer.find(i => innerText.includes(i?.question) )
      if (answerItem) {
        console.log('answerItem',answerItem)
        const rightIndex = answerItem?.choices.findIndex(i => i?.right_answer == 1)
        console.log('rightIndex',rightIndex)
        questionTable[index + 1].getElementsByTagName('input')[rightIndex].click()
      }
    })
    await sleep()
    document.getElementById('btn_submit').click()
    await sleep()
    // goToNext()
  }
  if (isTesting) {
    // doExam()
  }


})();