LAW

LC AUTO WATCH

目前為 2022-09-29 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         LAW
// @namespace    http://tampermonkey.net/
// @version      2.80
// @description  LC AUTO WATCH
// @author       You
// @match        https://edu.inspur.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=inspur.com
// @grant        none
// ==/UserScript==
let curTime = "";
function refreshSchedule(){
    const divStartArea=document.getElementById('divStartArea');
    if(divStartArea!==null){
        const spanLeavTimes=document.getElementById('spanLeavTimes').innerText;
        if(divStartArea.style.display==="none"){
            window.history.back(-1);
        }else{
            if(curTime===""||curTime===spanLeavTimes){
                myPlayer.play();
            }else{
                console.log(divStartArea.innerText);
            }
            curTime=spanLeavTimes;
        }
    }
}
function setCookie(cname,cvalue,exdays)
{
  var d = new Date();
  d.setTime(d.getTime()+(exdays*24*60*60*1000));
  var expires = "expires="+d.toGMTString();
  document.cookie = cname + "=" + cvalue + "; " + expires +";path=/";
}
function getCookie(cname)
{
  var name = cname + "=";
  var ca = document.cookie.split(';');
  for(var i=0; i<ca.length; i++)
  {
    var c = ca[i].trim();
    if (c.indexOf(name)==0) return c.substring(name.length,c.length);
  }
  return "";
}
(function() {
    'use strict';
    let i=1;
    while(1){
        let contentitem=document.getElementById('contentitem'+i);
        if(contentitem!==null){
            let url=$('#contentitem'+i).attr('onclick').match(/learningKnowledge\(\"(.*).html"/)[1]+".html",flag=false;
            console.log(url);
            let skipstr=getCookie('skip'),skip=[];
            if(skipstr!==''){
                skip=JSON.parse(skipstr);
            }
            for(let s of skip){
                if(s===url){
                    flag=true;
                    break;
                }
            }
            if(flag){
                i++;
                continue;
            }
            window.location.href=window.location.href;
            setCookie('tmp',url,1);
            window.location.href=url;
        }else{
            break;
        }
        i++;
    }

    const tbodyTrainInfo=document.getElementById('tbodyTrainInfo');
    if(tbodyTrainInfo!==null){
        let trs = tbodyTrainInfo.children,i;
        console.log(trs);
        for(i =1;i<trs.length;i++){
            if(trs[i].nodeName==='TR'){
                //console.log(trs[i]);
                let str=trs[i].lastElementChild.lastElementChild.lastElementChild.innerText;
                if(str==="100%"||str==="查看"){
                    continue;
                }
                if(str==="开始考试"){
                    let skipstr=getCookie('skip'),tmp=getCookie('tmp'),skip=[];
                    if(tmp!==''){
                        if(skipstr!==''){
                            skip=JSON.parse(skipstr);
                        }
                        skip.push(tmp);
                        setCookie('skip',JSON.stringify(skip),1);
                    }
                    window.history.back(-1);
                    break;
                }
                window.location.href=window.location.href;
                let url=trs[i].getAttribute('onclick');
                console.log(url);
                window.location.href=url.match(/return StudyRowClick\(\'(.*).html?/)[1]+".html";
                break;
                //window.history.pushState(null,"",url.match(/return StudyRowClick\(\'(.*).html?/)[1]+".html");
            }
        }
        if(i>0&&i==trs.length){
            window.history.back(-1);
        }
    }

    const tableContainer=document.getElementById('tableContainer');
    if(tableContainer!==null){
        let trs = tableContainer.firstElementChild.firstElementChild.children;
        console.log(trs);
        if(trs.length>1&&trs[1].nodeName==='TR'&&trs[1].className!=="empty"){
            //console.log(trs[1]);
            window.location.href=window.location.href;
            let check=trs[1].firstElementChild.firstElementChild.firstElementChild;
            if(check!==null){
                check.checked=true;
                ClickSelf(check);
                $('#hidDeleteType').val("BacthDelete");
                document.getElementById('btnDelete').click();
            }
            let url=trs[1].children[2].innerHTML;
            console.log(url);
            window.location.href=url.match(/isOpenFaceId\(&quot;&quot;,&quot;&quot;,&quot;(.*).html?/)[1]+".html";
            //window.location.replace(url.match(/isOpenFaceId\(&quot;&quot;,&quot;&quot;,&quot;(.*).html?/)[1]+".html");
        }
    }

    const normalrow=document.getElementsByClassName('normalrow clearfix');
    if(normalrow!==null){
        let i=0;
        for(;i<normalrow.length;i++){
            if(normalrow[i].nodeName==='DIV'){
                let str=normalrow[i].getElementsByClassName('fontnumber study-schedule')[0].innerHTML;
                if(str.match(/100.0%/)!==null){
                    continue;
                }
                window.location.href=window.location.href;
                let url=normalrow[i].getElementsByClassName('text-color6')[0].getAttribute('href');
                console.log(url);
                window.location.href=url.match(/javascript:void\(StudyRowClick\(\'(.*).html?/)[1]+".html";
                break;
            }
        }
        if(i>0&&i==normalrow.length){
            window.history.back(-1);
        }
    }
    let timer=null;
    clearInterval(timer);
    timer=setInterval(() => {
        refreshSchedule();
    }, 10000);
    if(typeof phaseTrackIntervalTime!=='undefined'){
        phaseTrackIntervalTime = 60000;
    }
    // Your code here...
})();