校园网自动打开认证页面(南昌航空大学)

检测到校园网后自动打开认证页面,让 Chrome 处理自动填充登录(不可用)

  1. // ==UserScript==
  2. // @name 校园网自动打开认证页面(南昌航空大学)
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description 检测到校园网后自动打开认证页面,让 Chrome 处理自动填充登录(不可用)
  6. // @match *://*/*
  7. // @grant GM_xmlhttpRequest
  8. // @run-at document-start
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. const loginPageURL = "http://10.1.88.4"; // 你的校园网认证页面地址
  16. const checkURL = "http://10.1.88.4/cgi-bin/rad_user_info"; // 用于检测是否已登录(不可用)
  17.  
  18. // 发送请求检查是否已登录(不可用)
  19. function checkLoginStatus() {
  20. GM_xmlhttpRequest({
  21. method: "GET",
  22. url: checkURL,
  23. timeout: 3000, // 3秒超时
  24. onload: function(response) {
  25. if (!response.responseText.includes("username")) {
  26. console.log("未登录(不可用),打开认证页面...");
  27. window.open(loginPageURL, "_blank");
  28. } else {
  29. console.log("已登录(不可用),无需操作。");
  30. }
  31. },
  32. onerror: function() {
  33. console.log("无法连接校园网,可能未连接 WiFi");
  34. }
  35. });
  36. }
  37.  
  38. // 每隔 30 秒检测一次
  39. setInterval(checkLoginStatus, 30000);
  40.  
  41. // 初次运行时立即检测
  42. checkLoginStatus();
  43. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址