求大神帮我看看pttime脚本签到错误问题
// ==UserScript==// @name PT时间每日定时签到【脚本猫专用】
// @version 0.1.0
// @description定时脚本,每日1次,需要先登陆https://www.pttime.org/index.php
// @author shay
// @grant GM_xmlhttpRequest
// @grant GM_notification
// @connect pttime
// @crontab 1-59 * once * *
// ==/UserScript==
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: "GET",
url: "https://www.pttime.org/attendance.php",
onload: xhr => {
console.log(xhr)
try {
resolve(xhr.responseText.match(/dynamicurl\|\/(.+?)\|/))
} catch {
let text = "PT时间定时签到成功(我也不知道为啥就成功了)-重复签到"
GM_notification(text)
reject(text)
}
},
onerror: xhr => {
console.log(xhr)
let text = "PT时间定时签到失败-网络错误或重复签到"
GM_notification(text)
reject(text)
}
})
}).then(url => {
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: "GET",
url: "https://www.pttime.org" + url + "attendance.php",
onload: xhr => {
console.log(xhr)
let text
if (xhr.responseText.includes("任务已完成")) {
text = "PT时间定时签到成功"
GM_notification(text)
resolve(text)
} else if (xhr.responseText.includes("本期您已申请过此任务")) {
text = "PT时间定时签到失败 - 重复签到"
GM_notification(text)
resolve(text)
} else {
text = "PT时间定时签到失败-未知错误-详见调试"
GM_notification(text)
reject(text)
}
},
onerror: xhr => {
console.log(xhr)
let text = "PT时间定时签到失败-网络错误"
GM_notification(text)
reject(text)
}
})
})
})
上面是具体代码,是以前ptt签到的代码,后来不知道怎么就失效了,然后我自己改了改。每天0点开始运行,也不知道为啥就成功了,但失败后不会再次执行。希望大神能帮忙看看,顺便改善一下代码,使得弹出信息能显示签到后,获得了多少魔力值,还有多少魔力值。谢谢 // @crontab 1-59 once *
这表达式不对啊
另外贴代码建议用markdown编辑器的code模式,例如
```js
你的代码
```
这样太乱了 ```js
// ==UserScript==
// @name PT时间每日定时签到【脚本猫专用】
// @version 0.1.0
// @description定时脚本,每日1次,需要先登陆https://www.pttime.org/index.php
// @author shay
// @grant GM_xmlhttpRequest
// @grant GM_notification
// @connect pttime
// @crontab 1-59 * once * *
// ==/UserScript==
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: "GET",
url: "https://www.pttime.org/attendance.php",
onload: xhr => {
console.log(xhr)
try {
resolve(xhr.responseText.match(/dynamicurl\|\/(.+?)\|/))
} catch {
let text = "PT时间定时签到成功(我也不知道为啥就成功了)-重复签到"
GM_notification(text)
reject(text)
}
},
onerror: xhr => {
console.log(xhr)
let text = "PT时间定时签到失败-网络错误或重复签到"
GM_notification(text)
reject(text)
}
})
}).then(url => {
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: "GET",
url: "https://www.pttime.org" + url + "attendance.php",
onload: xhr => {
console.log(xhr)
let text
if (xhr.responseText.includes("任务已完成")) {
text = "PT时间定时签到成功"
GM_notification(text)
resolve(text)
} else if (xhr.responseText.includes("本期您已申请过此任务")) {
text = "PT时间定时签到失败 - 重复签到"
GM_notification(text)
resolve(text)
} else {
text = "PT时间定时签到失败-未知错误-详见调试"
GM_notification(text)
reject(text)
}
},
onerror: xhr => {
console.log(xhr)
let text = "PT时间定时签到失败-网络错误"
GM_notification(text)
reject(text)
}
})
})
})
```
这样吗? https://scriptcat.org/script-show-page/550/code
你抄也别抄错啊…… shayshay 发表于 2023-8-25 15:59
```js
// ==UserScript==
// @name PT时间每日定时签到【脚本猫专用】
使用markdown编辑器,我给你改了 steven026 发表于 2023-8-25 16:55
https://scriptcat.org/script-show-page/550/code
你抄也别抄错啊……
兄弟你的链接我访问不了啊 shayshay 发表于 2023-8-26 02:27
兄弟你的链接我访问不了啊
哥,冷静,哥先别暴怒,哥你先别怪罪任何原因,哥,你先关闭V{}P[]N
页:
[1]