Triment / blog

0 stars 0 forks source link

四川自考办的抢票脚本 #92

Open Triment opened 1 year ago

Triment commented 1 year ago
// ==UserScript==
// @name         挤爆自考
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://zk.sceea.cn
// @icon         https://www.google.com/s2/favicons?sz=64&domain=sceea.cn
// @grant        none
// ==/UserScript==

function createELE(eleTag, title, event){
  const div = document.createElement("div");
  const titleTag = document.createElement(eleTag);
  titleTag.innerText = title;
  const input = document.createElement("input");
  input.addEventListener("input", event);
  div.appendChild(titleTag);
  div.appendChild(input);
  return div
}

(function () {
  "use strict";
  const userinfo = {
    idCode: '',
    code: '',
    pwd: ''
  }
  const idCodeTag = createELE('span', "输入身份证", ({ target: { value } })=>{
    userinfo.idCode = value
  })
  const pwdTag = createELE('span', "输入密码", ({ target: { value } })=>{
    userinfo.pwd = value
  })

  const reqLogin = ({ target: { value } }) => {
    if (value.length === 4) {
      const t = setInterval(() => {
        if (Date.now() >= new Date("2023-09-12 09:00:00").getTime()) {
          fetch("https://zk.sceea.cn/RegExam/elogin?resourceId=login", {
            headers: {
              accept: "application/json, text/javascript, */*; q=0.01",
              "accept-language": "zh-CN,zh;q=0.9",
              "content-type":
                "application/x-www-form-urlencoded; charset=UTF-8",
              "sec-ch-ua":
                '"Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"',
              "sec-ch-ua-mobile": "?0",
              "sec-ch-ua-platform": '"macOS"',
              "sec-fetch-dest": "empty",
              "sec-fetch-mode": "cors",
              "sec-fetch-site": "same-origin",
              "x-requested-with": "XMLHttpRequest",
            },
            referrer: "https://zk.sceea.cn/",
            referrerPolicy: "strict-origin-when-cross-origin",
            body: `name=${userinfo.idCode}&code=${value}&pwd=${userinfo.pwd}`,
            method: "POST",
            mode: "cors",
            credentials: "include",
          })
            .then((res) => res.text())
            .then((d) => {
              if (d != "7") {
                clearInterval(t);
                window.location.replace("/RegExam/switchPage?resourceId=view");
              } else {
                console.log(d);
              }
            });
        }
      }, 100);
    }
  }
  const codeTag = createELE('span', "输入验证码", reqLogin)
  const div = document.createElement("div");
  div.appendChild(idCodeTag).appendChild(pwdTag).appendChild(codeTag);
  div.style =
    "z-index: 999999;position: absolute;left: 100px;top: 150px;min-height: 20px;min-width: 40px;color: white;background:#33ff66";
  document.querySelector("body > div.body").appendChild(div);
  // Your code here...
})();
// ==UserScript==
// @name         挤爆自考
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://zk.sceea.cn/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=sceea.cn
// @grant        none
// ==/UserScript==

(function () {
  "use strict";
  function customLogin() {
                        var name = $("#txtName").val();
                        var pwd = $("#txtPwd").val();
                        var code = $("#txtCode").val();
                        if (name.length < 6) {
                            setErrMsg("身份证件位数不正确!");
                            return
                        }
                        if (pwd.length == 0) {
                            setErrMsg("密码不能为空!");
                            return
                        }
                        if (yzm == 1 && code.length == 0) {
                            setErrMsg("验证码不能为空!");
                            return
                        }
                        $.ajax({
                            url: "/RegExam/elogin?resourceId=login",
                            dataType: "json",
                            cache: false,
                            async: true,
                            type: "POST",
                            data: {
                                name: name,
                                code: code,
                                pwd: pwd
                            },
                            beforeSend: function() {
                                // showLoading();
                                // $("#btn_login").attr("disabled", "disabled")
                            },
                            complete: function() {
                                // setTimeout(function() {
                                //     $("#btnLogin").removeAttr("disabled")
                                // }, 3000)
                            },
                            success: function(data) {
                                if (data == 1) {
                                    window.location.replace("/RegExam/switchPage?resourceId=view")
                                } else {

                                }
                            }
                        })
                    }
  login = ()=>setInterval(customLogin, 300)

  // Your code here...
})();