@@ -36,47 +36,42 @@ e_sign.addEventListener('click', event => {
3636 autoSign ( ) ;
3737} ) ;
3838
39- async function autoSign ( ) {
40- startWorking ( 'sign' , 'dsu_paulsign:sign' , '签到' , 80 , ( document , window ) => {
39+ function delay ( ms ) {
40+ return new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
41+ }
42+
43+ function autoSign ( ) {
44+ startWorking ( 'sign' , 'dsu_paulsign:sign' , '签到' , 80 , async ( document , window ) => {
4145 let error = document . querySelector ( '#ct_shell > div:nth-child(1) > h1:nth-child(1)' ) ;
4246 if ( error ) {
43- return Promise . resolve ( error . textContent ) ;
47+ return error . textContent ;
4448 }
45- return new Promise ( ( resolve ) => {
46- window . Icon_selected ( 'kx' ) ;
47- document . getElementById ( 'todaysay' ) . value = '每日签到' ;
48- setTimeout ( ( ) => {
49- resolve ( ) ;
50- window . showWindow ( 'qwindow' , 'qiandao' , 'post' , '0' ) ;
51- } , 3000 ) ;
52- } ) ;
49+ window . Icon_selected ( 'kx' ) ;
50+ document . getElementById ( 'todaysay' ) . value = '每日签到' ;
51+ await delay ( 3000 ) ;
52+ window . showWindow ( 'qwindow' , 'qiandao' , 'post' , '0' ) ;
5353 } ) ;
5454}
5555
56- async function autoWork ( ) {
57- startWorking ( 'work' , 'np_cliworkdz:work' , '打工' , 120 , ( document , window ) => {
56+ function autoWork ( ) {
57+ startWorking ( 'work' , 'np_cliworkdz:work' , '打工' , 120 , async ( document , window ) => {
5858 let error = document . querySelector ( '#messagetext > p:first-of-type' ) ?. childNodes ?. [ 2 ] ;
5959 if ( error ) {
6060 let [ full , hh , mm , ss ] = error . textContent . match ( / ( \d ) 小 时 ( \d + ) 分 钟 ( \d + ) 秒 / ) ;
6161 let next = hh * 3600000 + mm * 60000 + ss * 1000 ;
6262 setTimeout ( autoWork , next ) ;
63- return Promise . resolve ( error . textContent ) ;
63+ return error . textContent ;
6464 }
6565 let index = 0 ;
66- return new Promise ( ( resolve ) => {
67- for ( let a of document . querySelectorAll ( '#advids > div > a' ) ) {
68- setTimeout ( ( ) => {
69- a . removeAttribute ( 'href' ) ;
70- a . removeAttribute ( 'target' ) ;
71- a . click ( ) ;
72- } , index ++ * 300 ) ;
73- }
74- setTimeout ( ( ) => {
75- resolve ( ) ;
76- document . querySelector ( '#stopad > a' ) . click ( ) ;
77- setTimeout ( autoWork , 21600000 ) ;
78- } , 3000 ) ;
79- } ) ;
66+ for ( let a of document . querySelectorAll ( '#advids > div > a' ) ) {
67+ a . removeAttribute ( 'href' ) ;
68+ a . removeAttribute ( 'target' ) ;
69+ a . click ( ) ;
70+ await delay ( 300 ) ;
71+ }
72+ await delay ( 3000 ) ;
73+ document . querySelector ( '#stopad > a' ) . click ( ) ;
74+ setTimeout ( autoWork , 21600000 ) ;
8075 } ) ;
8176}
8277
0 commit comments