MCPcopy Create free account
hub / github.com/dajie111/nodeseek-userscript / performSignIn

Method performSignIn

Clockin.js:165–204  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

163
164 // 执行签到API
165 async performSignIn() {
166 // 检查是否开启了自动签到
167 if (localStorage.getItem(STORAGE_KEYS.signEnabled) !== 'true') {
168 // this.addLog('自动签到已关闭,跳过执行');
169 return;
170 }
171
172 try {
173 // 记录当前小时已签到
174 const now = new Date();
175 localStorage.setItem(STORAGE_KEYS.hourlySignTime, now.getTime().toString());
176
177 // 获取当前签到模式
178 const mode = localStorage.getItem(STORAGE_KEYS.signMode) || 'fixed';
179 const api = APIS[mode] || APIS.fixed;
180
181 // this.addLog(`开始执行自动签到 (模式: ${mode === 'fixed' ? '固定' : '随机'})...`);
182
183 const response = await fetch(api, {
184 method: 'POST',
185 headers: {
186 'Content-Type': 'application/json',
187 'X-Requested-With': 'XMLHttpRequest'
188 }
189 });
190
191 // 只在签到成功时输出日志
192 if (response.ok) {
193 const result = await response.json();
194 const modeText = mode === 'fixed' ? '固定' : '随机';
195 this.addLog(`✅ 自动签到成功(${modeText})!${result.message || 'OK'}`);
196 } else {
197 // this.addLog(`❌ 自动签到失败: ${response.status}`);
198 }
199
200 } catch (error) {
201 // 签到异常时静默处理,但如果有日志函数则记录
202 // this.addLog(`❌ 签到出错: ${error.message}`);
203 }
204 }
205
206 // 设置签到模式
207 setSignMode(mode) {

Callers 1

Calls 1

addLogMethod · 0.95

Tested by

no test coverage detected