Merge branch 'master' of github.com:okyyds/yydspure

yyds 2022-02-11 20:42:40 +08:00
commit 326571943d
1 changed files with 26 additions and 19 deletions

View File

@ -1,7 +1,5 @@
/*
* @Author: X1a0He
* @Date: 2021-09-04 11:50:47
* @LastEditTime: 2021-11-10 22:30:00
* @LastEditors: X1a0He
* @Description: 批量取关京东店铺和商品
* @Fixed: 不再支持Qx仅支持Node.js
@ -21,16 +19,23 @@ if($.isNode()){
cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item);
}
let args_xh = {
/*
* 跳过某个指定账号默认为全部账号清空
* 填写规则例如当前Cookie1为pt_key=key; pt_pin=pin1;则环境变量填写pin1即可此时pin1的购物车将不会被清空
* 若有更多则按照pin1@pin2@pin3进行填写
* 环境变量名称XH_UNSUB_EXCEPT
*/
except: process.env.XH_UNSUB_EXCEPT && process.env.XH_UNSUB_EXCEPT.split('@') || [],
/*
* 是否执行取消关注默认true
* 可通过环境变量控制JD_UNSUB
* */
isRun: process.env.JD_UNSUB || true,
isRun: process.env.JD_UNSUB === 'true' || true,
/*
* 执行完毕是否进行通知默认false
* 可用环境变量控制JD_TRY_PLOG
* 可用环境变量控制JD_UNSUB_NOTIFY
* */
isNotify: process.env.JD_UNSEB_NOTIFY || false,
isNotify: process.env.JD_UNSUB_NOTIFY === 'true' || false,
/*
* 每次获取已关注的商品数
* 可设置环境变量JD_UNSUB_GPAGESIZE默认为20不建议超过20
@ -60,7 +65,7 @@ let args_xh = {
* 是否打印日志
* 可用环境变量控制JD_UNSUB_PLOG默认为true
* */
printLog: process.env.JD_UNSUB_PLOG || true,
printLog: process.env.JD_UNSUB_PLOG === 'true' || true,
/*
* 失败次数当取关商品或店铺时如果连续 x 次失败则结束本次取关防止死循环
* 可用环境变量控制JD_UNSUB_FAILTIMES默认为3次
@ -85,6 +90,10 @@ let args_xh = {
$.nickName = '';
await TotalBean();
console.log(`\n****开始【京东账号${$.index}${$.nickName || $.UserName}*****\n`);
if(args_xh.except.includes($.UserName)){
console.log(`跳过账号:${$.nickName || $.UserName}`)
continue
}
if(!$.isLogin){
$.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {
"open-url": "https://bean.m.jd.com/bean/signIndex.action"
@ -104,17 +113,17 @@ let args_xh = {
$.shopIdList = ``;
$.endGoods = $.endShops = false;
$.failTimes = 0;
console.log(`=====京东账号${$.index} ${$.nickName || $.UserName}内部变量=====`)
console.log(`$.unsubscribeGoodsNum: ${$.unsubscribeGoodsNum}`)
console.log(`$.unsubscribeShopsNum: ${$.unsubscribeShopsNum}`)
console.log(`$.goodsTotalNum: ${$.goodsTotalNum}`)
console.log(`$.shopsTotalNum: ${$.shopsTotalNum}`)
console.log(`$.commIdList: ${$.commIdList}`)
console.log(`$.shopIdList: ${$.shopIdList}`)
console.log(`$.failTimes: ${$.failTimes}`)
console.log(`================`)
// console.log(`=====京东账号${$.index} ${$.nickName || $.UserName}内部变量=====`)
// console.log(`$.unsubscribeGoodsNum: ${$.unsubscribeGoodsNum}`)
// console.log(`$.unsubscribeShopsNum: ${$.unsubscribeShopsNum}`)
// console.log(`$.goodsTotalNum: ${$.goodsTotalNum}`)
// console.log(`$.shopsTotalNum: ${$.shopsTotalNum}`)
// console.log(`$.commIdList: ${$.commIdList}`)
// console.log(`$.shopIdList: ${$.shopIdList}`)
// console.log(`$.failTimes: ${$.failTimes}`)
// console.log(`================`)
await favCommQueryFilter(); //获取商品并过滤
await $.wait(1000)
await $.wait(args_xh.unSubscribeInterval)
if(!$.endGoods && parseInt($.goodsTotalNum) !== parseInt($.goodsKeyWordsNum)) await favCommBatchDel();//取关商品
else console.log("不执行取消收藏商品\n")
await $.wait(args_xh.unSubscribeInterval)
@ -165,10 +174,8 @@ let args_xh = {
function requireConfig(){
return new Promise(resolve => {
if($.isNode() && process.env.JD_UNSUB){
args_xh.isRun = process.env.JD_UNSUB === 'true';
args_xh.isNotify = process.env.JD_UNSEB_NOTIFY === 'true';
args_xh.printLog = process.env.JD_UNSUB_PLOG === 'true';
console.log('=====环境变量配置如下=====')
console.log(`except: ${typeof args_xh.except}, ${args_xh.except}`)
console.log(`isNotify: ${typeof args_xh.isNotify}, ${args_xh.isNotify}`)
console.log(`goodPageSize: ${typeof args_xh.goodPageSize}, ${args_xh.goodPageSize}`)
console.log(`shopPageSize: ${typeof args_xh.shopPageSize}, ${args_xh.shopPageSize}`)