Auto login

绕过中科大统一身份认证的验证码并自动聚焦至登录按钮

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Auto login
// @namespace    http://tampermonkey.net/
// @version      0.2
// @license      gpl-3.0
// @description  绕过中科大统一身份认证的验证码并自动聚焦至登录按钮
// @author       PRO
// @match        https://passport.ustc.edu.cn/*
// @icon         https://passport.ustc.edu.cn/images/favicon.ico
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    let form = document.getElementsByClassName('loginForm')[0]; // 登录表格
    let options = { // observer 观察选项
        childList: true, // 观察目标子节点的变化,添加或删除
        attributes: false, // 观察属性变动
        subtree: true // 默认是false,设置为true后可观察后代节点
    }
    function bypass() { // 绕过验证码
        // 将 showCode 设置为空以绕过服务器的验证码校验
        let showCode = document.getElementsByName('showCode')[0];
        showCode.value = "";
        // 移除验证码元素
        let code = document.querySelector('#valiCode');
        code.remove();
    }
    function focus() { // 将焦点移至登录按钮,以便直接按下回车登录
        var button = document.getElementById('login');
        button.focus();
    }
    function main() { // 主函数
        bypass();
        focus();
        observer.disconnect(); // observer 停止观测
    }
    let observer = new MutationObserver(main); // 实例化 observer
    observer.observe(form, options); // 开始观测
})();