Greasy Fork is available in English.

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

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

// ==UserScript==
// @name         广东省国家工作人员学法考试系统刷课xfks-study
// @namespace    https://greasyfork.org/
// @version      1.03
// @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')) {
  //进入专题
  let nextCourseBtn = document.querySelector('.film_focus_imgs_wrap li .card.current div a.btn');
  if(nextCourseBtn){
    nextCourseBtn.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('准备跳转下一篇');
        nextChapterBtn.click();
      } else {
        //跳回目录
        console.log('准备返回目录');
        let navBackBtn = document.querySelector('.container.title.nav button');
        if(navBackBtn){
          navBackBtn.click();
        }
      }
    } else {
      submitLearn();
    }
  }, 1000);
} else if (pathname.includes('course')) {
  //专题页
  let targets = [].slice.call(document.querySelectorAll('.chapter li')).filter(v =>
    //判断文章是否未读
    v.querySelector('.sub_title')?.innerText.trim() === "" && v.querySelector('.title a')?.href
  )
  if (targets.length == 0) {
    console.log('该专题学习完毕,准备返回首页')
    window.location.pathname = 'study/index'
  } else {
    //进入文章
    console.log('准备进入文章' + targets[0].querySelector('.title a').innerText)
    targets[0].querySelector('.title a').click()
  }
}