├── Task ├── 1 ├── qqreadnode.zip ├── README.md ├── qqreadCOOKIE.js ├── sendNotify.js ├── qqreads.js └── qqreadnode.js ├── .github ├── pull.yml └── workflows │ ├── sync-repo.yml │ ├── qienode.yml │ ├── Qieread.yml │ ├── qieread.yml │ └── qieyuedu.yml ├── README.md └── sendNotify.js /Task/1: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Task/qqreadnode.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jone2008/Qieread/HEAD/Task/qqreadnode.zip -------------------------------------------------------------------------------- /Task/README.md: -------------------------------------------------------------------------------- 1 | 1.3更新node为功能完整版,可单任务,可单开宝箱,也可同时运行。 2 | 可直接更换zip包里面的脚本文件即可在云函数运行,可避免action延迟。 3 | 4 | 1.2更新: 5 | zip文件为ziye12编写,填写好cookies(多账号换行)即可直接在腾讯云函数使用,推荐单独开箱,因为时间控制很精准。 6 | 建议时间触发为5分钟一次。每天开箱65+没问题。 7 | -------------------------------------------------------------------------------- /Task/qqreadCOOKIE.js: -------------------------------------------------------------------------------- 1 | //⚠️ck在``里面填写ck,多账号换行 2 | let qqreadbodyVal = ``; 3 | 4 | let qqreadtimeurlVal = ``; 5 | 6 | let qqreadtimeheaderVal = ``; 7 | 8 | 9 | 10 | let qqreadcookie = { 11 | qqreadbodyVal: qqreadbodyVal, 12 | qqreadtimeurlVal: qqreadtimeurlVal, 13 | qqreadtimeheaderVal: qqreadtimeheaderVal 14 | } 15 | 16 | module.exports = qqreadcookie 17 | -------------------------------------------------------------------------------- /.github/pull.yml: -------------------------------------------------------------------------------- 1 | # 使用方法见[@lxk0301](https://raw.githubusercontent.com/lxk0301/scripts/master/githubAction.md) 2 | # 使用方法见[@lxk0301](https://raw.githubusercontent.com/lxk0301/scripts/master/githubAction.md) 3 | 4 | version: "1" 5 | rules: # Array of rules 6 | - base: main # Required. Target branch 7 | upstream: Jone2008/main # Required. Must be in the same fork network. 8 | mergeMethod: hardreset # Optional, one of [none, merge, squash, rebase, hardreset], Default: none. 9 | mergeUnstable: true # Optional, merge pull request even when the mergeable_state is not clean. Default: false 10 | -------------------------------------------------------------------------------- /.github/workflows/sync-repo.yml: -------------------------------------------------------------------------------- 1 | # File: .github/workflows/repo-sync.yml 2 | name: sync-Jone2008-Qieread 3 | on: 4 | schedule: 5 | - cron: '1 */3 * * *' 6 | workflow_dispatch: 7 | watch: 8 | types: started 9 | repository_dispatch: 10 | types: sync-Jone2008-Qieread 11 | jobs: 12 | repo-sync: 13 | env: 14 | PAT: ${{ secrets.PAT }} #此处PAT需要申请,教程详见:https://www.jianshu.com/p/bb82b3ad1d11 15 | dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} # 我自己同步到gitee使用,其他人可忽略 16 | runs-on: ubuntu-latest 17 | if: github.event.repository.owner.id == github.event.sender.id 18 | steps: 19 | - uses: actions/checkout@v2 20 | with: 21 | persist-credentials: false 22 | 23 | - name: sync Jone2008-Qieread 24 | uses: repo-sync/github-sync@v2 25 | if: env.PAT 26 | with: 27 | source_repo: "https://github.com/Jone2008/Qieread.git" 28 | source_branch: "main" 29 | destination_branch: "main" 30 | github_token: ${{ secrets.PAT }} 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Water's github stats

