11// ==UserScript==
22// @name 天使动漫自动签到打工
33// @namespace https://github.com/jc3213/userscript
4- // @version 1.5.0
4+ // @version 1.5.1
55// @description 天使动漫全自动打工签到脚本 — 完全自动无需任何操作,只需静待一分钟左右
66// @author jc3213
77// @match *://www.tsdm39.com/*
@@ -42,7 +42,7 @@ function delay(ms) {
4242}
4343
4444function autoSign ( ) {
45- startWorking ( 'sign ' , 'dsu_paulsign:sign' , '签到 ', 80 , async ( document , window ) => {
45+ startWorking ( '签到 ' , 'dsu_paulsign:sign' , 80 , async ( document , window ) => {
4646 let error = document . querySelector ( '#ct_shell > div:nth-child(1) > h1:nth-child(1)' ) ;
4747 if ( error ) {
4848 return error . textContent ;
@@ -55,7 +55,7 @@ function autoSign() {
5555}
5656
5757function autoWork ( ) {
58- startWorking ( 'work ' , 'np_cliworkdz:work' , '打工 ', 120 , async ( document , window ) => {
58+ startWorking ( '打工 ' , 'np_cliworkdz:work' , 120 , async ( document , window ) => {
5959 let error = document . querySelector ( '#messagetext > p:first-of-type' ) ?. childNodes ?. [ 2 ] ;
6060 if ( error ) {
6161 let [ full , hh , mm , ss ] = error . textContent . match ( / ( \d ) 小 时 ( \d + ) 分 钟 ( \d + ) 秒 / ) ;
@@ -76,9 +76,9 @@ function autoWork() {
7676 } ) ;
7777}
7878
79- function startWorking ( type , id , work , top , callback ) {
80- if ( action [ type ] ) return ;
81- action [ type ] = true ;
79+ function startWorking ( work , id , top , callback ) {
80+ if ( action [ work ] ) return ;
81+ action [ work ] = true ;
8282 let popup = document . createElement ( 'div' ) ;
8383 let iframe = document . createElement ( 'iframe' ) ;
8484 document . body . append ( iframe , popup ) ;
@@ -89,10 +89,11 @@ function startWorking(type, id, work, top, callback) {
8989 iframe . addEventListener ( 'load' , async ( evnet ) => {
9090 popup . textContent = `开始${ work } ...` ;
9191 let { contentDocument, contentWindow } = iframe ;
92- contentWindow . setTimeout = ( ) => null ;
93- popup . textContent = await callback ( contentDocument , contentWindow ) ?? `已完成${ work } ` ;
92+ contentWindow . setTimeout = ( ) => { } ;
93+ let result = await callback ( contentDocument , contentWindow ) ;
94+ popup . textContent = result ?? `已完成${ work } ` ;
9495 setTimeout ( ( ) => {
95- delete action [ type ] ;
96+ delete action [ work ] ;
9697 iframe . remove ( ) ;
9798 popup . remove ( ) ;
9899 iframe = popup = null ;
0 commit comments