您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
为 USTC 学生定制的各类实用功能。
当前为
// ==UserScript== // @name USTC Helper // @name:zh-CN USTC 助手 // @license unlicense // @namespace http://tampermonkey.net/ // @version 0.2 // @description Various useful functions for USTC students. // @description:zh-CN 为 USTC 学生定制的各类实用功能。 // @author PRO // @match https://mail.ustc.edu.cn/ // @match https://mail.ustc.edu.cn/coremail/index.jsp* // @match https://passport.ustc.edu.cn/* // @match https://rec.ustc.edu.cn/* // @match https://recapi.ustc.edu.cn/identity/other_login?* // @match https://www.bb.ustc.edu.cn/* // @icon https://passport.ustc.edu.cn/images/favicon.ico // @grant none // ==/UserScript== (function () { 'use strict'; var uhp_config = { passport: { enabled: true, // If false, all features will be disabled for passport.ustc.edu.cn bypass_code: true, // Whether to bypass verification code or not focus: true // Whether to focus on "Login" button }, mail: { enabled: true, // If false, all features will be disabled for mail.ustc.edu.cn focus: true, // Whether to focus on "Login" button domain: 'mail.ustc.edu.cn' // Automatically switch to given mail domain // Expected values: // 'mail.ustc.edu.cn' // 'ustc.edu.cn' // 'ah.edu.cn' // '' (Do nothing) }, rec: { enabled: true, // If false, all features will be disabled for rec.ustc.edu.cn & recapi.ustc.edu.cn autologin: true, // Whether automatically clicks login (USTC cas login) opencurrent: true // Whether open links in current tab }, bb: { enabled: true, // If false, all features will be disabled for www.bb.ustc.edu.cn autoauth: true, // Whether automatically authenticate when accessing outside school net autologin: true // Whether automatically clicks login } }; switch (window.location.host) { case 'mail.ustc.edu.cn': { if (!uhp_config.mail.enabled) { console.info("[USTC Helper] 'mail' feature disabled."); break; } if (uhp_config.mail.domain) { changeDomain(uhp_config.mail.domain); console.info(`[USTC Helper] Domain changed to ${uhp_config.mail.domain}.`); } if (uhp_config.mail.focus) { document.getElementById("login_button").focus(); console.info("[USTC Helper] Login button focused."); } break; } case 'passport.ustc.edu.cn': { if (!uhp_config.passport.enabled) { console.info("[USTC Helper] 'passport' feature disabled."); break; } let form = document.getElementsByClassName('loginForm')[0]; let options = { childList: true, attributes: false, subtree: true } function bypass() { let showCode = document.getElementsByName('showCode')[0]; showCode.value = ""; let code = document.querySelector('#valiCode'); code.remove(); console.info("[USTC Helper] Verification code bypassed."); } function focus() { document.getElementById('login').focus(); console.info("[USTC Helper] Login button focused."); } function main() { if (uhp_config.passport.bypass_code) bypass(); if (uhp_config.passport.focus) focus(); observer.disconnect(); } let observer = new MutationObserver(main); observer.observe(form, options); break; } case 'rec.ustc.edu.cn': { if (!uhp_config.rec.enabled) { console.info("[USTC Helper] 'rec' feature disabled."); break; } if (uhp_config.rec.autologin && document.location.pathname == '/') { let app = document.getElementById("app"); let options = { childList: true, attributes: false, subtree: true } let observer = new MutationObserver(() => { let btn = document.getElementsByClassName('navbar-login-btn')[0]; if (btn) { btn.click(); observer.disconnect(); } }); observer.observe(app, options); } else if (uhp_config.rec.opencurrent) { let app = document.getElementById("app"); let options = { childList: true, attributes: false, subtree: true } let observer = new MutationObserver(() => { let l = document.getElementsByClassName("app-list").length; if (l) { let links = app.getElementsByTagName("a"); for (let link of links) { if (link.target == '_blank') link.removeAttribute("target"); } } }); observer.observe(app, options); } break; } case 'recapi.ustc.edu.cn': { if (!uhp_config.rec.enabled) { console.info("[USTC Helper] 'rec' feature disabled."); break; } if (uhp_config.rec.autologin) { let btn = document.querySelector("#ltwo > div > button"); if (!btn) { console.error("[USTC Helper] Login button not found!"); } else { btn.click(); } } break; } case 'www.bb.ustc.edu.cn': { if (!uhp_config.bb.enabled) { console.info("[USTC Helper] 'bb' feature disabled."); break; } if (window.location.pathname == '/nginx_auth/' && uhp_config.bb.autoauth) { document.getElementsByTagName('a')[0].click(); } else if ((window.location.pathname == '/' || window.location.pathname == '/webapps/login/') && uhp_config.bb.autologin) { document.querySelector('#login > table > tbody > tr > td:nth-child(2) > span > a').click(); } break; } default: console.error("[USTC Helper] Unexpected host: " + window.location.host); break; } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址