2 | 3 | 1.6 因作者删库停止更新,此库也停更。仅供留以后参考研究学习用。 4 | 5 | 1.5 qqreads.js修复获取cookies问题,qqreadnode修复QQREAD_CASH环境变量问题 6 | 7 | 1.4增加本仓库自动同步功能 只需设置secrets名: PAT 8 | 此处PAT需要申请,教程详见:https://www.jianshu.com/p/bb82b3ad1d11 9 | 10 | 1.3同步更新ziye12脚本,修复cookie失效继续阅读任务,实测也可以Actions运行,不过还是建议云函数运行。 11 | 12 | 12.30同步ziye12更新脚本,请务必添加新Secrets,name为QQREAD_CASH,值:可设置0 1 2 10 30 50 100 ,设置0即为默认不提现 13 | 同时Workflow下的yml文件增加env:QQREAD_CASH: ${{ secrets.QQREAD_CASH }}即可自动提现,不增加默认不提现 14 | 15 | 12.09凌晨经验证均已解决1金币问题 16 | 17 | 12.07同步更新ziye12脚本,解决1金币问题,请务必更新qqreads.js和qqread.yml两个文件,原来三个secrets中的一个QQREAD_HEADER请手动更改成QQREAD_BODY,删除后重新添加,抓取cookie代码已更改必须同步更新获取。三个值重新获取后填写,更新完成后手动运行下即可 18 | 19 | BODY数值点击阅读小程序底下菜单栏“书库”进去读几秒书退出即可获取 20 | 21 | 企鹅阅读跑跑Actions 22 | 23 | 可直接fork仓库,然后设置里面分别添加如下三个secrets,值填写对应软件抓取的数据 24 | 25 | QQREAD_BODY 对应值可直接复制所获取的{ }所有内容(包括大括号),多账号换行 26 | 27 | QQREAD_TIMEURL 对应值直接复制填入,多账号换行 28 | 29 | QQREAD_TIMEHD 对应值可直接复制所获取的{ }所有内容(包括大括号),多账号换行 30 | 31 | 然后常规run 对应yml文件即可,再不行不行的可以star一下。 32 | -------------------------------------------------------------------------------- /.github/workflows/qienode.yml: -------------------------------------------------------------------------------- 1 | name: 好好读书吧 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: '*/5 * * * *' 7 | watch: 8 | types: started 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | if: github.event.repository.owner.id == github.event.sender.id 14 | env: 15 | QQREAD_BODY: ${{ secrets.QQREAD_BODY }} 16 | QQREAD_TIMEURL: ${{ secrets.QQREAD_TIMEURL }} 17 | QQREAD_TIMEHD: ${{ secrets.QQREAD_TIMEHD }} 18 | QQREAD_CASH: ${{ secrets.QQREAD_CASH }} 19 | steps: 20 | - name: Checkout 21 | run: | 22 | git clone https://github.com/ziye12/JavaScript.git ~/JavaScript 23 | - name: Use Node.js 12.x 24 | uses: actions/setup-node@v1 25 | with: 26 | node-version: 12.x 27 | - name: npm install 28 | if: env.QQREAD_TIMEHD 29 | run: | 30 | cd ~/JavaScript 31 | npm install 32 | - name: '运行 【企鹅读书完整版】' 33 | if: env.QQREAD_TIMEHD 34 | run: | 35 | cd ~/JavaScript 36 | node Task/qqreadnode.js 37 | env: 38 | 39 | PUSH_KEY: ${{ secrets.PUSH_KEY }} 40 | BARK_PUSH: ${{ secrets.BARK_PUSH }} 41 | TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }} 42 | TG_USER_ID: ${{ secrets.TG_USER_ID }} 43 | BARK_SOUND: ${{ secrets.BARK_SOUND }} 44 | DD_BOT_TOKEN: ${{ secrets.DD_BOT_TOKEN }} 45 | DD_BOT_SECRET: ${{ secrets.DD_BOT_SECRET }} 46 | -------------------------------------------------------------------------------- /.github/workflows/Qieread.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: 好好读书2 5 | 6 | on: 7 | workflow_dispatch: 8 | schedule: 9 | - cron: '*/5 * * * *' 10 | watch: 11 | types: started 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | if: github.event.repository.owner.id == github.event.sender.id 16 | env: 17 | QQREAD_BODY: ${{ secrets.QQREAD_BODY }} 18 | QQREAD_TIMEURL: ${{ secrets.QQREAD_TIMEURL }} 19 | QQREAD_TIMEHD: ${{ secrets.QQREAD_TIMEHD }} 20 | QQREAD_CASH: ${{ secrets.QQREAD_CASH }} 21 | steps: 22 | - name: Checkout 23 | uses: actions/checkout@v2 24 | - name: Use Node.js 12.x 25 | uses: actions/setup-node@v1 26 | with: 27 | node-version: 12.x 28 | - name: npm install 29 | run: | 30 | npm install 31 | - name: '运行 【企鹅读书2】' 32 | if: env.QQREAD_TIMEHD 33 | run: | 34 | node Task/qqreadnode.js 35 | env: 36 | PUSH_KEY: ${{ secrets.PUSH_KEY }} 37 | BARK_PUSH: ${{ secrets.BARK_PUSH }} 38 | TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }} 39 | TG_USER_ID: ${{ secrets.TG_USER_ID }} 40 | BARK_SOUND: ${{ secrets.BARK_SOUND }} 41 | DD_BOT_TOKEN: ${{ secrets.DD_BOT_TOKEN }} 42 | DD_BOT_SECRET: ${{ secrets.DD_BOT_SECRET }} 43 | -------------------------------------------------------------------------------- /.github/workflows/qieread.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: 听话读书 5 | 6 | on: 7 | workflow_dispatch: 8 | schedule: 9 | - cron: '*/11 * * * *' 10 | watch: 11 | types: started 12 | 13 | jobs: 14 | build: 15 | runs-on: ubuntu-latest 16 | if: github.event.repository.owner.id == github.event.sender.id 17 | env: 18 | QQREAD_BODY: ${{ secrets.QQREAD_BODY }} 19 | QQREAD_TIMEURL: ${{ secrets.QQREAD_TIMEURL }} 20 | QQREAD_TIMEHD: ${{ secrets.QQREAD_TIMEHD }} 21 | QQREAD_CASH: ${{ secrets.QQREAD_CASH }} 22 | steps: 23 | - name: Checkout 24 | run: | 25 | git clone https://github.com/ziye12/JavaScript.git ~/JavaScript 26 | - name: Use Node.js 12.x 27 | uses: actions/setup-node@v1 28 | with: 29 | node-version: 12.x 30 | - name: npm install 31 | if: env.QQREAD_TIMEHD 32 | run: | 33 | cd ~/JavaScript 34 | npm install 35 | - name: '运行 【企鹅读书】' 36 | if: env.QQREAD_TIMEHD 37 | run: | 38 | cd ~/JavaScript 39 | node Task/qqreads.js 40 | env: 41 | 42 | PUSH_KEY: ${{ secrets.PUSH_KEY }} 43 | BARK_PUSH: ${{ secrets.BARK_PUSH }} 44 | TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }} 45 | TG_USER_ID: ${{ secrets.TG_USER_ID }} 46 | BARK_SOUND: ${{ secrets.BARK_SOUND }} 47 | DD_BOT_TOKEN: ${{ secrets.DD_BOT_TOKEN }} 48 | DD_BOT_SECRET: ${{ secrets.DD_BOT_SECRET }} 49 | 50 | 51 | -------------------------------------------------------------------------------- /.github/workflows/qieyuedu.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: 阅读一下 5 | 6 | on: 7 | workflow_dispatch: 8 | schedule: 9 | - cron: '*/5 * * * ?' #action会有延迟 10 | watch: 11 | types: started 12 | repository_dispatch: 13 | types: qqread 14 | jobs: 15 | build: 16 | 17 | runs-on: ubuntu-latest 18 | if: github.event.repository.owner.id == github.event.sender.id 19 | steps: 20 | - name: Checkout 21 | uses: actions/checkout@v2 22 | with: 23 | repository: Jone2008/Qieread 24 | - name: Use Node.js ${{ matrix.node-version }} 25 | uses: actions/setup-node@v1 26 | with: 27 | node-version: ${{ matrix.node-version }} 28 | - name: Cache node_modules 29 | uses: actions/cache@v2 # 使用 GitHub 官方的缓存 Action。 30 | env: 31 | cache-name: cache-node-modules 32 | with: 33 | path: node_modules 34 | key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }} # 使用 package-lock.json 的 Hash 作为缓存的 key。也可以使用 package.json 代替 35 | - name: npm install 36 | run: | 37 | npm install 38 | - name: '运行 【企鹅阅读】' 39 | run: | 40 | node Task/qqreads.js 41 | env: 42 | JD_COOKIE: ${{ secrets.JD_COOKIE }} 43 | WATCH_ACCEPTBODY: ${{ secrets.WATCH_ACCEPTBODY }} 44 | WATCH_DOBODY: ${{ secrets.WATCH_DOBODY }} 45 | QQ_READ_HEADER_VAL: ${{ secrets.QQ_READ_HEADER_VAL }} 46 | QQ_READ_TIME_HEADER_VAL: ${{ secrets.QQ_READ_TIME_HEADER_VAL }} 47 | QQ_READ_TIME_URL_VAL: ${{ secrets.QQ_READ_TIME_URL_VAL }} 48 | JD_DEBUG: ${{ secrets.JD_DEBUG }} 49 | PUSH_KEY: ${{ secrets.PUSH_KEY }} 50 | BARK_PUSH: ${{ secrets.BARK_PUSH }} 51 | BARK_SOUND: ${{ secrets.BARK_SOUND }} 52 | TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }} 53 | TG_USER_ID: ${{ secrets.TG_USER_ID }} 54 | DD_BOT_TOKEN: ${{ secrets.DD_BOT_TOKEN }} 55 | DD_BOT_SECRET: ${{ secrets.DD_BOT_SECRET }} 56 | IGOT_PUSH_KEY: ${{ secrets.IGOT_PUSH_KEY }} 57 | -------------------------------------------------------------------------------- /sendNotify.js: -------------------------------------------------------------------------------- 1 | const $ = new Env(); 2 | // =======================================微信server酱通知设置区域=========================================== 3 | //此处填你申请的SCKEY. 4 | //注:此处设置github action用户填写到Settings-Secrets里面(Name输入PUSH_KEY) 5 | let SCKEY = ''; 6 | 7 | // =======================================Bark App通知设置区域=========================================== 8 | //此处填你BarkAPP的信息(IP/设备码,例如:https://api.day.app/XXXXXXXX) 9 | //注:此处设置github action用户填写到Settings-Secrets里面(Name输入BARK_PUSH) 10 | let BARK_PUSH = ''; 11 | //BARK app推送铃声,铃声列表去APP查看复制填写 12 | //注:此处设置github action用户填写到Settings-Secrets里面(Name输入BARK_SOUND , Value输入app提供的铃声名称,例如:birdsong) 13 | let BARK_SOUND = ''; 14 | 15 | 16 | // =======================================telegram机器人通知设置区域=========================================== 17 | //此处填你telegram bot 的Token,例如:1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw 18 | //注:此处设置github action用户填写到Settings-Secrets里面(Name输入TG_BOT_TOKEN) 19 | let TG_BOT_TOKEN = ''; 20 | //此处填你接收通知消息的telegram用户的id,例如:129xxx206 21 | //注:此处设置github action用户填写到Settings-Secrets里面(Name输入TG_USER_ID) 22 | let TG_USER_ID = ''; 23 | 24 | // =======================================钉钉机器人通知设置区域=========================================== 25 | //此处填你钉钉 bot 的webhook,例如:5a544165465465645d0f31dca676e7bd07415asdasd 26 | //注:此处设置github action用户填写到Settings-Secrets里面(Name输入DD_BOT_TOKEN) 27 | let DD_BOT_TOKEN = ''; 28 | //密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的字符串 29 | let DD_BOT_SECRET = ''; 30 | 31 | if (process.env.PUSH_KEY) { 32 | SCKEY = process.env.PUSH_KEY; 33 | } 34 | if (process.env.BARK_PUSH) { 35 | if(process.env.BARK_PUSH.indexOf('https') > -1 || process.env.BARK_PUSH.indexOf('http') > -1) { 36 | //兼容BARK自建用户 37 | BARK_PUSH = process.env.BARK_PUSH 38 | } else { 39 | BARK_PUSH = `https://api.day.app/${process.env.BARK_PUSH}` 40 | } 41 | if (process.env.BARK_SOUND) { 42 | BARK_SOUND = process.env.BARK_SOUND 43 | } 44 | } else { 45 | if(BARK_PUSH && BARK_PUSH.indexOf('https') === -1 && BARK_PUSH.indexOf('http') === -1) { 46 | //兼容BARK本地用户只填写设备码的情况 47 | BARK_PUSH = `https://api.day.app/${BARK_PUSH}` 48 | } 49 | } 50 | if (process.env.TG_BOT_TOKEN) { 51 | TG_BOT_TOKEN = process.env.TG_BOT_TOKEN; 52 | } 53 | if (process.env.TG_USER_ID) { 54 | TG_USER_ID = process.env.TG_USER_ID; 55 | } 56 | 57 | if (process.env.DD_BOT_TOKEN) { 58 | DD_BOT_TOKEN = process.env.DD_BOT_TOKEN; 59 | if (process.env.DD_BOT_SECRET) { 60 | DD_BOT_SECRET = process.env.DD_BOT_SECRET; 61 | } 62 | } 63 | 64 | async function sendNotify(text, desp) { 65 | //提供四种通知 66 | await serverNotify(text, desp); 67 | await BarkNotify(text, desp); 68 | await tgBotNotify(text, desp); 69 | await ddBotNotify(text, desp); 70 | } 71 | 72 | function serverNotify(text, desp) { 73 | return new Promise(resolve => { 74 | if (SCKEY) { 75 | //微信server酱推送通知一个\n不会换行,需要两个\n才能换行,故做此替换 76 | desp = desp.replace(/[\n\r]/g, '\n\n'); 77 | const options = { 78 | url: `https://sc.ftqq.com/${SCKEY}.send`, 79 | body: `text=${text}&desp=${desp}`, 80 | headers: { 81 | 'Content-Type': 'application/x-www-form-urlencoded' 82 | } 83 | } 84 | $.post(options, (err, resp, data) => { 85 | try { 86 | if (err) { 87 | console.log('\n发送通知调用API失败!!\n') 88 | console.log(err); 89 | } else { 90 | data = JSON.parse(data); 91 | if (data.errno === 0) { 92 | console.log('\nserver酱发送通知消息成功\n') 93 | } else if (data.errno === 1024) { 94 | console.log('\nPUSH_KEY 错误\n') 95 | } 96 | } 97 | } catch (e) { 98 | $.logErr(e, resp); 99 | } finally { 100 | resolve(data); 101 | } 102 | }) 103 | } else { 104 | console.log('\n您未提供server酱的SCKEY,取消微信推送消息通知\n'); 105 | resolve() 106 | } 107 | }) 108 | } 109 | 110 | function BarkNotify(text, desp) { 111 | return new Promise(resolve => { 112 | if (BARK_PUSH) { 113 | const options = { 114 | url: `${BARK_PUSH}/${encodeURIComponent(text)}/${encodeURIComponent(desp)}?sound=${BARK_SOUND}`, 115 | } 116 | $.get(options, (err, resp, data) => { 117 | try { 118 | if (err) { 119 | console.log('\nBark APP发送通知调用API失败!!\n') 120 | console.log(err); 121 | } else { 122 | data = JSON.parse(data); 123 | if (data.code === 200) { 124 | console.log('\nBark APP发送通知消息成功\n') 125 | } else { 126 | console.log(`\n${data.message}\n`); 127 | } 128 | } 129 | } catch (e) { 130 | $.logErr(e, resp); 131 | } finally { 132 | resolve(); 133 | } 134 | }) 135 | } else { 136 | console.log('\n您未提供Bark的APP推送BARK_PUSH,取消Bark推送消息通知\n'); 137 | resolve() 138 | } 139 | }) 140 | } 141 | 142 | function tgBotNotify(text, desp) { 143 | return new Promise(resolve => { 144 | if (TG_BOT_TOKEN && TG_USER_ID) { 145 | const options = { 146 | url: `https://api.telegram.org/bot${TG_BOT_TOKEN}/sendMessage`, 147 | body: `chat_id=${TG_USER_ID}&text=${text}\n\n${desp}`, 148 | headers: { 149 | 'Content-Type': 'application/x-www-form-urlencoded' 150 | } 151 | } 152 | $.post(options, (err, resp, data) => { 153 | try { 154 | if (err) { 155 | console.log('\ntelegram发送通知消息失败!!\n') 156 | console.log(err); 157 | } else { 158 | data = JSON.parse(data); 159 | if (data.ok) { 160 | console.log('\nTelegram发送通知消息完成。\n') 161 | } else if (data.error_code === 400) { 162 | console.log('\n请主动给bot发送一条消息并检查接收用户ID是否正确。\n') 163 | } else if (data.error_code === 401){ 164 | console.log('\nTelegram bot token 填写错误。\n') 165 | } 166 | } 167 | } catch (e) { 168 | $.logErr(e, resp); 169 | } finally { 170 | resolve(data); 171 | } 172 | }) 173 | } else { 174 | console.log('\n您未提供telegram机器人推送所需的TG_BOT_TOKEN和TG_USER_ID,取消telegram推送消息通知\n'); 175 | resolve() 176 | } 177 | }) 178 | } 179 | function ddBotNotify(text, desp) { 180 | return new Promise(resolve => { 181 | const options = { 182 | url: `https://oapi.dingtalk.com/robot/send?access_token=${DD_BOT_TOKEN}`, 183 | json: { 184 | "msgtype": "text", 185 | "text": { 186 | "content": ` ${text}\n\n${desp}` 187 | } 188 | }, 189 | headers: { 190 | 'Content-Type': 'application/json' 191 | } 192 | } 193 | if (DD_BOT_TOKEN && DD_BOT_SECRET) { 194 | const crypto = require('crypto'); 195 | const dateNow = Date.now(); 196 | const hmac = crypto.createHmac('sha256', DD_BOT_SECRET); 197 | hmac.update(`${dateNow}\n${DD_BOT_SECRET}`); 198 | const result = encodeURIComponent(hmac.digest('base64')); 199 | options.url = `${options.url}×tamp=${dateNow}&sign=${result}`; 200 | $.post(options, (err, resp, data) => { 201 | try { 202 | if (err) { 203 | console.log('\n钉钉发送通知消息失败!!\n') 204 | console.log(err); 205 | } else { 206 | data = JSON.parse(data); 207 | if (data.errcode === 0) { 208 | console.log('\n钉钉发送通知消息完成。\n') 209 | } else { 210 | console.log(`\n${data.errmsg}\n`) 211 | } 212 | } 213 | } catch (e) { 214 | $.logErr(e, resp); 215 | } finally { 216 | resolve(data); 217 | } 218 | }) 219 | } else if (DD_BOT_TOKEN) { 220 | $.post(options, (err, resp, data) => { 221 | try { 222 | if (err) { 223 | console.log('\n钉钉发送通知消息失败!!\n') 224 | console.log(err); 225 | } else { 226 | data = JSON.parse(data); 227 | if (data.errcode === 0) { 228 | console.log('\n钉钉发送通知消息完成。\n') 229 | } else { 230 | console.log(`\n${data.errmsg}\n`) 231 | } 232 | } 233 | } catch (e) { 234 | $.logErr(e, resp); 235 | } finally { 236 | resolve(data); 237 | } 238 | }) 239 | } else { 240 | console.log('\n您未提供钉钉机器人推送所需的DD_BOT_TOKEN或者DD_BOT_SECRET,取消钉钉推送消息通知\n'); 241 | resolve() 242 | } 243 | }) 244 | } 245 | module.exports = { 246 | sendNotify, 247 | BarkNotify, 248 | SCKEY, 249 | BARK_PUSH, 250 | TG_BOT_TOKEN, 251 | TG_USER_ID, 252 | DD_BOT_TOKEN, 253 | }//这里导出SCKEY,BARK_PUSH等通知参数是jd_bean_sign.js处需要 254 | // prettier-ignore 255 | function Env(t,s){return new class{constructor(t,s){this.name=t,this.data=null,this.dataFile="box.dat",this.logs=[],this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,s),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}getScript(t){return new Promise(s=>{$.get({url:t},(t,e,i)=>s(i))})}runScript(t,s){return new Promise(e=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let o=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");o=o?1*o:20,o=s&&s.timeout?s.timeout:o;const[h,a]=i.split("@"),r={url:`http://${a}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:o},headers:{"X-Key":h,Accept:"*/*"}};$.post(r,(t,s,i)=>e(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),s=this.path.resolve(process.cwd(),this.dataFile),e=this.fs.existsSync(t),i=!e&&this.fs.existsSync(s);if(!e&&!i)return{};{const i=e?t:s;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),s=this.path.resolve(process.cwd(),this.dataFile),e=this.fs.existsSync(t),i=!e&&this.fs.existsSync(s),o=JSON.stringify(this.data);e?this.fs.writeFileSync(t,o):i?this.fs.writeFileSync(s,o):this.fs.writeFileSync(t,o)}}lodash_get(t,s,e){const i=s.replace(/\[(\d+)\]/g,".$1").split(".");let o=t;for(const t of i)if(o=Object(o)[t],void 0===o)return e;return o}lodash_set(t,s,e){return Object(t)!==t?t:(Array.isArray(s)||(s=s.toString().match(/[^.[\]]+/g)||[]),s.slice(0,-1).reduce((t,e,i)=>Object(t[e])===t[e]?t[e]:t[e]=Math.abs(s[i+1])>>0==+s[i+1]?[]:{},t)[s[s.length-1]]=e,t)}getdata(t){let s=this.getval(t);if(/^@/.test(t)){const[,e,i]=/^@(.*?)\.(.*?)$/.exec(t),o=e?this.getval(e):"";if(o)try{const t=JSON.parse(o);s=t?this.lodash_get(t,i,""):s}catch(t){s=""}}return s}setdata(t,s){let e=!1;if(/^@/.test(s)){const[,i,o]=/^@(.*?)\.(.*?)$/.exec(s),h=this.getval(i),a=i?"null"===h?null:h||"{}":"{}";try{const s=JSON.parse(a);this.lodash_set(s,o,t),e=this.setval(JSON.stringify(s),i)}catch(s){const h={};this.lodash_set(h,o,t),e=this.setval(JSON.stringify(h),i)}}else e=$.setval(t,s);return e}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,s){return this.isSurge()||this.isLoon()?$persistentStore.write(t,s):this.isQuanX()?$prefs.setValueForKey(t,s):this.isNode()?(this.data=this.loaddata(),this.data[s]=t,this.writedata(),!0):this.data&&this.data[s]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,s=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?$httpClient.get(t,(t,e,i)=>{!t&&e&&(e.body=i,e.statusCode=e.status),s(t,e,i)}):this.isQuanX()?$task.fetch(t).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t)):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,s)=>{try{const e=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(e,null),s.cookieJar=this.ckjar}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t)))}post(t,s=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),delete t.headers["Content-Length"],this.isSurge()||this.isLoon())$httpClient.post(t,(t,e,i)=>{!t&&e&&(e.body=i,e.statusCode=e.status),s(t,e,i)});else if(this.isQuanX())t.method="POST",$task.fetch(t).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t));else if(this.isNode()){this.initGotEnv(t);const{url:e,...i}=t;this.got.post(e,i).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t))}}time(t){let s={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let e in s)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?s[e]:("00"+s[e]).substr((""+s[e]).length)));return t}msg(s=t,e="",i="",o){const h=t=>!t||!this.isLoon()&&this.isSurge()?t:"string"==typeof t?this.isLoon()?t:this.isQuanX()?{"open-url":t}:void 0:"object"==typeof t&&(t["open-url"]||t["media-url"])?this.isLoon()?t["open-url"]:this.isQuanX()?t:void 0:void 0;$.isMute||(this.isSurge()||this.isLoon()?$notification.post(s,e,i,h(o)):this.isQuanX()&&$notify(s,e,i,h(o))),this.logs.push("","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="),this.logs.push(s),e&&this.logs.push(e),i&&this.logs.push(i)}log(...t){t.length>0?this.logs=[...this.logs,...t]:console.log(this.logs.join(this.logSeparator))}logErr(t,s){const e=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();e?$.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):$.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(s=>setTimeout(s,t))}done(t={}){const s=(new Date).getTime(),e=(s-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${e} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,s)} 256 | -------------------------------------------------------------------------------- /Task/sendNotify.js: -------------------------------------------------------------------------------- 1 | const $ = new Env(); 2 | // =======================================微信server酱通知设置区域=========================================== 3 | //此处填你申请的SCKEY. 4 | //注:此处设置github action用户填写到Settings-Secrets里面(Name输入PUSH_KEY) 5 | let SCKEY = ''; 6 | 7 | // =======================================Bark App通知设置区域=========================================== 8 | //此处填你BarkAPP的信息(IP/设备码,例如:https://api.day.app/XXXXXXXX) 9 | //注:此处设置github action用户填写到Settings-Secrets里面(Name输入BARK_PUSH) 10 | let BARK_PUSH = ''; 11 | //BARK app推送铃声,铃声列表去APP查看复制填写 12 | //注:此处设置github action用户填写到Settings-Secrets里面(Name输入BARK_SOUND , Value输入app提供的铃声名称,例如:birdsong) 13 | let BARK_SOUND = ''; 14 | 15 | 16 | // =======================================telegram机器人通知设置区域=========================================== 17 | //此处填你telegram bot 的Token,例如:1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw 18 | //注:此处设置github action用户填写到Settings-Secrets里面(Name输入TG_BOT_TOKEN) 19 | let TG_BOT_TOKEN = ''; 20 | //此处填你接收通知消息的telegram用户的id,例如:129xxx206 21 | //注:此处设置github action用户填写到Settings-Secrets里面(Name输入TG_USER_ID) 22 | let TG_USER_ID = ''; 23 | 24 | // =======================================钉钉机器人通知设置区域=========================================== 25 | //此处填你钉钉 bot 的webhook,例如:5a544165465465645d0f31dca676e7bd07415asdasd 26 | //注:此处设置github action用户填写到Settings-Secrets里面(Name输入DD_BOT_TOKEN) 27 | let DD_BOT_TOKEN = ''; 28 | //密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的字符串 29 | let DD_BOT_SECRET = ''; 30 | 31 | if (process.env.PUSH_KEY) { 32 | SCKEY = process.env.PUSH_KEY; 33 | } 34 | if (process.env.BARK_PUSH) { 35 | if(process.env.BARK_PUSH.indexOf('https') > -1 || process.env.BARK_PUSH.indexOf('http') > -1) { 36 | //兼容BARK自建用户 37 | BARK_PUSH = process.env.BARK_PUSH 38 | } else { 39 | BARK_PUSH = `https://api.day.app/${process.env.BARK_PUSH}` 40 | } 41 | if (process.env.BARK_SOUND) { 42 | BARK_SOUND = process.env.BARK_SOUND 43 | } 44 | } else { 45 | if(BARK_PUSH && BARK_PUSH.indexOf('https') === -1 && BARK_PUSH.indexOf('http') === -1) { 46 | //兼容BARK本地用户只填写设备码的情况 47 | BARK_PUSH = `https://api.day.app/${BARK_PUSH}` 48 | } 49 | } 50 | if (process.env.TG_BOT_TOKEN) { 51 | TG_BOT_TOKEN = process.env.TG_BOT_TOKEN; 52 | } 53 | if (process.env.TG_USER_ID) { 54 | TG_USER_ID = process.env.TG_USER_ID; 55 | } 56 | 57 | if (process.env.DD_BOT_TOKEN) { 58 | DD_BOT_TOKEN = process.env.DD_BOT_TOKEN; 59 | if (process.env.DD_BOT_SECRET) { 60 | DD_BOT_SECRET = process.env.DD_BOT_SECRET; 61 | } 62 | } 63 | 64 | async function sendNotify(text, desp) { 65 | //提供四种通知 66 | await serverNotify(text, desp); 67 | await BarkNotify(text, desp); 68 | await tgBotNotify(text, desp); 69 | await ddBotNotify(text, desp); 70 | } 71 | 72 | function serverNotify(text, desp) { 73 | return new Promise(resolve => { 74 | if (SCKEY) { 75 | //微信server酱推送通知一个\n不会换行,需要两个\n才能换行,故做此替换 76 | desp = desp.replace(/[\n\r]/g, '\n\n'); 77 | const options = { 78 | url: `https://sc.ftqq.com/${SCKEY}.send`, 79 | body: `text=${text}&desp=${desp}`, 80 | headers: { 81 | 'Content-Type': 'application/x-www-form-urlencoded' 82 | } 83 | } 84 | $.post(options, (err, resp, data) => { 85 | try { 86 | if (err) { 87 | console.log('\n发送通知调用API失败!!\n') 88 | console.log(err); 89 | } else { 90 | data = JSON.parse(data); 91 | if (data.errno === 0) { 92 | console.log('\nserver酱发送通知消息成功\n') 93 | } else if (data.errno === 1024) { 94 | console.log('\nPUSH_KEY 错误\n') 95 | } 96 | } 97 | } catch (e) { 98 | $.logErr(e, resp); 99 | } finally { 100 | resolve(data); 101 | } 102 | }) 103 | } else { 104 | console.log('\n您未提供server酱的SCKEY,取消微信推送消息通知\n'); 105 | resolve() 106 | } 107 | }) 108 | } 109 | 110 | function BarkNotify(text, desp) { 111 | return new Promise(resolve => { 112 | if (BARK_PUSH) { 113 | const options = { 114 | url: `${BARK_PUSH}/${encodeURIComponent(text)}/${encodeURIComponent(desp)}?sound=${BARK_SOUND}`, 115 | } 116 | $.get(options, (err, resp, data) => { 117 | try { 118 | if (err) { 119 | console.log('\nBark APP发送通知调用API失败!!\n') 120 | console.log(err); 121 | } else { 122 | data = JSON.parse(data); 123 | if (data.code === 200) { 124 | console.log('\nBark APP发送通知消息成功\n') 125 | } else { 126 | console.log(`\n${data.message}\n`); 127 | } 128 | } 129 | } catch (e) { 130 | $.logErr(e, resp); 131 | } finally { 132 | resolve(); 133 | } 134 | }) 135 | } else { 136 | console.log('\n您未提供Bark的APP推送BARK_PUSH,取消Bark推送消息通知\n'); 137 | resolve() 138 | } 139 | }) 140 | } 141 | 142 | function tgBotNotify(text, desp) { 143 | return new Promise(resolve => { 144 | if (TG_BOT_TOKEN && TG_USER_ID) { 145 | const options = { 146 | url: `https://api.telegram.org/bot${TG_BOT_TOKEN}/sendMessage`, 147 | body: `chat_id=${TG_USER_ID}&text=${text}\n\n${desp}`, 148 | headers: { 149 | 'Content-Type': 'application/x-www-form-urlencoded' 150 | } 151 | } 152 | $.post(options, (err, resp, data) => { 153 | try { 154 | if (err) { 155 | console.log('\ntelegram发送通知消息失败!!\n') 156 | console.log(err); 157 | } else { 158 | data = JSON.parse(data); 159 | if (data.ok) { 160 | console.log('\nTelegram发送通知消息完成。\n') 161 | } else if (data.error_code === 400) { 162 | console.log('\n请主动给bot发送一条消息并检查接收用户ID是否正确。\n') 163 | } else if (data.error_code === 401){ 164 | console.log('\nTelegram bot token 填写错误。\n') 165 | } 166 | } 167 | } catch (e) { 168 | $.logErr(e, resp); 169 | } finally { 170 | resolve(data); 171 | } 172 | }) 173 | } else { 174 | console.log('\n您未提供telegram机器人推送所需的TG_BOT_TOKEN和TG_USER_ID,取消telegram推送消息通知\n'); 175 | resolve() 176 | } 177 | }) 178 | } 179 | function ddBotNotify(text, desp) { 180 | return new Promise(resolve => { 181 | const options = { 182 | url: `https://oapi.dingtalk.com/robot/send?access_token=${DD_BOT_TOKEN}`, 183 | json: { 184 | "msgtype": "text", 185 | "text": { 186 | "content": ` ${text}\n\n${desp}` 187 | } 188 | }, 189 | headers: { 190 | 'Content-Type': 'application/json' 191 | } 192 | } 193 | if (DD_BOT_TOKEN && DD_BOT_SECRET) { 194 | const crypto = require('crypto'); 195 | const dateNow = Date.now(); 196 | const hmac = crypto.createHmac('sha256', DD_BOT_SECRET); 197 | hmac.update(`${dateNow}\n${DD_BOT_SECRET}`); 198 | const result = encodeURIComponent(hmac.digest('base64')); 199 | options.url = `${options.url}×tamp=${dateNow}&sign=${result}`; 200 | $.post(options, (err, resp, data) => { 201 | try { 202 | if (err) { 203 | console.log('\n钉钉发送通知消息失败!!\n') 204 | console.log(err); 205 | } else { 206 | data = JSON.parse(data); 207 | if (data.errcode === 0) { 208 | console.log('\n钉钉发送通知消息完成。\n') 209 | } else { 210 | console.log(`\n${data.errmsg}\n`) 211 | } 212 | } 213 | } catch (e) { 214 | $.logErr(e, resp); 215 | } finally { 216 | resolve(data); 217 | } 218 | }) 219 | } else if (DD_BOT_TOKEN) { 220 | $.post(options, (err, resp, data) => { 221 | try { 222 | if (err) { 223 | console.log('\n钉钉发送通知消息失败!!\n') 224 | console.log(err); 225 | } else { 226 | data = JSON.parse(data); 227 | if (data.errcode === 0) { 228 | console.log('\n钉钉发送通知消息完成。\n') 229 | } else { 230 | console.log(`\n${data.errmsg}\n`) 231 | } 232 | } 233 | } catch (e) { 234 | $.logErr(e, resp); 235 | } finally { 236 | resolve(data); 237 | } 238 | }) 239 | } else { 240 | console.log('\n您未提供钉钉机器人推送所需的DD_BOT_TOKEN或者DD_BOT_SECRET,取消钉钉推送消息通知\n'); 241 | resolve() 242 | } 243 | }) 244 | } 245 | module.exports = { 246 | sendNotify, 247 | BarkNotify, 248 | SCKEY, 249 | BARK_PUSH, 250 | TG_BOT_TOKEN, 251 | TG_USER_ID, 252 | DD_BOT_TOKEN, 253 | }//这里导出SCKEY,BARK_PUSH等通知参数是jd_bean_sign.js处需要 254 | // prettier-ignore 255 | function Env(t,s){return new class{constructor(t,s){this.name=t,this.data=null,this.dataFile="box.dat",this.logs=[],this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,s),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}getScript(t){return new Promise(s=>{$.get({url:t},(t,e,i)=>s(i))})}runScript(t,s){return new Promise(e=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let o=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");o=o?1*o:20,o=s&&s.timeout?s.timeout:o;const[h,a]=i.split("@"),r={url:`http://${a}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:o},headers:{"X-Key":h,Accept:"*/*"}};$.post(r,(t,s,i)=>e(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),s=this.path.resolve(process.cwd(),this.dataFile),e=this.fs.existsSync(t),i=!e&&this.fs.existsSync(s);if(!e&&!i)return{};{const i=e?t:s;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),s=this.path.resolve(process.cwd(),this.dataFile),e=this.fs.existsSync(t),i=!e&&this.fs.existsSync(s),o=JSON.stringify(this.data);e?this.fs.writeFileSync(t,o):i?this.fs.writeFileSync(s,o):this.fs.writeFileSync(t,o)}}lodash_get(t,s,e){const i=s.replace(/\[(\d+)\]/g,".$1").split(".");let o=t;for(const t of i)if(o=Object(o)[t],void 0===o)return e;return o}lodash_set(t,s,e){return Object(t)!==t?t:(Array.isArray(s)||(s=s.toString().match(/[^.[\]]+/g)||[]),s.slice(0,-1).reduce((t,e,i)=>Object(t[e])===t[e]?t[e]:t[e]=Math.abs(s[i+1])>>0==+s[i+1]?[]:{},t)[s[s.length-1]]=e,t)}getdata(t){let s=this.getval(t);if(/^@/.test(t)){const[,e,i]=/^@(.*?)\.(.*?)$/.exec(t),o=e?this.getval(e):"";if(o)try{const t=JSON.parse(o);s=t?this.lodash_get(t,i,""):s}catch(t){s=""}}return s}setdata(t,s){let e=!1;if(/^@/.test(s)){const[,i,o]=/^@(.*?)\.(.*?)$/.exec(s),h=this.getval(i),a=i?"null"===h?null:h||"{}":"{}";try{const s=JSON.parse(a);this.lodash_set(s,o,t),e=this.setval(JSON.stringify(s),i)}catch(s){const h={};this.lodash_set(h,o,t),e=this.setval(JSON.stringify(h),i)}}else e=$.setval(t,s);return e}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,s){return this.isSurge()||this.isLoon()?$persistentStore.write(t,s):this.isQuanX()?$prefs.setValueForKey(t,s):this.isNode()?(this.data=this.loaddata(),this.data[s]=t,this.writedata(),!0):this.data&&this.data[s]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,s=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?$httpClient.get(t,(t,e,i)=>{!t&&e&&(e.body=i,e.statusCode=e.status),s(t,e,i)}):this.isQuanX()?$task.fetch(t).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t)):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,s)=>{try{const e=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(e,null),s.cookieJar=this.ckjar}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t)))}post(t,s=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),delete t.headers["Content-Length"],this.isSurge()||this.isLoon())$httpClient.post(t,(t,e,i)=>{!t&&e&&(e.body=i,e.statusCode=e.status),s(t,e,i)});else if(this.isQuanX())t.method="POST",$task.fetch(t).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t));else if(this.isNode()){this.initGotEnv(t);const{url:e,...i}=t;this.got.post(e,i).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t))}}time(t){let s={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let e in s)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?s[e]:("00"+s[e]).substr((""+s[e]).length)));return t}msg(s=t,e="",i="",o){const h=t=>!t||!this.isLoon()&&this.isSurge()?t:"string"==typeof t?this.isLoon()?t:this.isQuanX()?{"open-url":t}:void 0:"object"==typeof t&&(t["open-url"]||t["media-url"])?this.isLoon()?t["open-url"]:this.isQuanX()?t:void 0:void 0;$.isMute||(this.isSurge()||this.isLoon()?$notification.post(s,e,i,h(o)):this.isQuanX()&&$notify(s,e,i,h(o))),this.logs.push("","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="),this.logs.push(s),e&&this.logs.push(e),i&&this.logs.push(i)}log(...t){t.length>0?this.logs=[...this.logs,...t]:console.log(this.logs.join(this.logSeparator))}logErr(t,s){const e=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();e?$.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):$.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(s=>setTimeout(s,t))}done(t={}){const s=(new Date).getTime(),e=(s-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${e} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,s)} 256 | -------------------------------------------------------------------------------- /Task/qqreads.js: -------------------------------------------------------------------------------- 1 | /* ziye 2 | 3 | github地址 https://github.com/ziye12/JavaScript 4 | TG频道地址 https://t.me/ziyescript 5 | TG交流群 https://t.me/joinchat/AAAAAE7XHm-q1-7Np-tF3g 6 | boxjs链接 https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/ziye.boxjs.json 7 | 另一完整版链接 https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/qqreadnode.js 8 | 打印ck链接 https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/qqreadck.js 9 | 10 | 11 | 转载请备注个名字,谢谢 12 | 13 | 11.25 增加 阅读时长上传,阅读金币,阅读随机金币 14 | 11.25 修复翻倍宝箱不同时领取的问题.增加阅读金币判定 15 | 11.25 修复阅读时长问题,阅读金币问题,请重新获取时长cookie 16 | 11.26 随机金币只有一次,故去除,调整修复阅读金币问题,增加时长上传限制 17 | 11.26 增加领取周时长奖励 18 | 11.26 增加结束命令 19 | 11.27 调整通知为,成功开启宝箱再通知 20 | 11.28 修复错误 21 | 11.29 更新 支持action.默认每天21点到21点20通知 22 | 12.2 修复打卡问题 23 | 12.3 缩短运行时间,由于企鹅读书版本更新.请手动进去看一次书 24 | 12.3 调整推送时间为12点和24点左右 25 | 12.6 精简打印通知 26 | 12.7 解决1金币问题,务必重新获取一次更新body 27 | 12.8 更新支持boxjs 28 | 12.10 默认现金大于10且在23点提现10元,23点40后显示今日收益统计 29 | 12.11 修复git与手机 时间不兼容问题 30 | 12.30 增加提现开关,优化部分代码 31 | 12.31 修复版本更新带来的判定问题 32 | 1.4 增加ck失效提醒,ck获取时间显示,6点后今日收益显示, 33 | 34 | 35 | ⚠️cookie获取方法: 36 | 37 | 进 https://m.q.qq.com/a/s/d3eacc70120b9a37e46bad408c0c4c2a 38 | 39 | 进书库⚠️选择一本书,看10秒以下,然后退出,获取时长url和时长header以及更新body,看书一定不能超过10秒 40 | 41 | 42 | 43 | Secrets对应关系如下,多账号默认换行 44 | 45 | qqreadbodyVal 👉 QQREAD_BODY 46 | qqreadtimeurlVal 👉 QQREAD_TIMEURL 47 | qqreadtimeheaderVal 👉 QQREAD_TIMEHD 48 | CASH 👉 QQREAD_CASH 提现标准 可设置0 1 2 10 30 50 100 设置0关闭 49 | 50 | 51 | 52 | ⚠️宝箱奖励为20分钟一次,自己根据情况设置定时,建议设置11分钟一次 53 | 54 | hostname=mqqapi.reader.qq.com 55 | 56 | ############## 圈x 57 | 58 | #企鹅读书获取更新body 59 | https:\/\/mqqapi\.reader\.qq\.com\/log\/v4\/mqq\/track url script-request-body https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/qqreads.js 60 | 61 | #企鹅读书获取时长cookie 62 | https:\/\/mqqapi\.reader\.qq\.com\/mqq\/addReadTimeWithBid? url script-request-header https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/qqreads.js 63 | 64 | ############## loon 65 | 66 | //企鹅读书获取更新body 67 | http-request https:\/\/mqqapi\.reader\.qq\.com\/log\/v4\/mqq\/track script-path=https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/qqreads.js,requires-body=true, tag=企鹅读书获取更新body 68 | 69 | //企鹅读书获取时长cookie 70 | http-request https:\/\/mqqapi\.reader\.qq\.com\/mqq\/addReadTimeWithBid? script-path=https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/qqreads.js, requires-header=true, tag=企鹅读书获取时长cookie 71 | 72 | ############## surge 73 | 74 | //企鹅读书获取更新body 75 | 企鹅读书获取更新body = type=http-request,pattern=https:\/\/mqqapi\.reader\.qq\.com\/log\/v4\/mqq\/track,script-path=https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/qqreads.js, 76 | 77 | //企鹅读书获取时长cookie 78 | 企鹅读书获取时长cookie = type=http-request,pattern=https:\/\/mqqapi\.reader\.qq\.com\/mqq\/addReadTimeWithBid?,script-path=https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/qqreads.js, 79 | 80 | 81 | */ 82 | 83 | const jsname = "企鹅读书"; 84 | const $ = Env(jsname); 85 | $.idx = ($.idx = ($.getval("qeSuffix") || "1") - 1) > 0 ? `${$.idx + 1}` : ""; // 账号扩展字符 86 | const notify = $.isNode() ? require("./sendNotify") : ""; 87 | 88 | let tz = ""; 89 | let kz = ""; 90 | let task = ""; 91 | let CASH = ""; 92 | let config = ""; 93 | let K = 0; 94 | let COOKIES_SPLIT = ""; 95 | let dk,sp,ljyd,ydrw,wktime; 96 | 97 | 98 | const logs = 0; // 0为关闭日志,1为开启 99 | const notifyInterval = 3; 100 | // 0为关闭通知,1为所有通知,2为宝箱领取成功通知,3为宝箱每15次通知一次 101 | 102 | const dd = 1; // 单次任务延迟,默认1秒 103 | const maxtime = 10; // 每日上传时长限制,默认12小时 104 | const wktimess = 1200; // 周奖励领取标准,默认1200分钟 105 | const nowTimes = new Date( 106 | new Date().getTime() + 107 | new Date().getTimezoneOffset() * 60 * 1000 + 108 | 8 * 60 * 60 * 1000 109 | ); 110 | 111 | 112 | 113 | const qqreadbdArr = []; 114 | let qqreadbodyVal = ""; 115 | const qqreadtimeurlArr = []; 116 | let qqreadtimeurlVal = ""; 117 | const qqreadtimehdArr = []; 118 | let qqreadtimeheaderVal = ""; 119 | let qqreadBD = []; 120 | let qqreadtimeURL = []; 121 | let qqreadtimeHD = []; 122 | 123 | if ($.isNode()) { 124 | // 没有设置 QQREAD_CASH 则默认为 0 不提现 125 | CASH = process.env.QQREAD_CASH || 0; 126 | 127 | // 自定义多 cookie 之间连接的分隔符,默认为 \n 换行分割,不熟悉的不要改动和配置,为了兼容本地 node 执行 128 | COOKIES_SPLIT = process.env.COOKIES_SPLIT || "\n"; 129 | 130 | console.log( 131 | `============ cookies分隔符为:${JSON.stringify( 132 | COOKIES_SPLIT 133 | )} =============\n` 134 | ); 135 | if ( 136 | process.env.QQREAD_BODY && 137 | process.env.QQREAD_BODY.indexOf(COOKIES_SPLIT) > -1 138 | ) { 139 | qqreadBD = process.env.QQREAD_BODY.split(COOKIES_SPLIT); 140 | } else { 141 | qqreadBD = process.env.QQREAD_BODY.split(); 142 | } 143 | 144 | if ( 145 | process.env.QQREAD_TIMEURL && 146 | process.env.QQREAD_TIMEURL.indexOf(COOKIES_SPLIT) > -1 147 | ) { 148 | qqreadtimeURL = process.env.QQREAD_TIMEURL.split(COOKIES_SPLIT); 149 | } else { 150 | qqreadtimeURL = process.env.QQREAD_TIMEURL.split(); 151 | } 152 | 153 | if ( 154 | process.env.QQREAD_TIMEHD && 155 | process.env.QQREAD_TIMEHD.indexOf(COOKIES_SPLIT) > -1 156 | ) { 157 | qqreadtimeHD = process.env.QQREAD_TIMEHD.split(COOKIES_SPLIT); 158 | } else { 159 | qqreadtimeHD = process.env.QQREAD_TIMEHD.split(); 160 | } 161 | } 162 | 163 | if ($.isNode()) { 164 | Object.keys(qqreadBD).forEach((item) => { 165 | if (qqreadBD[item]) { 166 | qqreadbdArr.push(qqreadBD[item]); 167 | } 168 | }); 169 | Object.keys(qqreadtimeURL).forEach((item) => { 170 | if (qqreadtimeURL[item]) { 171 | qqreadtimeurlArr.push(qqreadtimeURL[item]); 172 | } 173 | }); 174 | Object.keys(qqreadtimeHD).forEach((item) => { 175 | if (qqreadtimeHD[item]) { 176 | qqreadtimehdArr.push(qqreadtimeHD[item]); 177 | } 178 | }); 179 | } else { 180 | qqreadbdArr.push($.getdata("qqreadbd")); 181 | qqreadtimeurlArr.push($.getdata("qqreadtimeurl")); 182 | qqreadtimehdArr.push($.getdata("qqreadtimehd")); 183 | // 根据boxjs中设置的额外账号数,添加存在的账号数据进行任务处理 184 | if ("qeCASH") { 185 | CASH = $.getval("qeCASH"); 186 | } else CASH = 0; 187 | const qeCount = ($.getval("qeCount") || "1") - 0; 188 | for (let i = 2; i <= qeCount; i++) { 189 | if ($.getdata(`qqreadbd${i}`)) { 190 | qqreadbdArr.push($.getdata(`qqreadbd${i}`)); 191 | qqreadtimeurlArr.push($.getdata(`qqreadtimeurl${i}`)); 192 | qqreadtimehdArr.push($.getdata(`qqreadtimehd${i}`)); 193 | } 194 | } 195 | } 196 | 197 | // 今日0点时间戳 198 | if ($.isNode()) { 199 | daytime = 200 | new Date(new Date().toLocaleDateString()).getTime() - 8 * 60 * 60 * 1000; 201 | } else { 202 | daytime = new Date(new Date().toLocaleDateString()).getTime(); 203 | } 204 | 205 | 206 | if ((isGetCookie = typeof $request !== "undefined")) { 207 | GetCookie(); 208 | $.done(); 209 | } 210 | 211 | 212 | function GetCookie() { 213 | if ( 214 | $request && $request.url.indexOf("addReadTimeWithBid?") >= 0 && 215 | $request.url.indexOf("book-category") >= 0 216 | ) { 217 | const qqreadtimeurlVal = $request.url; 218 | if (qqreadtimeurlVal) $.setdata(qqreadtimeurlVal, `qqreadtimeurl${$.idx}`); 219 | $.log( 220 | `[${ 221 | jsname + $.idx 222 | }] 获取时长url: 成功,qqreadtimeurlVal: ${qqreadtimeurlVal}` 223 | ); 224 | $.msg(jsname + $.idx, `获取时长url: 成功🎉`, ``); 225 | const qqreadtimeheaderVal = JSON.stringify($request.headers); 226 | if (qqreadtimeheaderVal) 227 | $.setdata(qqreadtimeheaderVal, `qqreadtimehd${$.idx}`); 228 | $.log( 229 | `[${ 230 | jsname + $.idx 231 | }] 获取时长header: 成功,qqreadtimeheaderVal: ${qqreadtimeheaderVal}` 232 | ); 233 | $.msg(jsname + $.idx, `获取时长header: 成功🎉`, ``); 234 | } else if ( 235 | $request && 236 | $request.body.indexOf("bookDetail_bottomBar_read_C") >= 0 && 237 | $request.body.indexOf("bookLib2_bookList_bookClick_C") >= 0 && 238 | $request.body.indexOf("bookRead_show_I") >= 0 && 239 | $request.body.indexOf("topBar_left_back_C") < 0 && 240 | $request.body.indexOf("bookRead_dropOut_shelfYes_C") < 0 241 | ) { 242 | const qqreadbodyVal = $request.body; 243 | if (qqreadbodyVal) $.setdata(qqreadbodyVal, `qqreadbd${$.idx}`); 244 | $.log( 245 | `[${jsname + $.idx}] 获取更新body: 成功,qqreadbodyVal: ${qqreadbodyVal}` 246 | ); 247 | $.msg(jsname + $.idx, `获取更新body: 成功🎉`, ``); 248 | } 249 | } 250 | 251 | console.log( 252 | `================== 脚本执行 - 北京时间(UTC+8):${new Date( 253 | new Date().getTime() + 254 | new Date().getTimezoneOffset() * 60 * 1000 + 255 | 8 * 60 * 60 * 1000 256 | ).toLocaleString()} =====================\n` 257 | ); 258 | 259 | console.log( 260 | `============ 共 ${qqreadbdArr.length} 个${jsname}账号:预计运行 ${ 261 | qqreadbdArr.length * 13 262 | } 秒 =============\n` 263 | ); 264 | 265 | console.log(`============ 提现标准为:${CASH} =============\n`); 266 | 267 | all(); 268 | function all() { 269 | if (!qqreadbdArr[0]) { 270 | $.msg( 271 | jsname, 272 | "⚠️提示:您还未获取cookie,请点击前往获取cookie\n", 273 | "https://m.q.qq.com/a/s/d3eacc70120b9a37e46bad408c0c4c2a", 274 | { "open-url": "https://m.q.qq.com/a/s/d3eacc70120b9a37e46bad408c0c4c2a" } 275 | ); 276 | $.done(); 277 | } 278 | 279 | qqreadbodyVal = qqreadbdArr[K]; 280 | qqreadtimeurlVal = qqreadtimeurlArr[K]; 281 | qqreadtimeheaderVal = qqreadtimehdArr[K]; 282 | O = `${jsname + (K + 1)}🔔`; 283 | for (let i = 0; i < 13; i++) { 284 | (function (i) { 285 | setTimeout( 286 | function () { 287 | if (i == 0) qqreadinfo(); // 用户名 288 | if (i == 1) { 289 | qqreadwktime(); // 周时长查询 290 | qqreadconfig(); // 时长查询 291 | qqreadtrack(); // 更新 292 | } else if (i == 2) { 293 | qqreadtask(); // 任务列表 294 | if ( 295 | config.data && 296 | config.data.pageParams.todayReadSeconds / 3600 <= maxtime 297 | ) 298 | qqreadtime(); // 上传时长 299 | } else if (i == 3) { 300 | if ( 301 | wktime && 302 | wktime.data && 303 | wktime.data.readTime >= wktimess && 304 | wktime.data.readTime <= 1250 305 | ) { 306 | qqreadpick(); // 领周时长奖励 307 | } 308 | if (task.data && ljyd.doneFlag == 0) qqreaddayread(); // 阅读任务 309 | if ( 310 | ydrw && 311 | ydrw.doneFlag == 0 && 312 | config.data && 313 | config.data.pageParams.todayReadSeconds / 60 >= 1 314 | ) 315 | qqreadssr1(); // 阅读金币1 316 | if (task.data && dk.doneFlag == 0) { 317 | qqreadsign(); // 金币签到 318 | qqreadtake(); // 阅豆签到 319 | } 320 | if (task.data && sp.doneFlag == 0) qqreadvideo(); // 视频任务 321 | } else if (i == 7) { 322 | if (task.data && task.data.treasureBox.doneFlag == 0) qqreadbox(); // 宝箱 323 | if ( 324 | ydrw && 325 | ydrw.doneFlag == 0 && 326 | config.data && 327 | config.data.pageParams.todayReadSeconds / 60 >= 30 328 | ) 329 | qqreadssr2(); // 阅读金币2 330 | if (task.data && dk.doneFlag == 0) qqreadsign2(); // 签到翻倍 331 | } else if ( 332 | i == 8 && 333 | CASH >= 1 && 334 | task.data.user.amount >= CASH * 10000 && 335 | nowTimes.getHours() == 23 336 | ) { 337 | qqreadwithdraw(); // 现金提现 338 | } else if (i == 9 && 339 | nowTimes.getHours() >= 6 340 | ) { 341 | getAmounts(); // 今日收益累计 342 | } else if (i == 11) { 343 | if (task.data && task.data.treasureBox.videoDoneFlag == 0) 344 | qqreadbox2(); // 宝箱翻倍 345 | if ( 346 | ydrw && 347 | ydrw.doneFlag == 0 && 348 | config.data && 349 | config.data.pageParams.todayReadSeconds / 60 >= 30 350 | ) 351 | qqreadssr3(); // 阅读金币3 352 | } else if (i == 12) { 353 | if (K < qqreadbdArr.length - 1) { 354 | K += 1; 355 | all(); 356 | } else if (K == qqreadbdArr.length - 1) { 357 | showmsg(); // 通知 358 | $.done(); 359 | } 360 | } 361 | }, 362 | 363 | (i + 1) * dd * 1000 364 | ); 365 | })(i); 366 | } 367 | } 368 | 369 | function showmsg() { 370 | console.log( 371 | `================== 脚本执行 - 北京时间(UTC+8):${new Date( 372 | new Date().getTime() + 373 | new Date().getTimezoneOffset() * 60 * 1000 + 374 | 8 * 60 * 60 * 1000 375 | ).toLocaleString()} =====================\n` 376 | ); 377 | if ( 378 | $.isNode() && 379 | (nowTimes.getHours() === 12 || nowTimes.getHours() === 23) && 380 | nowTimes.getMinutes() >= 0 && 381 | nowTimes.getMinutes() <= 30 382 | ) { 383 | notify.sendNotify(jsname, kz); 384 | } 385 | if (notifyInterval != 1) console.log(tz); // 无通知时,打印通知 386 | if (notifyInterval == 1) $.msg(jsname, "", tz); 387 | // 显示所有通知 388 | else if ( 389 | notifyInterval == 2 && 390 | task.data && 391 | task.data.treasureBox.doneFlag == 0 392 | ) 393 | $.msg(jsname, "", tz); 394 | // 宝箱领取成功通知 395 | else if ( 396 | (notifyInterval == 3 && task.data && task.data.treasureBox.count == 0) || 397 | task.data.treasureBox.count == 15 || 398 | task.data.treasureBox.count == 30 || 399 | task.data.treasureBox.count == 45 || 400 | task.data.treasureBox.count == 60 401 | ) 402 | $.msg(jsname, "", tz); // 宝箱每15次通知一次 403 | } 404 | // 任务列表 405 | function qqreadtask() { 406 | return new Promise((resolve, reject) => { 407 | const toqqreadtaskurl = { 408 | url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/page?fromGuid=", 409 | headers: JSON.parse(qqreadtimeheaderVal), 410 | timeout: 60000, 411 | }; 412 | $.get(toqqreadtaskurl, (error, response, data) => { 413 | if (logs) $.log(`${O}, 任务列表: ${data}`); 414 | task = JSON.parse(data); 415 | dk = task.data.taskList.find((item) => item.type === 200); 416 | ljyd = task.data.taskList.find((item) => item.type === 210); 417 | ydrw = task.data.taskList.find((item) => item.type === 220); 418 | sp = task.data.taskList.find((item) => item.type === 230); 419 | 420 | if (task.data.invite.nextInviteConfig) { 421 | tz += 422 | `【现金余额】:${(task.data.user.amount / 10000).toFixed(2)}元\n` + 423 | `【第${task.data.invite.issue}期】:时间${task.data.invite.dayRange}\n` + 424 | ` 已邀请${task.data.invite.inviteCount}人,再邀请${task.data.invite.nextInviteConfig.count}人获得${task.data.invite.nextInviteConfig.amount}金币\n` + 425 | `【${dk.title}】:${dk.amount}金币,${dk.actionText}\n` + 426 | `【${ljyd.title}】:${ljyd.amount}金币,${ljyd.actionText}\n` + 427 | `【${ydrw.title}】:${ydrw.amount}金币,${ydrw.actionText}\n` + 428 | `【${sp.title}】:${sp.amount}金币,${sp.actionText}\n` + 429 | `【宝箱任务${task.data.treasureBox.count + 1}】:${ 430 | task.data.treasureBox.tipText 431 | }\n` + 432 | `【${task.data.fans.title}】:${task.data.fans.fansCount}个好友,${task.data.fans.todayAmount}金币\n`; 433 | } 434 | 435 | kz += 436 | `【现金余额】:${(task.data.user.amount / 10000).toFixed(2)}元\n` + 437 | `【宝箱任务${task.data.treasureBox.count + 1}】:${ 438 | task.data.treasureBox.timeInterval / 1000 439 | }秒后领取\n` + 440 | `【已开宝箱】:${task.data.treasureBox.count}个\n`; 441 | 442 | resolve(); 443 | }); 444 | }); 445 | } 446 | // 统计金币 447 | async function getAmounts() { 448 | let page = 1 449 | let amounts = 0 450 | while (true) { 451 | const { total, isEnd } = await getTodayAmount(page) 452 | amounts += total 453 | if (isEnd) { 454 | break 455 | } else { 456 | page++ 457 | await $.wait(200) 458 | } 459 | } 460 | if (logs) $.log(`${O}, 今日收益: ${amounts}金币,约${(amounts / 10000.0).toFixed(2)}元.`); 461 | tz += `【今日收益】:获得${amounts}金币,约${(amounts / 10000.0).toFixed(2)}元.\n` 462 | kz += `【今日收益】:获得${amounts}金币,约${(amounts / 10000.0).toFixed(2)}元.\n` 463 | } 464 | 465 | function getTodayAmount(page = 1) { 466 | return new Promise((r, j) => { 467 | const options = { 468 | url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/trans/list?pn=" + page, 469 | headers: JSON.parse(qqreadtimeheaderVal), 470 | timeout: 60000, 471 | } 472 | $.get(options, (error, response, data) => { 473 | const obj = JSON.parse(data) 474 | let isEnd = obj.data.list.length == 0 475 | let total = 0 476 | for (let index = 0; index < obj.data.list.length; index++) { 477 | const element = obj.data.list[index]; 478 | if (element.createTime < daytime){ 479 | isEnd = true 480 | break 481 | } 482 | total += element.amount 483 | } 484 | r({ total, isEnd }) 485 | }) 486 | }) 487 | } 488 | // 更新 489 | function qqreadtrack() { 490 | return new Promise((resolve, reject) => { 491 | const body = qqreadbodyVal.replace(new RegExp(/"dis":[0-9]{13}/), `"dis":${new Date().getTime()}`) 492 | const toqqreadtrackurl = { 493 | url: "https://mqqapi.reader.qq.com/log/v4/mqq/track", 494 | headers: JSON.parse(qqreadtimeheaderVal), 495 | body: body, 496 | timeout: 60000, 497 | }; 498 | $.post(toqqreadtrackurl, (error, response, data) => { 499 | if (logs) $.log(`${O}, 更新: ${data}`); 500 | let track = JSON.parse(data); 501 | var date = new Date(JSON.parse(qqreadbodyVal).dataList[0].dis); 502 | Y = date.getFullYear() + '-'; 503 | M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-'; 504 | D = date.getDate() + ' '; 505 | h = date.getHours() + ':'; 506 | m = date.getMinutes() + ':'; 507 | s = date.getSeconds(); 508 | time=Y+M+D+h+m+s; 509 | tz += `【数据更新】:更新${track.msg},\n【cookie获取时间】${time}\n`; 510 | kz += `【数据更新】:更新${track.msg},\n【cookie获取时间】${time}\n`; 511 | resolve(); 512 | }); 513 | }); 514 | } 515 | // 提现 516 | function qqreadwithdraw() { 517 | return new Promise((resolve, reject) => { 518 | const toqqreadwithdrawurl = { 519 | url: `https://mqqapi.reader.qq.com/mqq/red_packet/user/withdraw?amount=${ 520 | CASH * 10000 521 | }`, 522 | headers: JSON.parse(qqreadtimeheaderVal), 523 | timeout: 60000, 524 | }; 525 | $.post(toqqreadwithdrawurl, (error, response, data) => { 526 | if (logs) $.log(`${O}, 提现: ${data}`); 527 | const withdraw = JSON.parse(data); 528 | if (withdraw.data.code == 0) { 529 | tz += `【现金提现】:成功提现${CASH}元\n`; 530 | kz += `【现金提现】:成功提现${CASH}元\n`; 531 | } 532 | resolve(); 533 | }); 534 | }); 535 | } 536 | // 用户名 537 | function qqreadinfo() { 538 | return new Promise((resolve, reject) => { 539 | const toqqreadinfourl = { 540 | url: "https://mqqapi.reader.qq.com/mqq/user/init", 541 | headers: JSON.parse(qqreadtimeheaderVal), 542 | timeout: 60000, 543 | }; 544 | $.get(toqqreadinfourl, (error, response, data) => { 545 | if (logs) $.log(`${O}, 用户名: ${data}`); 546 | info = JSON.parse(data); 547 | if (!info.data.user) 548 | $.msg( 549 | `【${O}】`, 550 | "COOKE失效:❌❌❌请点击前往获取cookie\n", 551 | "https://m.q.qq.com/a/s/d3eacc70120b9a37e46bad408c0c4c2a", 552 | { 553 | "open-url": 554 | "https://m.q.qq.com/a/s/d3eacc70120b9a37e46bad408c0c4c2a", 555 | } 556 | ); 557 | if (info.data.user.nickName) { 558 | kz += `\n========== 【${info.data.user.nickName}】 ==========\n`; 559 | tz += `\n========== 【${info.data.user.nickName}】 ==========\n`; 560 | } 561 | resolve(); 562 | }); 563 | }); 564 | } 565 | // 阅豆签到 566 | function qqreadtake() { 567 | return new Promise((resolve, reject) => { 568 | const toqqreadtakeurl = { 569 | url: "https://mqqapi.reader.qq.com/mqq/sign_in/user", 570 | headers: JSON.parse(qqreadtimeheaderVal), 571 | timeout: 60000, 572 | }; 573 | $.post(toqqreadtakeurl, (error, response, data) => { 574 | if (logs) $.log(`${O}, 阅豆签到: ${data}`); 575 | take = JSON.parse(data); 576 | if (take.data.takeTicket > 0) { 577 | tz += `【阅豆签到】:获得${take.data.takeTicket}豆\n`; 578 | } 579 | resolve(); 580 | }); 581 | }); 582 | } 583 | // 阅读时长任务 584 | function qqreadconfig() { 585 | return new Promise((resolve, reject) => { 586 | const toqqreadconfigurl = { 587 | url: 588 | "https://mqqapi.reader.qq.com/mqq/page/config?router=%2Fpages%2Fbook-read%2Findex&options=", 589 | headers: JSON.parse(qqreadtimeheaderVal), 590 | }; 591 | $.get(toqqreadconfigurl, (error, response, data) => { 592 | if (logs) $.log(`${O}, 阅读时长查询: ${data}`); 593 | config = JSON.parse(data); 594 | if (config.code == 0) { 595 | tz += `【时长查询】:今日阅读${( 596 | config.data.pageParams.todayReadSeconds / 60 597 | ).toFixed(0)}分钟\n`; 598 | } 599 | resolve(); 600 | }); 601 | }); 602 | } 603 | // 阅读时长 604 | function qqreadtime() { 605 | return new Promise((resolve, reject) => { 606 | do TIME = Math.floor(Math.random() * 35); 607 | while (TIME < 25); 608 | const toqqreadtimeurl = { 609 | url: qqreadtimeurlVal.replace(/readTime=/g, `readTime=${TIME}`), 610 | headers: JSON.parse(qqreadtimeheaderVal), 611 | }; 612 | $.get(toqqreadtimeurl, (error, response, data) => { 613 | if (logs) $.log(`${O}, 阅读时长: ${data}`); 614 | const time = JSON.parse(data); 615 | if (time.code == 0) { 616 | tz += `【阅读时长】:上传${(TIME / 6).toFixed(1)}分钟\n`; 617 | } 618 | resolve(); 619 | }); 620 | }); 621 | } 622 | // 阅读金币1 623 | function qqreadssr1() { 624 | return new Promise((resolve, reject) => { 625 | const toqqreadssr1url = { 626 | url: `https://mqqapi.reader.qq.com/mqq/red_packet/user/read_time?seconds=30`, 627 | headers: JSON.parse(qqreadtimeheaderVal), 628 | timeout: 60000, 629 | }; 630 | $.get(toqqreadssr1url, (error, response, data) => { 631 | if (logs) $.log(`${O}, 金币奖励1: ${data}`); 632 | ssr1 = JSON.parse(data); 633 | if (ssr1.data.amount > 0) { 634 | tz += `【阅读金币1】获得${ssr1.data.amount}金币\n`; 635 | } 636 | resolve(); 637 | }); 638 | }); 639 | } 640 | // 阅读金币2 641 | function qqreadssr2() { 642 | return new Promise((resolve, reject) => { 643 | const toqqreadssr2url = { 644 | url: `https://mqqapi.reader.qq.com/mqq/red_packet/user/read_time?seconds=300`, 645 | headers: JSON.parse(qqreadtimeheaderVal), 646 | timeout: 60000, 647 | }; 648 | $.get(toqqreadssr2url, (error, response, data) => { 649 | if (logs) $.log(`${O}, 金币奖励2: ${data}`); 650 | ssr2 = JSON.parse(data); 651 | if (ssr2.data.amount > 0) { 652 | tz += `【阅读金币2】获得${ssr2.data.amount}金币\n`; 653 | } 654 | resolve(); 655 | }); 656 | }); 657 | } 658 | // 阅读金币3 659 | function qqreadssr3() { 660 | return new Promise((resolve, reject) => { 661 | const toqqreadssr3url = { 662 | url: `https://mqqapi.reader.qq.com/mqq/red_packet/user/read_time?seconds=1800`, 663 | headers: JSON.parse(qqreadtimeheaderVal), 664 | timeout: 60000, 665 | }; 666 | $.get(toqqreadssr3url, (error, response, data) => { 667 | if (logs) $.log(`${O}, 金币奖励3: ${data}`); 668 | ssr3 = JSON.parse(data); 669 | if (ssr3.data.amount > 0) { 670 | tz += `【阅读金币3】获得${ssr3.data.amount}金币\n`; 671 | } 672 | resolve(); 673 | }); 674 | }); 675 | } 676 | // 金币签到 677 | function qqreadsign() { 678 | return new Promise((resolve, reject) => { 679 | const toqqreadsignurl = { 680 | url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/clock_in", 681 | headers: JSON.parse(qqreadtimeheaderVal), 682 | timeout: 60000, 683 | }; 684 | $.get(toqqreadsignurl, (error, response, data) => { 685 | if (logs) $.log(`${O}, 金币签到: ${data}`); 686 | sign = JSON.parse(data); 687 | if (sign.code == 0) { 688 | tz += `【金币签到】:获得${sign.data.amount}金币\n`; 689 | } 690 | resolve(); 691 | }); 692 | }); 693 | } 694 | // 金币签到翻倍 695 | function qqreadsign2() { 696 | return new Promise((resolve, reject) => { 697 | const toqqreadsign2url = { 698 | url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/clock_in_video", 699 | headers: JSON.parse(qqreadtimeheaderVal), 700 | timeout: 60000, 701 | }; 702 | $.get(toqqreadsign2url, (error, response, data) => { 703 | if (logs) $.log(`${O}, 金币签到翻倍: ${data}`); 704 | sign2 = JSON.parse(data); 705 | if (sign2.code == 0) { 706 | tz += `【签到翻倍】:获得${sign2.data.amount}金币\n`; 707 | } 708 | resolve(); 709 | }); 710 | }); 711 | } 712 | // 每日阅读 713 | function qqreaddayread() { 714 | return new Promise((resolve, reject) => { 715 | const toqqreaddayreadurl = { 716 | url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/read_book", 717 | headers: JSON.parse(qqreadtimeheaderVal), 718 | timeout: 60000, 719 | }; 720 | $.get(toqqreaddayreadurl, (error, response, data) => { 721 | if (logs) $.log(`${O}, 每日阅读: ${data}`); 722 | dayread = JSON.parse(data); 723 | if (dayread.code == 0) { 724 | tz += `【每日阅读】:获得${dayread.data.amount}金币\n`; 725 | } 726 | resolve(); 727 | }); 728 | }); 729 | } 730 | // 视频奖励 731 | function qqreadvideo() { 732 | return new Promise((resolve, reject) => { 733 | const toqqreadvideourl = { 734 | url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/watch_video", 735 | headers: JSON.parse(qqreadtimeheaderVal), 736 | timeout: 60000, 737 | }; 738 | $.get(toqqreadvideourl, (error, response, data) => { 739 | if (logs) $.log(`${O}, 视频奖励: ${data}`); 740 | video = JSON.parse(data); 741 | if (video.code == 0) { 742 | tz += `【视频奖励】:获得${video.data.amount}金币\n`; 743 | } 744 | resolve(); 745 | }); 746 | }); 747 | } 748 | // 宝箱奖励 749 | function qqreadbox() { 750 | return new Promise((resolve, reject) => { 751 | const toqqreadboxurl = { 752 | url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/treasure_box", 753 | headers: JSON.parse(qqreadtimeheaderVal), 754 | timeout: 60000, 755 | }; 756 | $.get(toqqreadboxurl, (error, response, data) => { 757 | if (logs) $.log(`${O}, 宝箱奖励: ${data}`); 758 | box = JSON.parse(data); 759 | if (box.code == 0) { 760 | tz += `【宝箱奖励${box.data.count}】:获得${box.data.amount}金币\n`; 761 | } 762 | resolve(); 763 | }); 764 | }); 765 | } 766 | // 宝箱奖励翻倍 767 | function qqreadbox2() { 768 | return new Promise((resolve, reject) => { 769 | const toqqreadbox2url = { 770 | url: 771 | "https://mqqapi.reader.qq.com/mqq/red_packet/user/treasure_box_video", 772 | headers: JSON.parse(qqreadtimeheaderVal), 773 | timeout: 60000, 774 | }; 775 | $.get(toqqreadbox2url, (error, response, data) => { 776 | if (logs) $.log(`${O}, 宝箱奖励翻倍: ${data}`); 777 | box2 = JSON.parse(data); 778 | if (box2.code == 0) { 779 | tz += `【宝箱翻倍】:获得${box2.data.amount}金币\n`; 780 | } 781 | resolve(); 782 | }); 783 | }); 784 | } 785 | // 本周阅读时长 786 | function qqreadwktime() { 787 | return new Promise((resolve, reject) => { 788 | const toqqreadwktimeurl = { 789 | url: `https://mqqapi.reader.qq.com/mqq/v1/bookShelfInit`, 790 | headers: JSON.parse(qqreadtimeheaderVal), 791 | }; 792 | $.get(toqqreadwktimeurl, (error, response, data) => { 793 | if (logs) $.log(`${O}, 阅读时长: ${data}`); 794 | wktime = JSON.parse(data); 795 | if (wktime.code == 0) { 796 | tz += `【本周阅读时长】:${wktime.data.readTime}分钟\n`; 797 | } 798 | resolve(); 799 | }); 800 | }); 801 | } 802 | // 本周阅读时长奖励任务 803 | function qqreadpick() { 804 | return new Promise((resolve, reject) => { 805 | const toqqreadpickurl = { 806 | url: `https://mqqapi.reader.qq.com/mqq/pickPackageInit`, 807 | headers: JSON.parse(qqreadtimeheaderVal), 808 | }; 809 | $.get(toqqreadpickurl, (error, response, data) => { 810 | if (logs) $.log(`${O},周阅读时长奖励任务: ${data}`); 811 | pick = JSON.parse(data); 812 | if (pick.data[7].isPick == true) tz += "【周时长奖励】:已全部领取\n"; 813 | for (let i = 0; i < pick.data.length; i++) { 814 | setTimeout(() => { 815 | const pickid = pick.data[i].readTime; 816 | const Packageid = ["10", "10", "20", "30", "50", "80", "100", "120"]; 817 | const toqqreadPackageurl = { 818 | url: `https://mqqapi.reader.qq.com/mqq/pickPackage?readTime=${pickid}`, 819 | headers: JSON.parse(qqreadtimeheaderVal), 820 | timeout: 60000, 821 | }; 822 | $.get(toqqreadPackageurl, (error, response, data) => { 823 | if (logs) $.log(`${O}, 领周阅读时长: ${data}`); 824 | Package = JSON.parse(data); 825 | if (Package.code == 0) 826 | tz += `【周时长奖励${i + 1}】:领取${Packageid[i]}阅豆\n`; 827 | }); 828 | }, i * 100); 829 | } 830 | }); 831 | resolve(); 832 | }); 833 | } 834 | 835 | // prettier-ignore 836 | function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} 837 | -------------------------------------------------------------------------------- /Task/qqreadnode.js: -------------------------------------------------------------------------------- 1 | /*ziye 2 | ****************************************************************************** 3 | ⚠️可N个账号,BOX 设置为0 日常任务,设置为1 单开宝箱,设置为2 完整功能 4 | 5 | ⚠️云函数固定ck则在 qqreadCOOKIE 文件里面填写ck,多账号换行 6 | 7 | qqreadCOOKIE地址 https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/qqreadCOOKIE.js 8 | github地址 https://github.com/ziye12/JavaScript 9 | TG频道地址 https://t.me/ziyescript 10 | TG交流群 https://t.me/joinchat/AAAAAE7XHm-q1-7Np-tF3g 11 | boxjs链接 https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/ziye.boxjs.json 12 | 另一版 https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/qqreads.js 13 | 14 | 本人github地址 https://github.com/ziye12/JavaScript 15 | 转载请备注个名字,谢谢 16 | 17 | 12.28 固定ck版,增加外部通知,默认12点以及23.40通知,解决宝箱翻倍问题,解决手机端运行异常问题 18 | 12.28 解决通知问题,notifyInterval 0为关闭通知,1为所有通知,2为12 23 点通知 , 3为 6 12 18 23 点通知 19 | 12.28 增加 无通知时打印通知 20 | 12.29 修复手机通知问题,增加外部推送开关 21 | 1.1 修复签到问题 22 | 1.2 增加完整功能 兼容固定ck与boxjs以及变量版 23 | 1.3 增加ck失效提醒,并继续执行其他账号 24 | 1.3 增加一个独立的cookie文件 25 | 1.3 增加cookie获取时间显示 26 | 1.4 单开宝箱不再ck失效提示,增加6点后显示今日收益 27 | 1.5 调整宝箱策略,20分钟运行一次就行 28 | 29 | ⚠️cookie获取方法: 30 | 31 | 进 https://m.q.qq.com/a/s/d3eacc70120b9a37e46bad408c0c4c2a 点我的 获取cookie 32 | 33 | 进一本书 看 10秒以下 然后退出,获取阅读时长cookie,看书一定不能超过10秒 34 | 35 | 可能某些页面会卡住,但是能获取到cookie,再注释cookie重写就行了! 36 | 37 | Secrets对应关系如下,多账号默认换行 38 | 39 | qqreadbodyVal 👉 QQREAD_BODY 40 | qqreadtimeurlVal 👉 QQREAD_TIMEURL 41 | qqreadtimeheaderVal 👉 QQREAD_TIMEHD 42 | CASH 👉 QQREAD_CASH 提现标准 可设置0 1 2 10 30 50 100 设置0关闭 43 | 44 | 45 | ⚠️宝箱奖励为20分钟一次,自己根据情况设置定时,建议设置11分钟一次 46 | 47 | hostname=mqqapi.reader.qq.com 48 | ############## 圈x 49 | #企鹅读书获取更新body 50 | https:\/\/mqqapi\.reader\.qq\.com\/log\/v4\/mqq\/track url script-request-body https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/qqreads.js 51 | #企鹅读书获取时长cookie 52 | https:\/\/mqqapi\.reader\.qq\.com\/mqq\/addReadTimeWithBid? url script-request-header https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/qqreads.js 53 | 54 | ############## loon 55 | #企鹅读书获取更新body 56 | http-request https:\/\/mqqapi\.reader\.qq\.com\/log\/v4\/mqq\/track script-path=https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/qqreads.js,requires-body=true, tag=企鹅读书获取更新body 57 | #企鹅读书获取时长cookie 58 | http-request https:\/\/mqqapi\.reader\.qq\.com\/mqq\/addReadTimeWithBid? script-path=https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/qqreads.js, requires-header=true, tag=企鹅读书获取时长cookie 59 | 60 | ############## surge 61 | #企鹅读书获取更新body 62 | 企鹅读书获取更新body = type=http-request,pattern=https:\/\/mqqapi\.reader\.qq\.com\/log\/v4\/mqq\/track,script-path=https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/qqreads.js, 63 | #企鹅读书获取时长cookie 64 | 企鹅读书获取时长cookie = type=http-request,pattern=https:\/\/mqqapi\.reader\.qq\.com\/mqq\/addReadTimeWithBid?,script-path=https://raw.githubusercontent.com/ziye12/JavaScript/master/Task/qqreads.js, 65 | 66 | 67 | 68 | */ 69 | 70 | const BOX = 2;//设置为0 日常任务,设置为1 单开宝箱,设置为2 完整功能版 71 | 72 | 73 | 74 | 75 | const jsname = '企鹅读书' 76 | const $ = Env(jsname) 77 | const COOKIE = $.isNode() ? require("./qqreadCOOKIE") : ""; 78 | const notify = $.isNode() ? require("./sendNotify") : ""; 79 | const notifyttt = 1// 0为关闭外部推送,1为12 23 点外部推送 80 | const notifyInterval = 2;// 0为关闭通知,1为所有通知,2为12 23 点通知 , 3为 6 12 18 23 点通知 81 | const logs = 0; //0为关闭日志,1为开启 82 | const maxtime = 10//每日上传时长限制,默认20小时 83 | const wktimess = 1200//周奖励领取标准,默认1200分钟 84 | 85 | let task, tz, kz, config = '', CASH = '', COOKIES_SPLIT = '' ; 86 | let dk,ljyd,sp,ydrw,wktime; 87 | 88 | let qqreadbodyVal = ``; 89 | let qqreadtimeurlVal = ``; 90 | let qqreadtimeheaderVal = ``; 91 | const qqreadbdArr = []; 92 | const qqreadtimeurlArr = []; 93 | const qqreadtimehdArr = []; 94 | let qqreadBD = []; 95 | let qqreadtimeURL = []; 96 | let qqreadtimeHD = []; 97 | 98 | const nowTimes = new Date( 99 | new Date().getTime() + 100 | new Date().getTimezoneOffset() * 60 * 1000 + 101 | 8 * 60 * 60 * 1000 102 | ); 103 | // 今日0点时间戳 104 | if ($.isNode()) { 105 | daytime = 106 | new Date(new Date().toLocaleDateString()).getTime() - 8 * 60 * 60 * 1000; 107 | // 没有设置 QQREAD_CASH 则默认为 0 不提现 108 | CASH = process.env.QQREAD_CASH || 0; 109 | } else { 110 | daytime = new Date(new Date().toLocaleDateString()).getTime(); 111 | } 112 | 113 | if ($.isNode() &&process.env.QQREAD_BODY) { 114 | // 自定义多 cookie 之间连接的分隔符,默认为 \n 换行分割,不熟悉的不要改动和配置,为了兼容本地 node 执行 115 | COOKIES_SPLIT = process.env.COOKIES_SPLIT || "\n"; 116 | console.log( 117 | `============ cookies分隔符为:${JSON.stringify( 118 | COOKIES_SPLIT 119 | )} =============\n` 120 | ); 121 | if ( 122 | process.env.QQREAD_BODY && 123 | process.env.QQREAD_BODY.indexOf(COOKIES_SPLIT) > -1 124 | ) { 125 | qqreadBD = process.env.QQREAD_BODY.split(COOKIES_SPLIT); 126 | } else { 127 | qqreadBD = process.env.QQREAD_BODY.split(); 128 | } 129 | 130 | if ( 131 | process.env.QQREAD_TIMEURL && 132 | process.env.QQREAD_TIMEURL.indexOf(COOKIES_SPLIT) > -1 133 | ) { 134 | qqreadtimeURL = process.env.QQREAD_TIMEURL.split(COOKIES_SPLIT); 135 | } else { 136 | qqreadtimeURL = process.env.QQREAD_TIMEURL.split(); 137 | } 138 | 139 | if ( 140 | process.env.QQREAD_TIMEHD && 141 | process.env.QQREAD_TIMEHD.indexOf(COOKIES_SPLIT) > -1 142 | ) { 143 | qqreadtimeHD = process.env.QQREAD_TIMEHD.split(COOKIES_SPLIT); 144 | } else { 145 | qqreadtimeHD = process.env.QQREAD_TIMEHD.split(); 146 | } 147 | } 148 | 149 | if (COOKIE.qqreadbodyVal) { 150 | QQ_READ_COOKIES = { 151 | "qqreadbodyVal": COOKIE.qqreadbodyVal.split('\n'), 152 | "qqreadtimeurlVal": COOKIE.qqreadtimeurlVal.split('\n'), 153 | "qqreadtimeheaderVal": COOKIE.qqreadtimeheaderVal.split('\n') 154 | } 155 | 156 | Length = QQ_READ_COOKIES.qqreadbodyVal.length; 157 | } 158 | 159 | 160 | if (!COOKIE.qqreadbodyVal) { 161 | 162 | if ($.isNode()) { 163 | Object.keys(qqreadBD).forEach((item) => { 164 | if (qqreadBD[item]) { 165 | qqreadbdArr.push(qqreadBD[item]); 166 | } 167 | }); 168 | Object.keys(qqreadtimeURL).forEach((item) => { 169 | if (qqreadtimeURL[item]) { 170 | qqreadtimeurlArr.push(qqreadtimeURL[item]); 171 | } 172 | }); 173 | Object.keys(qqreadtimeHD).forEach((item) => { 174 | if (qqreadtimeHD[item]) { 175 | qqreadtimehdArr.push(qqreadtimeHD[item]); 176 | } 177 | }); 178 | } else { 179 | qqreadbdArr.push($.getdata("qqreadbd")); 180 | qqreadtimeurlArr.push($.getdata("qqreadtimeurl")); 181 | qqreadtimehdArr.push($.getdata("qqreadtimehd")); 182 | // 根据boxjs中设置的额外账号数,添加存在的账号数据进行任务处理 183 | if ("qeCASH") { 184 | CASH = $.getval("qeCASH"); 185 | } 186 | const qeCount = ($.getval("qeCount") || "1") - 0; 187 | for (let i = 2; i <= qeCount; i++) { 188 | if ($.getdata(`qqreadbd${i}`)) { 189 | qqreadbdArr.push($.getdata(`qqreadbd${i}`)); 190 | qqreadtimeurlArr.push($.getdata(`qqreadtimeurl${i}`)); 191 | qqreadtimehdArr.push($.getdata(`qqreadtimehd${i}`)); 192 | } 193 | } 194 | } 195 | Length = qqreadbdArr.length 196 | } 197 | 198 | if ((isGetCookie = typeof $request !== "undefined")) { 199 | GetCookie(); 200 | $.done(); 201 | } 202 | 203 | function GetCookie() { 204 | if ($request && $request.url.indexOf("addReadTimeWithBid?") >= 0) { 205 | const qqreadtimeurlVal = $request.url; 206 | if (qqreadtimeurlVal) $.setdata(qqreadtimeurlVal, `qqreadtimeurl${$.idx}`); 207 | $.log( 208 | `[${jsname + $.idx 209 | }] 获取时长url: 成功,qqreadtimeurlVal: ${qqreadtimeurlVal}` 210 | ); 211 | $.msg(jsname + $.idx, `获取时长url: 成功🎉`, ``); 212 | const qqreadtimeheaderVal = JSON.stringify($request.headers); 213 | if (qqreadtimeheaderVal) 214 | $.setdata(qqreadtimeheaderVal, `qqreadtimehd${$.idx}`); 215 | $.log( 216 | `[${jsname + $.idx 217 | }] 获取时长header: 成功,qqreadtimeheaderVal: ${qqreadtimeheaderVal}` 218 | ); 219 | $.msg(jsname + $.idx, `获取时长header: 成功🎉`, ``); 220 | } else if ( 221 | $request && 222 | $request.body.indexOf("bookDetail_bottomBar_read_C") >= 0 && 223 | $request.body.indexOf("bookRead_show_I") >= 0 && 224 | $request.body.indexOf("topBar_left_back_C") < 0 && 225 | $request.body.indexOf("bookRead_dropOut_shelfYes_C") < 0 226 | ) { 227 | const qqreadbodyVal = $request.body; 228 | if (qqreadbodyVal) $.setdata(qqreadbodyVal, `qqreadbd${$.idx}`); 229 | $.log( 230 | `[${jsname + $.idx}] 获取更新body: 成功,qqreadbodyVal: ${qqreadbodyVal}` 231 | ); 232 | $.msg(jsname + $.idx, `获取更新body: 成功🎉`, ``); 233 | } 234 | } 235 | 236 | console.log( 237 | `================== 脚本执行 - 北京时间(UTC+8):${new Date( 238 | new Date().getTime() + 239 | new Date().getTimezoneOffset() * 60 * 1000 + 240 | 8 * 60 * 60 * 1000 241 | ).toLocaleString()} =====================\n` 242 | ); 243 | 244 | console.log( 245 | `============ 共 ${Length} 个${jsname}账号=============\n` 246 | ); 247 | 248 | console.log(`============ 提现标准为:${CASH} =============\n`); 249 | 250 | 251 | !(async () => { 252 | 253 | await all(); 254 | 255 | })() 256 | .catch((e) => { 257 | $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') 258 | }) 259 | .finally(() => { 260 | $.done(); 261 | }) 262 | 263 | async function all() { 264 | 265 | if (!Length) { 266 | $.msg( 267 | jsname, 268 | "⚠️提示:您还未获取cookie,请点击前往获取cookie\n", 269 | "https://m.q.qq.com/a/s/d3eacc70120b9a37e46bad408c0c4c2a", 270 | { "open-url": "https://m.q.qq.com/a/s/d3eacc70120b9a37e46bad408c0c4c2a" } 271 | ); 272 | $.done(); 273 | } 274 | 275 | for (let i = 0; i < Length; i++) { 276 | if (COOKIE.qqreadbodyVal) { 277 | qqreadbodyVal = QQ_READ_COOKIES.qqreadbodyVal[i]; 278 | qqreadtimeurlVal = QQ_READ_COOKIES.qqreadtimeurlVal[i]; 279 | qqreadtimeheaderVal = QQ_READ_COOKIES.qqreadtimeheaderVal[i]; 280 | } 281 | if (!COOKIE.qqreadbodyVal) { 282 | qqreadbodyVal = qqreadbdArr[i]; 283 | qqreadtimeurlVal = qqreadtimeurlArr[i]; 284 | qqreadtimeheaderVal = qqreadtimehdArr[i]; 285 | 286 | } 287 | O = (`${jsname + (i + 1)}🔔`); 288 | tz = ''; 289 | kz = ''; 290 | let cookie_is_live = await qqreadinfo(i + 1);//用户名 291 | if (!cookie_is_live) { 292 | continue; 293 | } 294 | if (BOX == 0) { 295 | await qqreadtrack();//更新 296 | await qqreadconfig();//时长查询 297 | await qqreadwktime();//周时长查询 298 | if (config.data && config.data.pageParams.todayReadSeconds / 3600 <= maxtime) { 299 | await qqreadtime();// 上传时长 300 | } 301 | if (wktime.data && wktime.data.readTime >= wktimess && wktime.data.readTime <= 1250) { 302 | await qqreadpick();//领周时长奖励 303 | } 304 | await qqreadtask();//任务列表 305 | if (task.data && ljyd.doneFlag == 0) { 306 | await qqreaddayread();//阅读任务 307 | } 308 | if (ydrw.doneFlag == 0 && config.data && config.data.pageParams.todayReadSeconds / 60 >= 1) { 309 | await qqreadssr1();//阅读金币1 310 | } 311 | if (task.data && dk.doneFlag == 0) { 312 | await qqreadsign();//金币签到 313 | await qqreadtake();//阅豆签到 314 | } 315 | await $.wait(4000) 316 | if (ydrw.doneFlag == 0 && config.data && config.data.pageParams.todayReadSeconds / 60 >= 30) { 317 | await qqreadssr2();//阅读金币2 318 | await $.wait(4000); 319 | await qqreadssr3();//阅读金币3 320 | } 321 | if (nowTimes.getHours() >= 23 && (nowTimes.getMinutes() >= 0 && nowTimes.getMinutes() <= 59)) { 322 | if (CASH >= 1 && task.data && task.data.user.amount >= CASH * 10000) { 323 | await qqreadwithdraw();//提现 324 | } 325 | } 326 | if (nowTimes.getHours() >= 6) { 327 | await getAmounts();//今日收益累计 328 | } 329 | if (task.data && dk.doneFlag == 0) { 330 | await qqreadsign2(); 331 | }//签到翻倍 332 | if (task.data && sp.doneFlag == 0) { 333 | await qqreadvideo();//视频奖励 334 | } 335 | 336 | } 337 | 338 | 339 | if (BOX == 1) { 340 | 341 | if (nowTimes.getHours() === 0 && (nowTimes.getMinutes() >= 0 && nowTimes.getMinutes() <= 59)) { 342 | await qqreadtrack();//更新 343 | } 344 | await qqreadtask();//任务列表 345 | if (task.data && ljyd.doneFlag == 0) { 346 | await qqreaddayread();//阅读任务 347 | } 348 | if (task.data && task.data.treasureBox.timeInterval <= 10000) { 349 | await $.wait(task.data.treasureBox.timeInterval) 350 | await qqreadbox();//宝箱 351 | } 352 | if (task.data && task.data.treasureBox.timeInterval - 600000 <= 10000) { 353 | await $.wait(task.data.treasureBox.timeInterval - 600000) 354 | await qqreadbox2();//宝箱翻倍 355 | } 356 | } 357 | 358 | if (BOX == 2) { 359 | await qqreadtrack();//更新 360 | await qqreadconfig();//时长查询 361 | await qqreadwktime();//周时长查询 362 | if (config.data && config.data.pageParams.todayReadSeconds / 3600 <= maxtime) { 363 | await qqreadtime();// 上传时长 364 | } 365 | if (wktime.data && wktime.data.readTime >= wktimess && wktime.data.readTime <= 1250) { 366 | await qqreadpick();//领周时长奖励 367 | } 368 | await qqreadtask();//任务列表 369 | if (task.data && ljyd.doneFlag == 0) { 370 | await qqreaddayread();//阅读任务 371 | } 372 | if (ydrw.doneFlag == 0 && config.data && config.data.pageParams.todayReadSeconds / 60 >= 1) { 373 | await qqreadssr1();//阅读金币1 374 | } 375 | if (task.data && dk.doneFlag == 0) { 376 | await qqreadsign();//金币签到 377 | await qqreadtake();//阅豆签到 378 | } 379 | if (task.data && task.data.treasureBox.timeInterval <= 10000) { 380 | await $.wait(task.data.treasureBox.timeInterval) 381 | await qqreadbox();//宝箱 382 | await $.wait(4000) 383 | await qqreadbox2();//宝箱翻倍 384 | } 385 | if (ydrw.doneFlag == 0 && config.data && config.data.pageParams.todayReadSeconds / 60 >= 30) { 386 | await qqreadssr2();//阅读金币2 387 | await $.wait(4000); 388 | await qqreadssr3();//阅读金币3 389 | } 390 | if (nowTimes.getHours() >= 23 && (nowTimes.getMinutes() >= 0 && nowTimes.getMinutes() <= 59)) { 391 | if (CASH >= 1 && task.data && task.data.user.amount >= CASH * 10000) { 392 | await qqreadwithdraw();//提现 393 | } 394 | } 395 | if (nowTimes.getHours() >= 6) { 396 | await getAmounts();//今日收益累计 397 | } 398 | if (task.data && dk.doneFlag == 0) { 399 | await qqreadsign2(); 400 | }//签到翻倍 401 | if (task.data && sp.doneFlag == 0) { 402 | await qqreadvideo();//视频奖励 403 | } 404 | 405 | } 406 | 407 | await showmsg();//通知 408 | 409 | } 410 | } 411 | 412 | 413 | function showmsg() { 414 | return new Promise(async resolve => { 415 | if (BOX != 1) { 416 | if (notifyInterval != 1) { 417 | console.log(O + '\n' + tz); 418 | } 419 | 420 | if (notifyInterval == 1) { 421 | $.msg(O, "", tz); 422 | } 423 | if (notifyInterval == 2 && (nowTimes.getHours() === 12 || nowTimes.getHours() === 23) && (nowTimes.getMinutes() >= 0 && nowTimes.getMinutes() <= 10)) { 424 | $.msg(O, "", tz); 425 | } 426 | if (notifyInterval == 3 && (nowTimes.getHours() === 6 || nowTimes.getHours() === 12 || nowTimes.getHours() === 18 || nowTimes.getHours() === 23) && (nowTimes.getMinutes() >= 0 && nowTimes.getMinutes() <= 10)) { 427 | $.msg(O, "", tz); 428 | } 429 | 430 | if (notifyttt == 1 && $.isNode() && (nowTimes.getHours() === 12 || nowTimes.getHours() === 23) && (nowTimes.getMinutes() >= 0 && nowTimes.getMinutes() <= 10)) 431 | await notify.sendNotify(O, tz); 432 | 433 | } 434 | if (BOX == 1) { 435 | if (notifyInterval != 1) { 436 | console.log(O + '\n' + kz); 437 | } 438 | 439 | if (notifyInterval == 1) { 440 | $.msg(O, "", kz); 441 | } 442 | if (notifyInterval == 2 && (nowTimes.getHours() === 12 || nowTimes.getHours() === 23) && (nowTimes.getMinutes() >= 0 && nowTimes.getMinutes() <= 10)) { 443 | $.msg(O, "", kz); 444 | } 445 | if (notifyInterval == 3 && (nowTimes.getHours() === 6 || nowTimes.getHours() === 12 || nowTimes.getHours() === 18 || nowTimes.getHours() === 23) && (nowTimes.getMinutes() >= 0 && nowTimes.getMinutes() <= 10)) { 446 | $.msg(O, "", kz); 447 | } 448 | 449 | if (notifyttt == 1 && $.isNode() && (nowTimes.getHours() === 12 || nowTimes.getHours() === 23) && (nowTimes.getMinutes() >= 0 && nowTimes.getMinutes() <= 10)) 450 | await notify.sendNotify(O, kz); 451 | 452 | } 453 | resolve() 454 | }) 455 | } 456 | 457 | 458 | // 更新 459 | function qqreadtrack() { 460 | return new Promise((resolve, reject) => { 461 | const body = qqreadbodyVal.replace(new RegExp(/"dis":[0-9]{13}/), `"dis":${new Date().getTime()}`) 462 | const toqqreadtrackurl = { 463 | url: "https://mqqapi.reader.qq.com/log/v4/mqq/track", 464 | headers: JSON.parse(qqreadtimeheaderVal), 465 | body: body, 466 | timeout: 60000, 467 | }; 468 | $.post(toqqreadtrackurl, (error, response, data) => { 469 | if (logs) $.log(`${O}, 更新: ${data}`); 470 | let track = JSON.parse(data); 471 | var date = new Date(JSON.parse(qqreadbodyVal).dataList[0].dis); 472 | Y = date.getFullYear() + '-'; 473 | M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-'; 474 | D = date.getDate() + ' '; 475 | h = date.getHours() + ':'; 476 | m = date.getMinutes() + ':'; 477 | s = date.getSeconds(); 478 | time=Y+M+D+h+m+s; 479 | tz += `【数据更新】:更新${track.msg},\n【cookie获取时间】${time}\n`; 480 | kz += `【数据更新】:更新${track.msg},\n【cookie获取时间】${time}\n`; 481 | resolve(); 482 | }); 483 | }); 484 | } 485 | // 用户名 486 | function qqreadinfo() { 487 | return new Promise((resolve, reject) => { 488 | const toqqreadinfourl = { 489 | url: "https://mqqapi.reader.qq.com/mqq/user/init", 490 | headers: JSON.parse(qqreadtimeheaderVal), 491 | timeout: 60000, 492 | }; 493 | $.get(toqqreadinfourl, (error, response, data) => { 494 | if (logs) $.log(`${O}, 用户名: ${data}`); 495 | let info = JSON.parse(data); 496 | if (!info.data.user) { 497 | let cookie_not_live_message = new Date( 498 | new Date().getTime() + 499 | new Date().getTimezoneOffset() * 60 * 1000 + 500 | 8 * 60 * 60 * 1000 501 | ).toLocaleString() + "❌❌❌COOKIE失效"; 502 | if(BOX!=1){ 503 | $.msg(O, cookie_not_live_message); 504 | if($.isNode()){ 505 | notify.sendNotify(O, cookie_not_live_message); 506 | } 507 | } 508 | resolve(false); 509 | } else { 510 | tz += `\n========== 【${info.data.user.nickName}】 ==========\n`; 511 | kz += `\n========== 【${info.data.user.nickName}】 ==========\n`; 512 | resolve(true); 513 | } 514 | }); 515 | }); 516 | } 517 | // 任务列表 518 | function qqreadtask() { 519 | return new Promise((resolve, reject) => { 520 | const toqqreadtaskurl = { 521 | url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/page?fromGuid=", 522 | headers: JSON.parse(qqreadtimeheaderVal), 523 | timeout: 60000, 524 | }; 525 | $.get(toqqreadtaskurl, (error, response, data) => { 526 | if (logs) $.log(`${O}, 任务列表: ${data}`); 527 | task = JSON.parse(data); 528 | dk = task.data.taskList.find(item => item.type === 200); 529 | ljyd = task.data.taskList.find(item => item.type === 210); 530 | ydrw = task.data.taskList.find(item => item.type === 220); 531 | sp = task.data.taskList.find(item => item.type === 230); 532 | 533 | if (task.data.invite.nextInviteConfig) { 534 | tz += 535 | `【现金余额】:${(task.data.user.amount / 10000).toFixed(2)}元\n` + 536 | `【第${task.data.invite.issue}期】:时间${task.data.invite.dayRange}\n` + 537 | ` 已邀请${task.data.invite.inviteCount}人,再邀请${task.data.invite.nextInviteConfig.count}人获得${task.data.invite.nextInviteConfig.amount}金币\n` + 538 | `【${dk.title}】:${dk.amount}金币,${dk.actionText}\n` + 539 | `【${ljyd.title}】:${ljyd.amount}金币,${ljyd.actionText}\n` + 540 | `【${ydrw.title}】:${ydrw.amount}金币,${ydrw.actionText}\n` + 541 | `【${sp.title}】:${sp.amount}金币,${sp.actionText}\n` + 542 | `【宝箱任务${task.data.treasureBox.count + 1}】:${task.data.treasureBox.timeInterval / 1000 543 | }秒后领取\n` + 544 | `【${task.data.fans.title}】:${task.data.fans.fansCount}个好友,${task.data.fans.todayAmount}金币\n`; 545 | } 546 | 547 | kz += 548 | `【现金余额】:${(task.data.user.amount / 10000).toFixed(2)}元\n` + 549 | `【宝箱任务${task.data.treasureBox.count + 1}】:${task.data.treasureBox.timeInterval / 1000 550 | }秒后领取\n` + 551 | `【已开宝箱】:${task.data.treasureBox.count}个\n`; 552 | 553 | resolve(); 554 | }); 555 | }); 556 | } 557 | // 每日阅读 558 | function qqreaddayread() { 559 | return new Promise((resolve, reject) => { 560 | const toqqreaddayreadurl = { 561 | url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/read_book", 562 | headers: JSON.parse(qqreadtimeheaderVal), 563 | timeout: 60000, 564 | }; 565 | $.get(toqqreaddayreadurl, (error, response, data) => { 566 | if (logs) $.log(`${O}, 每日阅读: ${data}`); 567 | let dayread = JSON.parse(data); 568 | if (dayread.code == 0) { 569 | tz += `【每日阅读】:获得${dayread.data.amount}金币\n`; 570 | kz += `【每日阅读】:获得${dayread.data.amount}金币\n`; 571 | } 572 | resolve(); 573 | }); 574 | }); 575 | } 576 | // 金币签到 577 | function qqreadsign() { 578 | return new Promise((resolve, reject) => { 579 | const toqqreadsignurl = { 580 | url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/clock_in", 581 | headers: JSON.parse(qqreadtimeheaderVal), 582 | timeout: 60000, 583 | }; 584 | $.get(toqqreadsignurl, (error, response, data) => { 585 | if (logs) $.log(`${O}, 金币签到: ${data}`); 586 | sign = JSON.parse(data); 587 | if (sign.code == 0) { 588 | tz += `【金币签到】:获得${sign.data.amount}金币\n`; 589 | kz += `【金币签到】:获得${sign.data.amount}金币\n`; 590 | } 591 | resolve(); 592 | }); 593 | }); 594 | } 595 | // 金币签到翻倍 596 | function qqreadsign2() { 597 | return new Promise((resolve, reject) => { 598 | const toqqreadsign2url = { 599 | url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/clock_in_video", 600 | headers: JSON.parse(qqreadtimeheaderVal), 601 | timeout: 60000, 602 | }; 603 | $.get(toqqreadsign2url, (error, response, data) => { 604 | if (logs) $.log(`${O}, 金币签到翻倍: ${data}`); 605 | let sign2 = JSON.parse(data); 606 | if (sign2.code == 0) { 607 | tz += `【签到翻倍】:获得${sign2.data.amount}金币\n`; 608 | kz += `【签到翻倍】:获得${sign2.data.amount}金币\n`; 609 | } 610 | resolve(); 611 | }); 612 | }); 613 | } 614 | // 视频奖励 615 | function qqreadvideo() { 616 | return new Promise((resolve, reject) => { 617 | const toqqreadvideourl = { 618 | url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/watch_video", 619 | headers: JSON.parse(qqreadtimeheaderVal), 620 | timeout: 60000, 621 | }; 622 | $.get(toqqreadvideourl, (error, response, data) => { 623 | if (logs) $.log(`${O}, 视频奖励: ${data}`); 624 | let video = JSON.parse(data); 625 | if (video.code == 0) { 626 | tz += `【视频奖励】:获得${video.data.amount}金币\n`; 627 | kz += `【视频奖励】:获得${video.data.amount}金币\n`; 628 | } 629 | resolve(); 630 | }); 631 | }); 632 | } 633 | // 阅读金币1 634 | function qqreadssr1() { 635 | return new Promise((resolve, reject) => { 636 | const toqqreadssr1url = { 637 | url: `https://mqqapi.reader.qq.com/mqq/red_packet/user/read_time?seconds=30`, 638 | headers: JSON.parse(qqreadtimeheaderVal), 639 | timeout: 60000, 640 | }; 641 | 642 | $.get(toqqreadssr1url, (error, response, data) => { 643 | if (logs) $.log(`${O}, 金币奖励1: ${data}`); 644 | let ssr1 = JSON.parse(data); 645 | if (ssr1.data.amount > 0) { 646 | tz += `【阅读金币1】获得${ssr1.data.amount}金币\n`; 647 | kz += `【阅读金币1】获得${ssr1.data.amount}金币\n`; 648 | } 649 | }); 650 | 651 | resolve(); 652 | }); 653 | } 654 | // 阅读金币2 655 | function qqreadssr2() { 656 | return new Promise((resolve, reject) => { 657 | const toqqreadssr2url = { 658 | url: `https://mqqapi.reader.qq.com/mqq/red_packet/user/read_time?seconds=300`, 659 | headers: JSON.parse(qqreadtimeheaderVal), 660 | timeout: 60000, 661 | }; 662 | 663 | $.get(toqqreadssr2url, (error, response, data) => { 664 | if (logs) $.log(`${O}, 金币奖励2: ${data}`); 665 | ssr2 = JSON.parse(data); 666 | if (ssr2.data.amount > 0) { 667 | tz += `【阅读金币2】获得${ssr2.data.amount}金币\n`; 668 | kz += `【阅读金币2】获得${ssr2.data.amount}金币\n`; 669 | } 670 | }); 671 | 672 | resolve(); 673 | }); 674 | } 675 | // 阅读金币3 676 | function qqreadssr3() { 677 | return new Promise((resolve, reject) => { 678 | const toqqreadssr3url = { 679 | url: `https://mqqapi.reader.qq.com/mqq/red_packet/user/read_time?seconds=1800`, 680 | headers: JSON.parse(qqreadtimeheaderVal), 681 | timeout: 60000, 682 | }; 683 | 684 | $.get(toqqreadssr3url, (error, response, data) => { 685 | if (logs) $.log(`${O}, 金币奖励3: ${data}`); 686 | let ssr3 = JSON.parse(data); 687 | if (ssr3.data.amount > 0) { 688 | tz += `【阅读金币3】获得${ssr3.data.amount}金币\n`; 689 | kz += `【阅读金币3】获得${ssr3.data.amount}金币\n`; 690 | } 691 | }); 692 | 693 | resolve(); 694 | }); 695 | } 696 | // 阅豆签到 697 | function qqreadtake() { 698 | return new Promise((resolve, reject) => { 699 | const toqqreadtakeurl = { 700 | url: "https://mqqapi.reader.qq.com/mqq/sign_in/user", 701 | headers: JSON.parse(qqreadtimeheaderVal), 702 | timeout: 60000, 703 | }; 704 | $.post(toqqreadtakeurl, (error, response, data) => { 705 | if (logs) $.log(`${O}, 阅豆签到: ${data}`); 706 | let take = JSON.parse(data); 707 | if (take.data.takeTicket > 0) { 708 | tz += `【阅豆签到】:获得${take.data.takeTicket}豆\n`; 709 | kz += `【阅豆签到】:获得${take.data.takeTicket}豆\n`; 710 | } 711 | resolve(); 712 | }); 713 | }); 714 | } 715 | // 阅读时长任务 716 | function qqreadconfig() { 717 | return new Promise((resolve, reject) => { 718 | const toqqreadconfigurl = { 719 | url: 720 | "https://mqqapi.reader.qq.com/mqq/page/config?router=%2Fpages%2Fbook-read%2Findex&options=", 721 | headers: JSON.parse(qqreadtimeheaderVal), 722 | }; 723 | $.get(toqqreadconfigurl, (error, response, data) => { 724 | if (logs) $.log(`${O}, 阅读时长查询: ${data}`); 725 | config = JSON.parse(data); 726 | if (config.code == 0) { 727 | tz += `【时长查询】:今日阅读${( 728 | config.data.pageParams.todayReadSeconds / 60 729 | ).toFixed(0)}分钟\n`; 730 | kz += `【时长查询】:今日阅读${( 731 | config.data.pageParams.todayReadSeconds / 60 732 | ).toFixed(0)}分钟\n`; 733 | } 734 | 735 | resolve(); 736 | }); 737 | }); 738 | } 739 | // 阅读时长 740 | function qqreadtime() { 741 | return new Promise((resolve, reject) => { 742 | do TIME = Math.floor(Math.random() * 35); 743 | while (TIME < 25) 744 | const toqqreadtimeurl = { 745 | url: qqreadtimeurlVal.replace(/readTime=/g, `readTime=${TIME}`), 746 | headers: JSON.parse(qqreadtimeheaderVal), 747 | }; 748 | $.get(toqqreadtimeurl, (error, response, data) => { 749 | if (logs) $.log(`${O}, 阅读时长: ${data}`); 750 | let time = JSON.parse(data); 751 | if (time.code == 0) { 752 | tz += `【阅读时长】:上传${(TIME / 6).toFixed(1)}分钟\n`; 753 | kz += `【阅读时长】:上传${(TIME / 6).toFixed(1)}分钟\n`; 754 | } 755 | resolve(); 756 | }); 757 | }); 758 | } 759 | // 宝箱奖励 760 | function qqreadbox() { 761 | return new Promise((resolve, reject) => { 762 | const toqqreadboxurl = { 763 | url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/treasure_box", 764 | headers: JSON.parse(qqreadtimeheaderVal), 765 | timeout: 60000, 766 | }; 767 | $.get(toqqreadboxurl, (error, response, data) => { 768 | if (logs) $.log(`${O}, 宝箱奖励: ${data}`); 769 | let box = JSON.parse(data); 770 | if (box.code == 0 && box.data.amount) { 771 | tz += `【宝箱奖励${box.data.count}】:获得${box.data.amount}金币\n`; 772 | kz += `【宝箱奖励${box.data.count}】:获得${box.data.amount}金币\n`; 773 | } 774 | 775 | resolve(); 776 | }); 777 | }); 778 | } 779 | // 宝箱奖励翻倍 780 | function qqreadbox2() { 781 | return new Promise((resolve, reject) => { 782 | const toqqreadbox2url = { 783 | url: 784 | "https://mqqapi.reader.qq.com/mqq/red_packet/user/treasure_box_video", 785 | headers: JSON.parse(qqreadtimeheaderVal), 786 | timeout: 60000, 787 | }; 788 | $.get(toqqreadbox2url, (error, response, data) => { 789 | if (logs) $.log(`${O}, 宝箱奖励翻倍: ${data}`); 790 | let box2 = JSON.parse(data); 791 | if (box2.code == 0 && box2.data.amount) { 792 | tz += `【宝箱翻倍】:获得${box2.data.amount}金币\n`; 793 | kz += `【宝箱翻倍】:获得${box2.data.amount}金币\n`; 794 | } 795 | resolve(); 796 | }); 797 | }); 798 | } 799 | // 本周阅读时长 800 | function qqreadwktime() { 801 | return new Promise((resolve, reject) => { 802 | const toqqreadwktimeurl = { 803 | url: `https://mqqapi.reader.qq.com/mqq/v1/bookShelfInit`, 804 | headers: JSON.parse(qqreadtimeheaderVal), 805 | }; 806 | $.get(toqqreadwktimeurl, (error, response, data) => { 807 | if (logs) $.log(`${O}, 本周阅读时长: ${data}`); 808 | wktime = JSON.parse(data); 809 | if (wktime.code == 0) { 810 | tz += `【本周阅读时长】:${wktime.data.readTime}分钟\n`; 811 | kz += `【本周阅读时长】:${wktime.data.readTime}分钟\n`; 812 | } 813 | resolve(); 814 | }); 815 | }); 816 | } 817 | // 本周阅读时长奖励任务 818 | function qqreadpick() { 819 | return new Promise((resolve, reject) => { 820 | const toqqreadpickurl = { 821 | url: `https://mqqapi.reader.qq.com/mqq/pickPackageInit`, 822 | headers: JSON.parse(qqreadtimeheaderVal), 823 | }; 824 | 825 | $.get(toqqreadpickurl, (error, response, data) => { 826 | if (logs) $.log(`${O},周阅读时长奖励任务: ${data}`); 827 | let pick = JSON.parse(data); { 828 | if (pick.data[7].isPick == true) 829 | tz += "【周时长奖励】:已全部领取\n"; 830 | kz += "【周时长奖励】:已全部领取\n"; 831 | } 832 | 833 | for (let i = 0; i < pick.data.length; i++) { 834 | setTimeout(() => { 835 | const pickid = pick.data[i].readTime; 836 | const Packageid = [ 837 | "10", 838 | "10", 839 | "20", 840 | "30", 841 | "50", 842 | "80", 843 | "100", 844 | "120", 845 | ]; 846 | const toqqreadPackageurl = { 847 | url: `https://mqqapi.reader.qq.com/mqq/pickPackage?readTime=${pickid}`, 848 | headers: JSON.parse(qqreadtimeheaderVal), 849 | timeout: 60000, 850 | }; 851 | $.get(toqqreadPackageurl, (error, response, data) => { 852 | if (logs) $.log(`${O}, 领周阅读时长奖励: ${data}`); 853 | Package = JSON.parse(data); 854 | if (Package.code == 0) { 855 | tz += `【周时长奖励${i + 1}】:领取${Packageid[i]}阅豆\n`; 856 | kz += `【周时长奖励${i + 1}】:领取${Packageid[i]}阅豆\n`; 857 | } 858 | }); 859 | }, i * 100); 860 | } 861 | }); 862 | resolve(); 863 | 864 | resolve(); 865 | }); 866 | } 867 | //提现 868 | function qqreadwithdraw() { 869 | return new Promise((resolve, reject) => { 870 | const toqqreadwithdrawurl = { 871 | url: `https://mqqapi.reader.qq.com/mqq/red_packet/user/withdraw?amount=${CASH * 10000}`, 872 | headers: JSON.parse(qqreadtimeheaderVal), 873 | timeout: 60000, 874 | }; 875 | $.post(toqqreadwithdrawurl, (error, response, data) => { 876 | if (logs) $.log(`${O}, 提现: ${data}`); 877 | let withdraw = JSON.parse(data); 878 | if (withdraw.data.code == 0) { 879 | tz += `【现金提现】:成功提现${CASH}元\n`; 880 | kz += `【现金提现】:成功提现${CASH}元\n`; 881 | } 882 | resolve(); 883 | }); 884 | }); 885 | } 886 | // 统计金币 887 | async function getAmounts() { 888 | let page = 1 889 | let amounts = 0 890 | while (true) { 891 | const { total, isEnd } = await getTodayAmount(page) 892 | amounts += total 893 | if (isEnd) { 894 | break 895 | } else { 896 | page++ 897 | await $.wait(200) 898 | } 899 | } 900 | if (logs) $.log(`${O}, 今日收益: ${amounts}金币,约${(amounts / 10000.0).toFixed(2)}元.`); 901 | tz += `【今日收益】:获得${amounts}金币,约${(amounts / 10000.0).toFixed(2)}元.\n` 902 | kz += `【今日收益】:获得${amounts}金币,约${(amounts / 10000.0).toFixed(2)}元.\n` 903 | } 904 | 905 | function getTodayAmount(page = 1) { 906 | return new Promise((r, j) => { 907 | const options = { 908 | url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/trans/list?pn=" + page, 909 | headers: JSON.parse(qqreadtimeheaderVal), 910 | timeout: 60000, 911 | } 912 | $.get(options, (error, response, data) => { 913 | const obj = JSON.parse(data) 914 | let isEnd = obj.data.list.length == 0 915 | let total = 0 916 | for (let index = 0; index < obj.data.list.length; index++) { 917 | const element = obj.data.list[index]; 918 | if (element.createTime < daytime){ 919 | isEnd = true 920 | break 921 | } 922 | total += element.amount 923 | } 924 | r({ total, isEnd }) 925 | }) 926 | }) 927 | } 928 | 929 | 930 | // prettier-ignore 931 | function Env(t, e) { class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `\ud83d\udd14${this.name}, \u5f00\u59cb!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), a = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(a, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t) { let e = { "M+": (new Date).getMonth() + 1, "d+": (new Date).getDate(), "H+": (new Date).getHours(), "m+": (new Date).getMinutes(), "s+": (new Date).getSeconds(), "q+": Math.floor(((new Date).getMonth() + 3) / 3), S: (new Date).getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, ((new Date).getFullYear() + "").substr(4 - RegExp.$1.length))); for (let s in e) new RegExp("(" + s + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? e[s] : ("00" + e[s]).substr(("" + e[s]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))); let h = ["", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="]; h.push(e), s && h.push(s), i && h.push(i), console.log(h.join("\n")), this.logs = this.logs.concat(h) } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `\u2757\ufe0f${this.name}, \u9519\u8bef!`, t.stack) : this.log("", `\u2757\ufe0f${this.name}, \u9519\u8bef!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } 932 | --------------------------------------------------------------------------------