广东省国家工作人员学法考试系统刷课xfks-study

广东省国家工作人员学法考试系统刷课

As of 2022-04-22. See the latest version.

// ==UserScript==
// @name         广东省国家工作人员学法考试系统刷课xfks-study
// @namespace    https://greasyforks.org/
// @version      1.01
// @description  广东省国家工作人员学法考试系统刷课
// @author       Cosil.C
// @match        http*://xfks-study.gdsf.gov.cn/study/*
// @icon         http://xfks-study.gdsf.gov.cn/study/static/images/favicon.ico?v2019031285
// @license      GPLv3
// ==/UserScript==

let pathname = window.location.pathname;

//首页
if (pathname.includes('index')) {
  //进入专题
  document.querySelector('.film_focus_imgs_wrap li .card.current div a.btn')?.click();
} else if (pathname.includes('chapter')) {
  //文章页
  setInterval(() => {
    if (document.querySelector('.chapter-score').classList.contains('chapter-score-suc')) {
      let nextChapterBtn = document.querySelector('.next_chapter');
      //跳转下一篇文章
      if(nextChapterBtn){
        console.log('准备跳转下一篇');
        document.querySelector('.next_chapter')?.click();
      }else{
        //跳回目录
        console.log('准备返回目录');
        document.querySelector('.container.title.nav button')?.click();
      }
    } else {
      submitLearn();
    }
  }, 1000);
} else if (pathname.includes('course')) {
  //专题页
  let targets = [].slice.call(document.querySelectorAll('.chapter[chapter="0"] li')).filter(v => {
    //判断文章是否未读
    return v.querySelector('.sub_title')?.innerText.trim() === "" && v.querySelector('.title a');
  })
  if (!targets.length) {
    console.log('该专题学习完毕,准备返回首页')
    window.location.pathname = 'study/index'
  } else {
    //进入文章
    console.log('准备进入文章' + targets[0].querySelector('.title a').innerText)
    targets[0].querySelector('.title a').click()
  }
}
长期地址
遇到问题?请前往 GitHub 提 Issues。