深澜校园网自动登陆脚本

因为晚上要断电,所以写了个油猴脚本,自动登录深澜校园网

深澜校园网 - 自动登陆

原理:输入自己的账号、密码后,让浏览器填写自己设置的密码,模拟用户点击登录按钮

油猴脚本插件 - 下载地址

篡改猴 - Chrome 应用商店

篡改猴 - Microsoft Edge Addons

操作步骤

在浏览器右上角找到篡改猴扩展

选择添加新脚本的选项

代码复制到此处, ctrl+s 保存即可,打开校园网登录地址,实现自动登录。

将下面的脚本代码粘贴到编辑区域

粘贴油猴脚本

自动登录脚本:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// ==UserScript==
// @name 深澜校园网-自动登陆
// @namespace http://www.baidu.com/
// @version 0.12
// @description 仅仅提供【深澜校园网】的保存密码及自动登陆,第7行为校园网登录 IP。
// @author Skyforever
// @match http://218.104.96.75/*
// @icon https://srun.com/favicon.ico
// @icon64 https://srun.com/favicon.ico
// @grant none
// ==/UserScript==
(function() {
'use strict';

// 用户自定义 - 输入账号密码
var usr = "这里填账号"; // 账号
var pwd = "这里填密码"; // 密码

// 检查账号密码是否已填写
if (usr === "这里填账号" || pwd === "这里填密码") {
alert("请去用户脚本管理器中,找到【深澜校园网-自动登录】脚本的代码,添加自己的账号与密码");
} else {
// 填充账号和密码
document.querySelector("#username").value = usr;
document.querySelector("#password").value = pwd;

// 点击登录按钮
document.querySelector("#login-account").click();
}
})();

