NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name 西浦自动登录
// @namespace PairZhu
// @match https://*.xjtlu.edu.cn/*
// @grant none
// @version 2.1
// @author PairZhu
// @run-at document-end
// @description 2023/12/1 19:02:50
// @license MIT
// @downloadURL https://update.greasyfork.org/scripts/484105/%E8%A5%BF%E6%B5%A6%E8%87%AA%E5%8A%A8%E7%99%BB%E5%BD%95.user.js
// @updateURL https://update.greasyfork.org/scripts/484105/%E8%A5%BF%E6%B5%A6%E8%87%AA%E5%8A%A8%E7%99%BB%E5%BD%95.meta.js
// ==/UserScript==
(function () {
'use strict';
const domain = window.location.hostname.split('.')[0];
const pathname = window.location.pathname;
const search = new URLSearchParams(window.location.search);
const $ = str => document.querySelector(str);
const setting = {
username: 'Heizi.Xiao',//西浦账号
password: '1145141919810',//西浦密码
}
const webConfig = {
core: {
path: '/local/login',
action: ()=>$('#local-login-options > div.idp-login.container-fluid.saml2 > a').click()
},
sso: {
path: '/login',
username: '#username_show',
password: '#password_show',
login: '#btn_login input',
error: '#msg'
},
mail: {
path: '/owa/auth/logon.aspx',
username: '#username',
password: '#password',
login: '.signinbutton',
error: '#signInErrorDiv'
},
ebridge: {
path: '/urd/sits.urd/run/siw_lgn',
username: '#MUA_CODE\\.DUMMY\\.MENSYS',
password: '#PASSWORD\\.DUMMY\\.MENSYS',
login: '.sv-btn.sv-btn-block.sv-btn-primary',
error: '.sv-panel.sv-panel-danger.sv-message-box'
},
idp: {
path: '/idp/profile/SAML2/',
action: ()=>{
switch (search.get("execution")) {
case "e1s3":
$('#accept').checked = true;
$('[name="_eventId_proceed"]').click();
break;
case "e1s4":
$('#_shib_idp_globalConsent').click();
$('[name="_eventId_proceed"]').click();
break;
default:
break;
}
}
}
}
const init = () => {
if (!webConfig[domain]) return;
const config = webConfig[domain];
if (!pathname.startsWith(config.path)) return;
if (config.error && $(config.error)) return;
config.preAction && config.preAction();
try {
if (config.action) {
config.action();
} else {
$(config.username).value = setting.username;
$(config.password).value = setting.password;
$(config.login).click();
}
} catch (e) {
config.fail && config.fail();
console.log('自动登录失败', e);
}
config.postAction && config.postAction();
}
init();
})();