11// ==UserScript==
22// @name Login Override
3- // @version 0.3.1
3+ // @version 0.4.0
44// @description Overrides the login function on a given website
55// @match http://pass.sdu.edu.cn/cas/login*
66// @match https://pass.sdu.edu.cn/cas/login*
@@ -20,24 +20,26 @@ const YOUR_CUSTOM_DEVICE_FINGERPRINT = "SOMETHING_UNIQUE";
2020
2121( function ( ) {
2222 "use strict" ;
23- if ( location . protocol === 'http:' ) {
24- location . href = 'https:' + window . location . href . substring ( window . location . protocol . length ) ;
23+ if ( location . protocol === "http:" ) {
24+ location . href =
25+ "https:" +
26+ window . location . href . substring ( window . location . protocol . length ) ;
2527 } // Redirect to HTTPS if not already
26- if ( location . href . startsWith ( 'https://pass-sdu-edu-cn.atrust.sdu.edu.cn:81/' ) ) {
27- location . href = location . href . replace ( 'https://pass-sdu-edu-cn.atrust.sdu.edu.cn:81/' , 'https://pass-sdu-edu-cn-s.atrust.sdu.edu.cn:81/' )
28+ if (
29+ location . href . startsWith ( "https://pass-sdu-edu-cn.atrust.sdu.edu.cn:81/" )
30+ ) {
31+ location . href = location . href . replace (
32+ "https://pass-sdu-edu-cn.atrust.sdu.edu.cn:81/" ,
33+ "https://pass-sdu-edu-cn-s.atrust.sdu.edu.cn:81/" ,
34+ ) ;
2835 }
29- if ( location . href . startsWith ( 'https://webvpn.sdu.edu.cn/http/' ) ) {
30- location . href = location . href . replace ( 'https://webvpn.sdu.edu.cn/http/' , 'https://webvpn.sdu.edu.cn/https/' )
31- }
32- // Function to hash a string using SHA-256
33- function hashString ( str ) {
34- const encoder = new TextEncoder ( ) ;
35- const data = encoder . encode ( str ) ;
36- const hashBuffer = crypto . subtle . digest ( 'SHA-256' , data ) ;
37- const hashArray = Array . from ( new Uint8Array ( hashBuffer ) ) ;
38- const hashHex = hashArray . map ( b => b . toString ( 16 ) . padStart ( 2 , '0' ) ) . join ( '' ) ;
39- return hashHex ;
36+ if ( location . href . startsWith ( "https://webvpn.sdu.edu.cn/http/" ) ) {
37+ location . href = location . href . replace (
38+ "https://webvpn.sdu.edu.cn/http/" ,
39+ "https://webvpn.sdu.edu.cn/https/" ,
40+ ) ;
4041 }
42+
4143 // Override the login function
4244 function login ( ) {
4345 var $u = $ ( "#un" ) ,
@@ -67,15 +69,18 @@ const YOUR_CUSTOM_DEVICE_FINGERPRINT = "SOMETHING_UNIQUE";
6769 $ ( "#pl" ) . val ( p . length ) ;
6870 $ ( "#rsa" ) . val ( strEnc ( u + p + lt , "1" , "2" , "3" ) ) ;
6971 var details_s = YOUR_CUSTOM_DEVICE_FINGERPRINT ;
70- var murmur = YOUR_CUSTOM_DEVICE_FINGERPRINT ;
71- var murmur_s = hashString ( details_s ) ;
72+ var details_browser_s = YOUR_CUSTOM_DEVICE_FINGERPRINT ;
73+ var murmur_s = hex_md5 ( details_s ) ;
7274 var murmur_md5 = hex_md5 ( details_s ) ;
75+ var browser_md5 = hex_md5 ( details_browser_s ) ;
7376 $ . post (
7477 "device" ,
7578 {
7679 d : murmur ,
7780 d_s : murmur_s ,
78- d_md5 : murmur_md5 ,
81+ d_md5 : strEnc ( murmur_md5 , "1" , "2" , "3" ) ,
82+ d_browser_md5 : strEnc ( browser_md5 , "1" , "2" , "3" ) ,
83+ i : strEnc ( details_s , "1" , "2" , "3" ) ,
7984 m : "1" ,
8085 u : strEnc ( u , "1" , "2" , "3" ) ,
8186 p : strEnc ( p , "1" , "2" , "3" ) ,
@@ -84,23 +89,26 @@ const YOUR_CUSTOM_DEVICE_FINGERPRINT = "SOMETHING_UNIQUE";
8489 if ( ret . info == "validErr" || ret . info == "notFound" ) {
8590 location . reload ( ) ;
8691 } else if ( ret . info == "bind" ) {
87- //二次验证 绑定设备
92+ // 二次验证 绑定设备
8893 $ ( "#phone" ) . val ( ret . m ) ;
89- phone ( murmur_s , details_s ) ;
94+ if ( typeof phone === "function" ) {
95+ phone ( murmur_s , details_s ) ;
96+ }
9097 } else if ( ret . info == "mobileErr" ) {
91- //手机有误
98+ // 手机有误
9299 $ ( "#errormsg2" ) . show ( ) . text ( "尚未绑定手机" ) ;
93100 } else if ( ret . info == "binded" || ret . info == "pass" ) {
94- //直接提交
101+ // 直接提交
95102 $ ( "#loginForm" ) [ 0 ] . submit ( ) ;
96103 }
97104 } ,
98- "json"
105+ "json" ,
99106 ) . error ( function ( xhr , status , info ) {
100- if ( is_weixin ( ) ) {
107+ if ( typeof is_weixin === "function" && is_weixin ( ) ) {
101108 }
102109 } ) ;
103110 }
111+
104112 // Override the original login function with the modified one
105113 window . login = login ;
106114} ) ( ) ;
0 commit comments