成都市中小学继续教育网站全自动在线挂机学习&自动添加学习记录

https://www.cdjxjy.com/ 网站全自动在线挂机学习&自动添加学习记录

// ==UserScript==
// @name         成都市中小学继续教育网站全自动在线挂机学习&自动添加学习记录
// @namespace    none
// @version      1.1.5
// @description  https://www.cdjxjy.com/ 网站全自动在线挂机学习&自动添加学习记录
// @require      http://libs.baidu.com/jquery/1.8.3/jquery.min.js
// @author       Zed
// @match        https://www.cdjxjy.com/SiteWeb/*
// @match        https://www.cdjxjy.com/IndexMain.aspx*
// @match        https://www.cdjxjy.com/IndexMain.aspx
// @grant        GM_getValue
// @grant        GM_setValue
// ***********************************特此声明***********************************************
// 该脚本完全免费,仅供学习使用,严谨倒卖!!! 如果您是通过购买所得,请找卖家退款!!!
// 尊重作者权益,请勿在未经允许的情况下擅自修改代码和发布到其他平台!
// 作者: Zed
// 更新时间: 2025年2月6日
// ****************************************************************************************
// ==/UserScript==
(function() {
  'use strict';
  var pathMap = ['/SiteWeb/index.htm']
  if (pathMap.includes(GetUrlRelativePath())) {
    $.ajax({
      url: "/ashx/weixindispose.ashx?a=IsLogin",
      type: "POST",
      dataType: "json",
      success: function (data) {
        if (data === 1) {
          if (window.confirm('插件已准备就绪,直接跳转到未完成课程开始自动学习课程? tip: 如果在自动学习的过程中遇到问题,请尝试刷新页面,如果还是有问题,请联系作者')) {
            window.location.href='https://www.cdjxjy.com/IndexMain.aspx#/student/SelectCourseRecord.aspx'
          }

        }
      }
    });
    if (document.cookie.logincookie && window.confirm('插件已准备就绪,直接跳转到未完成课程开始自动学习课程? tip: 如果在自动学习的过程中遇到问题,请尝试刷新页面,如果还是有问题,请联系作者')) {
      window.location.href='https://www.cdjxjy.com/IndexMain.aspx#/student/SelectCourseRecord.aspx'
    }
  }
  console.log(GetUrlRelativePath())


  if (GetUrlRelativePath() === '/IndexMain.aspx' && location.hash.indexOf('SelectCourseRecord') > -1) {
    window.setTimeout(listInit, 3000)
    var current = 0
    function listInit () {
      if (sessionStorage.notFirst === undefined) {
        layer.msg('插件开始工作了...');
        sessionStorage.notFirst = 1
      }
      var iframe = document.getElementsByTagName('iframe')[1].contentWindow
      // 课程名称(可点击)
      var aList = $(".color_span", iframe.document).get()

      // 课程名称(可点击)
      var btnList = $(".xx_ben a", iframe.document).get()
      // list 数据
      var litable = $(".litable", iframe.document).get()
      // 翻页按钮
      var actionList = $("#AspNetPager1 > div", iframe.document).eq(0).children().get()

      var map = litable.map(v => {
        if($(v).html().indexOf('已完成') > -1) {
          return true
        } else return false
      })
      var index = map.findIndex(function (currentValue) {
        return !currentValue
      })
      console.log(index)
      if (index > -1) {
        var selectclassid = getParams('scid', btnList[index].href)
        // 锁定新的课程
        $.ajax({
          url: "/ashx/SelectApi.ashx?a=UpdateSelectState",
          type: "POST",
          data: { "selectclassid": selectclassid },
          dataType: "json",
          success: function () {
            current = 0
            aList[index].click()
            window.setTimeout(studyCourse, 3000)
          }
        });
      } else {
        current += 1
        if (current < actionList.length) {
          actionList[current].click()
          window.setTimeout(listInit, 3000)
        } else {
          console.log('没有找到需要学习的课程,继续寻找')
          window.setTimeout(listInit, 3000)
        }
      }

      function studyCourse () {
        iframe.updata = updata
        iframe.showyzm = function () {}
        iframe.yzIsinput = function () {}
        openOtherInfo()

        var timer = window.setInterval(function () {
          if (iframe.Startime >= +iframe.asknum) {
            $.ajax({
              url: "/ashx/SelectApi.ashx?a=UpdateLookTime",
              type: "POST",
              data: { "selectclassid": iframe.selectclassid },
              dataType: "json",
              success: function (data) {
                console.log(data)
                if (data.message.indexOf('已完成') > -1 || iframe.Startime >= +iframe.asknum + 110) {
                  window.clearInterval(timer)
                  window.location.reload()
                  window.setTimeout(listInit, 3000)
                }
              }
            });
          } else {
            console.log('当前时间:' + iframe.Startime + 's,所需完成时间:' + iframe.asknum + 's')
          }

        }, 60000);

        window.setTimeout(automaticRecording, 60000)
      }

      function updata() {
        iframe.UpdateTime();
        $.ajax({
          url: "/ashx/SelectApi.ashx?a=UpdateLookTime",
          type: "POST",
          data: { "selectclassid": iframe.selectclassid },
          dataType: "json",
          success: function (data) {
            console.log(data, '学习时间记录:' + iframe.Startime)
            if (data.message.indexOf('已完成') > -1) {
              window.location.reload()
              window.setTimeout(listInit, 3000)
            }
          }
        });
        window.setTimeout(updata, 300000)
      }
      // 自动填写学习记录
      function automaticRecording () {
        iframe.alert = function () {}
        // 点击获取评论
        var btn = $("#btncommment", iframe.document).get()[0]
        // 学习记录
        var tab = $(".course-tab .tabItem", iframe.document).eq(1).get()[0]
        btn.click()
        tab.click()
        window.setTimeout(function () {
          var firstlabel = $("#UpdatePanel2 .label", iframe.document).eq(0).get()[0]
          var content = (firstlabel.innerHTML || '').padEnd(50)
          $("#txtareainnertContents", iframe.document).val(content)
          $("#txtareaExperience", iframe.document).val(content);
          $("#AddRecord", iframe.document).click()
        }, 3000)
      }

    }

  }

  // 获取当前窗口相对路径
  function GetUrlRelativePath(){
    return window.location.pathname
  }

  //  获取参数
  function getParams(name, target) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = target.substr(1).match(reg);  //匹配目标参数
    if (r != null) return unescape(r[2]); return null; //返回参数值
  }

  // 显示作者信息
  function openOtherInfo(){
    try {
      layer.open({
        type: 1,
        skin: 'layui-layer-rim', //加上边框
        area: ['400px', '540px'], //宽高
        offset: 'rb',
        shade :0,
        content: '<div style="padding: 10px;">该插件仅供学习使用,严谨倒卖<br/>' +
            '<span style="color:red">请升级最新版本</span><br/>' +
            '</div>'
      });
    } catch (error) {
      console.log(error)
    }

  }
})();