Greasy Fork is available in English.

wsxy_autoLogin

网上学院函数库:自动登录

Ekde 2020/02/02. Vidu La ĝisdata versio.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/395952/769421/wsxy_autoLogin.js

// 在原函数的基础上,去掉验证码识别,去除 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();
  }
};