Greasy Fork is available in English.
网上学院函数库:自动登录
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/395952/769958/wsxy_autoLogin.js
// ==UserScript==
// @name wsxy_autoLogin
// @namespace Vionlentmonkey
// @version 0.1
// @description 网上学院函数库:自动登录
// @grant GM_getValue
// ==/UserScript==
// 在原函数的基础上,去掉验证码识别,去除 isBlank 函数依赖
const check = () => {
if (document.getElementById('loginName').value === '') {
alert('请输入用户名');
document.getElementById('loginName').focus();
return;
}
if (document.getElementById('pwd').value === '') {
alert('请输入密码');
document.getElementById('pwd').focus();
return;
}
document.getElementById('form1').submit();
};
const autoLogin = () => {
// 重新绑定点击事件
document.getElementById('Submit').onclick = check;
// 移除验证码并提示
document.getElementById('verifyCode').remove();
document.getElementById('imgCode').value = '已去除验证码可直接登录';
// 以下尝试自动登录
document.getElementById('loginName').value = GM_config.get('loginName'); // 写入预先设置的用户名
document.getElementById('pwd').value = GM_config.get('pwd'); // 写入预先设置的密码
// 自动获取用户名密码输入框焦点
if (document.getElementById('loginName').value === '') {
document.getElementById('loginName').focus();
} else if (document.getElementById('pwd').value === '') {
document.getElementById('pwd').focus();
} else {
// 用户名密码均已填写时才自动登录
document.getElementById('Submit').click();
}
};