脚本--自用

找个地方放代码

// ==UserScript==
// @name        2021年惠来县小学教师全员轮训
// @namespace   Violentmonkey Scripts
// @match       http*://study.teacheredu.cn/proj/studentwork/study.htm*
// @match       http*://study.teacheredu.cn/proj/studentwork/courseListNew*
// @match       http*://study.teacheredu.cn/proj/studentwork/course_list_new.htm*
// @grant       none
// @version     1.0
// @author      -
// @description 2021/8/6 下午9:30:45
// ==/UserScript==


init();

/**
 * 执行入口
 */
function init() {
  if (window.location.href.includes('studentwork/study.htm')) {
      //视频页
    console.log('准备执行视频页脚本');
    setTimeout(function () {
      study();
    }, 1000);

  } else if (window.location.href.includes('courseListNew')) {
      //课程页
    console.log('课程页');
    setTimeout(function () {
      handleCourse();
    }, 1500);
    // 80分钟后,新窗口就关了,该打开新窗口了
    setTimeout(function () {
      window.location.reload();
    }, 4810000);
  }
}

function study() {
  console.log(randomTime);
  // 设置randomTime 为-1 ,不弹窗。
  randomTime = -1;
  
  let timeI = 0;
  let playingInterval;
  playingInterval = setInterval(function () {
    console.log('定时器存活 ');
//     if(timeI == 10) {
//       console.log('测试关窗口' + timeI);
      
//       window.close();
//     }
    timeI = timeI+1;
    // 20分钟执行一次存时间
    if(timeI%1200 == 0) {
      console.log('执行存储时间' + timeI);
      console.log('执行存储时间' + timeI);
      updateStudyTime(0);
    }
    
    // 操作弹窗
    var _alert=window.alert;
    window.alert=function(msg){
      console.log(msg);
      _alert.dismiss();
    }
    
    var _confirm=window.confirm;
    window.confirm=function(msg){
      console.log(msg);
      return true;
    }
    
    // 一个小时20分钟后退出
    if(timeI == 4810) {
    // if(timeI == 5) {
      
      // exit_study_btn
      // console.log(document.querySelectorAll('.video_title_time fr'));
      exitStudy();
      // window.close();
      return true;
    }
  }, 1000)
}

function handleCourse() {
  // kcxx_side_title fl Course_list_info
  console.log(document.querySelectorAll('.list'));
  let list = document.querySelectorAll('.list');
  if( !list.length ) {
    window.location.reload();
    return;
  }
  for (let i = 0 ;i<list.length ;i+=1) {
    let strings = list[i].children[0].childNodes[3].childNodes[1].outerText;
    // console.log(strings);

    var str ; 
    str = strings.match(/已学习 (\S*) 分钟/)[1]; 
    // console.log(str);
    if(parseInt(str) <= 40) {
      list[i].children[0].childNodes[1].childNodes[1].onclick();
      window.close();
      break;
    }
  }
  
}






// ==UserScript==
// @name        2021年惠来县小学幼儿园“三区”教师全员轮训
// @namespace   Violentmonkey Scripts
// @match       http*://study.teacheredu.cn/proj/studentwork/study.htm*
// @match       http*://study.teacheredu.cn/proj/studentwork/courseListNew*
// @match       http*://study.teacheredu.cn/proj/studentwork/course_list_new.htm*
// @grant       none
// @version     1.0
// @author      -
// @description 2021/8/6 下午9:30:45
// ==/UserScript==


init();

/**
 * 执行入口
 */
function init() {
  if (window.location.href.includes('studentwork/study.htm')) {
      //视频页
    console.log('准备执行视频页脚本');
    setTimeout(function () {
      study();
    }, 1000);

  } else if (window.location.href.includes('courseListNew')) {
      //课程页
    console.log('课程页');
    setTimeout(function () {
      handleCourse();
    }, 1500);
    // 80分钟后,新窗口就关了,该打开新窗口了
    setTimeout(function () {
      window.location.reload();
    }, 4810000);
  }
}

function study() {
  console.log(randomTime);
  // 设置randomTime 为-1 ,不弹窗。
  randomTime = -1;
  
  let timeI = 0;
  let playingInterval;
  playingInterval = setInterval(function () {
    console.log('定时器存活 ');
//     if(timeI == 10) {
//       console.log('测试关窗口' + timeI);
      
//       window.close();
//     }
    timeI = timeI+1;
    // 20分钟执行一次存时间
    if(timeI%1200 == 0) {
      console.log('执行存储时间' + timeI);
      console.log('执行存储时间' + timeI);
      updateStudyTime(0);
    }
    
    // 操作弹窗
    var _alert=window.alert;
    window.alert=function(msg){
      console.log(msg);
      _alert.dismiss();
    }
    
    var _confirm=window.confirm;
    window.confirm=function(msg){
      console.log(msg);
      return true;
    }
    
    // 一个小时20分钟后退出
    if(timeI == 4800) {
      window.close();
      return true;
    }
  }, 1000)
}

function handleCourse() {
  // kcxx_side_title fl Course_list_info
  console.log(document.querySelectorAll('.list'));
  let list = document.querySelectorAll('.list');
  if( !list.length ) {
    window.location.reload();
    return;
  }
  for (let i = 0 ;i<list.length ;i+=1) {
    let strings = list[i].children[0].childNodes[3].childNodes[1].outerText;
    // console.log(strings);

    var str ; 
    str = strings.match(/已学习 (\S*) 分钟/)[1]; 
    // console.log(str);
    if(parseInt(str) <= 30) {
      list[i].children[0].childNodes[1].childNodes[1].onclick();
      break;
    }
  }
}

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 10
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值