自动切换账号登录(不建议这么做,会打破付费平衡)
程序原理:在默认账号无法登录时,自动对账号+1,并重新尝试登录,如果登录成功,就把账号存在本地数据库中,方便下次登录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// ==UserScript==
// @name 深澜校园网-自动登陆
// @namespace http://www.baidu.com/
// @version 0.22
// @description 仅仅提供【深澜校园网】的保存密码及自动登陆,第7行为校园网登录 IP。
// @author Skyforever
// @match http://218.104.96.75/*
// @icon https://srun.com/favicon.ico
// @icon64 https://srun.com/favicon.ico
// @grant none
// ==/UserScript==
(function() {
'use strict';

// 默认账号(初始账号),以及密码(密码不变)
var defaultUsr = "02702127512"; // 默认账号
var pwd = "123456"; // 密码

// localStorage 键名
var storageKey = "autoLogin_currentAccount";
// 从 localStorage 获取当前账号,若没有则使用默认账号
var currentUsr = localStorage.getItem(storageKey) || defaultUsr;

// 更新当前账号到 localStorage,并更新控制面板显示
function updateCurrentUsr(newUsr) {
localStorage.setItem(storageKey, newUsr);
currentUsr = newUsr;
console.log("更新当前账号为:" + newUsr);
updateControlPanel();
}

// 判断元素是否真的可见:检测 offsetWidth/offsetHeight 和 CSS 样式
function isVisible(element) {
if (!element) return false;
var style = window.getComputedStyle(element);
return style.display !== "none" &&
style.visibility !== "hidden" &&
element.offsetWidth > 0 &&
element.offsetHeight > 0;
}

// 登录后检测确认按钮的函数(如果检测到则执行账号自增并重新登录)
function checkForConfirmButtonPostLogin() {
var confirmBtn = document.querySelector(".btn-confirm");
if (confirmBtn && isVisible(confirmBtn)) {
console.log("✅ 登录后检测到确认按钮,准备重新尝试登录...");
// 点击确认按钮(如果需要)
confirmBtn.click();
// 自增账号:转换为数字后加 1,再转回字符串
var newAccountNum = parseInt(currentUsr, 10) + 1;
updateCurrentUsr(newAccountNum.toString());
// 1秒后刷新页面以重新尝试登录
setTimeout(function() {
location.reload();
}, 1000);
return true;
}
return false;
}

// 登录后启动定时检测确认按钮,连续检测一定时间(如 10 次,每次间隔 1 秒)
function startPostLoginConfirmCheck() {
var attempts = 0;
var maxAttempts = 10;
var intervalId = setInterval(function() {
attempts++;
if (checkForConfirmButtonPostLogin() || attempts >= maxAttempts) {
clearInterval(intervalId);
}
}, 1000);
}

// 自动填充账号密码并点击登录按钮
function autoLogin() {
var usernameField = document.querySelector("#username");
var passwordField = document.querySelector("#password");
var loginBtn = document.querySelector("#login-account");

if (usernameField && passwordField && loginBtn) {
usernameField.value = currentUsr;
passwordField.value = pwd;
console.log("✅ 使用账号 " + currentUsr + " 已填充账号密码,尝试登录...");
setTimeout(function() {
loginBtn.click();
// 登录后启动确认按钮检测(用于后续页面出现的确认按钮)
startPostLoginConfirmCheck();
}, 500);
} else {
console.log("❌ 未找到登录表单,等待加载...");
setTimeout(autoLogin, 1000);
}
}

// 处理初始页面上可能出现的确认按钮(登录前或中途出现的)
function handleInitialConfirmButton() {
var confirmBtn = document.querySelector(".btn-confirm");
if (confirmBtn && isVisible(confirmBtn)) {
console.log("✅ 检测到初始确认按钮,点击确认...");
confirmBtn.click();
// 检测按钮是否消失后刷新页面
var checkInterval = setInterval(function() {
if (!isVisible(confirmBtn)) {
clearInterval(checkInterval);
console.log("🔄 初始确认按钮已消失,刷新页面...");
setTimeout(function() {
location.reload();
}, 1000);
}
}, 500);
} else {
console.log("❌ 初始页面未检测到确认按钮,直接尝试登录...");
setTimeout(autoLogin, 1000);
}
}

// 创建右上角控制面板,用于显示当前账号和重置账号按钮
function createControlPanel() {
var panel = document.createElement("div");
panel.id = "autoLoginControlPanel";
panel.style.position = "fixed";
panel.style.top = "10px";
panel.style.right = "10px";
panel.style.background = "rgba(0, 0, 0, 0.7)";
panel.style.color = "#fff";
panel.style.padding = "8px";
panel.style.fontSize = "14px";
panel.style.zIndex = "9999";
panel.style.borderRadius = "4px";

// 当前账号显示区域
var accountInfo = document.createElement("span");
accountInfo.id = "currentAccountDisplay";
accountInfo.style.marginRight = "10px";
panel.appendChild(accountInfo);

// 重置账号按钮
var resetBtn = document.createElement("button");
resetBtn.textContent = "重置账号";
resetBtn.style.fontSize = "12px";
resetBtn.style.cursor = "pointer";
resetBtn.addEventListener("click", function() {
updateCurrentUsr(defaultUsr);
alert("账号已重置为:" + defaultUsr);
});
panel.appendChild(resetBtn);

document.body.appendChild(panel);
updateControlPanel();
}

// 更新控制面板中显示的当前账号
function updateControlPanel() {
var accountInfo = document.getElementById("currentAccountDisplay");
if (accountInfo) {
accountInfo.textContent = "当前账号:" + currentUsr;
}
}

// 脚本启动入口
function init() {
console.log("🚀 脚本启动... 当前账号:" + currentUsr);
createControlPanel();
setTimeout(handleInitialConfirmButton, 2000);
}

init();

})();

附加内容-绕过代理

将学校网关的代理设置为直连,不走代理,这样系统就可以自动弹出登录界面登录
Windows系统设置在这个位置:

win系统设置

Clash设置在这个位置:
Clash设置

附加内容-修改浏览器标识

修改浏览器标识,可以加大概率碰到能用的账号
因为大部分用户都是用电脑登录的,而一个账号可以用于两个设备(手机和电脑);
所以可以修改浏览器标识,让浏览器 pretend 成手机登录,这样能试到更多账号

浏览器标识修改插件 - 下载地址

User-Agent Switcher and Manager - Chrome 应用商店

User-Agent Switcher and Manage - Edge 应用商店

未应用插件的浏览器标识是,识别为电脑:
识别为电脑

按照下面图片的步骤操作即可模拟手机标识骗过:
选择对应的选项

应用后,识别为手机:
识别为手机