贵州省专业技术人员继续教育平台一键学完(Javascript代码)

let courseId=""
let worksId=""
let url_PostData="https://gzjxjy.gzsrs.cn/gzjxjy/front/api/study/save"
let method_Post="POST"
let totalHour=""
let body_Post=""

let url_GetData=""
let method_Get="GET"
let body_Get=null

let authorization=sessionStorage.getItem("authorization").replace("Bearer ","")

async function getCourseID() {
  const url = window.location.href
  const match = url.match(/id=([^&]+)/);
  const id = match ? match[1] : null;
  return id
}

async function getOrPost(url,method,body){
    let f=await fetch(url, {
        "headers": {
          "accept": "application/json, text/plain, */*",
          "accept-language": "zh-CN,zh;q=0.9",
          "authorization": authorization,
          "content-type": "application/x-www-form-urlencoded",
          "priority": "u=1, i",
          "sec-ch-ua": "\"Google Chrome\";v=\"135\", \"Not-A.Brand\";v=\"8\", \"Chromium\";v=\"135\"",
          "sec-ch-ua-mobile": "?0",
          "sec-ch-ua-platform": "\"Windows\"",
          "sec-fetch-dest": "empty",
          "sec-fetch-mode": "cors",
          "sec-fetch-site": "same-origin"
        },
        "referrerPolicy": "no-referrer",
        "body": body,
        "method": method,
        "mode": "cors",
        "credentials": "include"
      })
      return f.json()
}

async function getData(id,g_url,g_method,g_body,p_url,p_method,p_body) {
  let r=await getOrPost(g_url,g_method,g_body)
  for await(let list of r.data.works){
    let Progress=list && list.statistics && list.statistics.statProgress
    if(Progress!="100"){
        console.log(Progress)
        totalHour=await list.mediaDuration
        worksId=await list.worksId
        id=await getCourseID()
        p_body=`courseId=${id}&worksId=${worksId}&totalHour=${totalHour}&studyTime=${totalHour}&courseType=10&`
        console.log(p_body)
        await postData(p_url,p_method,p_body)
    }else{
      continue
    }
  }
}

async function postData(url,method,body) {
let result=await getOrPost(url,method,body)
  if(result.status=="OK"){
      console.log("完成")
  }else{
      console.log("失败")
  }
}

courseId=await getCourseID()
url_GetData=`https://gzjxjy.gzsrs.cn/gzjxjy/front/api/course/getCourseInfo?courseId=${courseId}`
await getData(courseId,url_GetData,method_Get,body_Get,url_PostData,method_Post,body_Post)
window.location.reload()

 

posted @ 2025-07-08 17:07  白嫖帝  阅读(43)  评论(1)    收藏  举报