From 2d0d75de0fa37ae3ba2bc902c6f580eda6ee0d26 Mon Sep 17 00:00:00 2001 From: ngfchl Date: Thu, 26 Jan 2023 19:02:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E8=8E=B7=E5=8F=96UI?= =?UTF-8?q?D=E9=94=99=E8=AF=AF=E7=9A=84bug=20=E8=B0=83=E6=95=B4=EF=BC=9A?= =?UTF-8?q?=E6=B2=B9=E7=8C=B4=E5=90=AF=E5=8A=A8=E6=96=B9=E5=BC=8F=E4=B8=BA?= =?UTF-8?q?=E5=8F=B3=E9=94=AE=E8=8F=9C=E5=8D=95=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PtToPtools.js | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/PtToPtools.js b/PtToPtools.js index 5e25141..5da2b52 100644 --- a/PtToPtools.js +++ b/PtToPtools.js @@ -57,6 +57,8 @@ // @match https://zmpt.cc/* // @match https://leaves.red/* // @match https://piggo.me/* + +// @run-at context-menu // @version 0.0.2 // @grant GM_xmlhttpRequest // @grant none @@ -66,6 +68,7 @@ /* 日志: + 2023.01.26 修复bug,调整为右键菜单启动 2023.01.26 更新逻辑,一小时内不会重复更新 2023.01.25 完成第一版0.0.1 2023.01.24 开始编写第一版脚本 @@ -84,7 +87,8 @@ var path = "tasks/monkey_to_ptools"; (function () { 'use strict'; main().then(res => { - alert('PTools提醒您,你的Cookie已更新!') + console.log(res) + alert('PTools提醒您:' + res.msg) }); })(); @@ -97,8 +101,8 @@ async function getSite() { }).then(res => { // console.log(data); if (res.code !== 0) { - console.error(res.msg) - return + console.log(res.msg) + return false } console.log('站点信息获取成功!', res.data) return res.data @@ -107,15 +111,19 @@ async function getSite() { async function getData() { var site_info = await getSite() - console.log(site_info) + if (site_info == false) return; + console.log(site_info.uid_xpath) //获取cookie与useragent let user_agent = window.navigator.userAgent let cookie = document.cookie + //获取UID let re = /\d+/; - let href = document.evaluate(site_info.uid_xpath, document).iterateNext() - let user_id = re.exec(href)[0] + let href = document.evaluate(site_info.uid_xpath, document).iterateNext().textContent + console.log(href) + let user_id = href.match(re) + console.log(user_id) return { - user_id: user_id, + user_id: user_id[0], site_id: site_info.site_id, cookie: cookie, token: token, @@ -125,12 +133,13 @@ async function getData() { async function main() { var data = await getData(); - if (data == false) return; - console.log(data) - let res = await ajax_post(data).then(res => { - alert('PTools提醒您:' + res.msg) - console.log(res) - }) + if (data == false) { + return; + } else { + return await ajax_post(data).then(res => { + return res + }) + } }