(qiandao, timeNow)
| 232 | |
| 233 | // 后台签到 |
| 234 | function qianDao_(qiandao, timeNow) { |
| 235 | let url = (location.origin + "/mission/daily/redeem?" + RegExp("once\\=(\\d+)").exec(document.querySelector('div#Top .tools, #menu-body').innerHTML)[0]); |
| 236 | GM_xmlhttpRequest({ |
| 237 | url: url, |
| 238 | method: 'GET', |
| 239 | timeout: 5000, |
| 240 | onload: function (response) { |
| 241 | let html = ShowPager.createDocumentByString(response.responseText); |
| 242 | //console.log(html) |
| 243 | if (html.querySelector('li.fa.fa-ok-sign')) { |
| 244 | html = html.getElementById('Main').textContent.match(/已连续登录 (\d+?) 天/)[0]; |
| 245 | GM_setValue('menu_clockInTime', timeNow); // 写入签到时间以供后续比较 |
| 246 | console.info('[V2EX 增强] 自动签到完成!') |
| 247 | if (qiandao) { |
| 248 | qiandao.textContent = `自动签到完成!${html}`; |
| 249 | qiandao.href = 'javascript:void(0);'; |
| 250 | } |
| 251 | } else { |
| 252 | GM_notification({text: '自动签到失败!请访问 V2EX 首页试试。\n如果连续几天都签到失败,请联系作者解决!', timeout: 4000, onclick() {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});window.GM_openInTab('https://greasyfork.org/zh-CN/scripts/424246/feedback', {active: true,insert: true,setParent: true});}}); |
| 253 | console.warn('[V2EX 增强] 自动签到失败!请访问 V2EX 首页试试。如果连续几天都签到失败,请联系作者解决!') |
| 254 | if (qiandao) qiandao.textContent = '自动签到失败!请尝试手动签到!'; |
| 255 | } |
| 256 | } |
| 257 | }); |
| 258 | } |
| 259 | |
| 260 | |
| 261 | // 后台获取签到状态(并判断是否需要签到) |
no outgoing calls
no test coverage detected