常工院校园网
// ==UserScript==
// @name 常工院校园网
// @version 1.0
// @description 【校园网自动登录】
// @author 林林林
// @match *://172.19.0.1/*
// ==/UserScript==
(function() {
'use strict';
// 用户信息
var userInfo = {
username: '你的用户名', // 替换为你的用户名
password: '你的密码', // 替换为你的密码
isp: 2 // 1: 校园网, 2: 中国移动, 3: 中国电信, 4: 中国联通
};
// 延迟执行,确保页面加载完成
setTimeout(connect, 100);
// 自动填充账号密码并提交
function connect() {
var account = document.querySelector('.edit_row input[name=DDDDD]');
var password = document.querySelector('.edit_row input[name=upass]');
var ispSelect = document.querySelector('.edit_lobo_cell.edit_select[name=ISP_select]'); // 运营商选择框
var loginButton = document.querySelector('input.edit_lobo_cell[type=button][name="0MKKey"]'); // 登录按钮
if (account && password && ispSelect && loginButton) {
account.value = userInfo.username; // 填充账号
password.value = userInfo.password; // 填充密码
// 根据用户选择的运营商设置选项
var ispValue = '';
switch (userInfo.isp) {
case 1:
ispValue = ''; // 校园网
break;
case 2:
ispValue = '@cmcc'; // 中国移动
break;
case 3:
ispValue = '@telecom'; // 中国电信
break;
case 4:
ispValue = '@unicom'; // 中国联通
break;
default:
console.error('无效的运营商选择');
return;
}
// 选择对应的运营商
for (var i = 0; i < ispSelect.options.length; i++) {
if (ispSelect.options[i].value === ispValue) {
ispSelect.selectedIndex = i;
break;
}
}
// 添加延时,确保页面元素完全加载后再点击登录按钮
setTimeout(function() {
loginButton.click();
}, 500); // 延时500毫秒
} else {
console.error('未找到账号、密码、运营商选择框或登录按钮');
}
}
})();