Update jd_unsubscribe.js
parent
c8c3da3bc3
commit
e0dfbf049c
|
@ -1,7 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* @Author: X1a0He
|
* @Author: X1a0He
|
||||||
* @Date: 2021-09-04 11:50:47
|
|
||||||
* @LastEditTime: 2021-11-10 22:30:00
|
|
||||||
* @LastEditors: X1a0He
|
* @LastEditors: X1a0He
|
||||||
* @Description: 批量取关京东店铺和商品
|
* @Description: 批量取关京东店铺和商品
|
||||||
* @Fixed: 不再支持Qx,仅支持Node.js
|
* @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);
|
cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item);
|
||||||
}
|
}
|
||||||
let args_xh = {
|
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
|
* 是否执行取消关注,默认true
|
||||||
* 可通过环境变量控制:JD_UNSUB
|
* 可通过环境变量控制:JD_UNSUB
|
||||||
* */
|
* */
|
||||||
isRun: process.env.JD_UNSUB || true,
|
isRun: process.env.JD_UNSUB === 'true' || true,
|
||||||
/*
|
/*
|
||||||
* 执行完毕是否进行通知,默认false
|
* 执行完毕是否进行通知,默认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
|
* 可设置环境变量:JD_UNSUB_GPAGESIZE,默认为20,不建议超过20
|
||||||
|
@ -60,7 +65,7 @@ let args_xh = {
|
||||||
* 是否打印日志
|
* 是否打印日志
|
||||||
* 可用环境变量控制:JD_UNSUB_PLOG,默认为true
|
* 可用环境变量控制:JD_UNSUB_PLOG,默认为true
|
||||||
* */
|
* */
|
||||||
printLog: process.env.JD_UNSUB_PLOG || true,
|
printLog: process.env.JD_UNSUB_PLOG === 'true' || true,
|
||||||
/*
|
/*
|
||||||
* 失败次数,当取关商品或店铺时,如果连续 x 次失败,则结束本次取关,防止死循环
|
* 失败次数,当取关商品或店铺时,如果连续 x 次失败,则结束本次取关,防止死循环
|
||||||
* 可用环境变量控制:JD_UNSUB_FAILTIMES,默认为3次
|
* 可用环境变量控制:JD_UNSUB_FAILTIMES,默认为3次
|
||||||
|
@ -85,6 +90,10 @@ let args_xh = {
|
||||||
$.nickName = '';
|
$.nickName = '';
|
||||||
await TotalBean();
|
await TotalBean();
|
||||||
console.log(`\n****开始【京东账号${$.index}】${$.nickName || $.UserName}*****\n`);
|
console.log(`\n****开始【京东账号${$.index}】${$.nickName || $.UserName}*****\n`);
|
||||||
|
if(args_xh.except.includes($.UserName)){
|
||||||
|
console.log(`跳过账号:${$.nickName || $.UserName}`)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if(!$.isLogin){
|
if(!$.isLogin){
|
||||||
$.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {
|
$.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"
|
"open-url": "https://bean.m.jd.com/bean/signIndex.action"
|
||||||
|
@ -104,17 +113,17 @@ let args_xh = {
|
||||||
$.shopIdList = ``;
|
$.shopIdList = ``;
|
||||||
$.endGoods = $.endShops = false;
|
$.endGoods = $.endShops = false;
|
||||||
$.failTimes = 0;
|
$.failTimes = 0;
|
||||||
console.log(`=====京东账号${$.index} ${$.nickName || $.UserName}内部变量=====`)
|
// console.log(`=====京东账号${$.index} ${$.nickName || $.UserName}内部变量=====`)
|
||||||
console.log(`$.unsubscribeGoodsNum: ${$.unsubscribeGoodsNum}`)
|
// console.log(`$.unsubscribeGoodsNum: ${$.unsubscribeGoodsNum}`)
|
||||||
console.log(`$.unsubscribeShopsNum: ${$.unsubscribeShopsNum}`)
|
// console.log(`$.unsubscribeShopsNum: ${$.unsubscribeShopsNum}`)
|
||||||
console.log(`$.goodsTotalNum: ${$.goodsTotalNum}`)
|
// console.log(`$.goodsTotalNum: ${$.goodsTotalNum}`)
|
||||||
console.log(`$.shopsTotalNum: ${$.shopsTotalNum}`)
|
// console.log(`$.shopsTotalNum: ${$.shopsTotalNum}`)
|
||||||
console.log(`$.commIdList: ${$.commIdList}`)
|
// console.log(`$.commIdList: ${$.commIdList}`)
|
||||||
console.log(`$.shopIdList: ${$.shopIdList}`)
|
// console.log(`$.shopIdList: ${$.shopIdList}`)
|
||||||
console.log(`$.failTimes: ${$.failTimes}`)
|
// console.log(`$.failTimes: ${$.failTimes}`)
|
||||||
console.log(`================`)
|
// console.log(`================`)
|
||||||
await favCommQueryFilter(); //获取商品并过滤
|
await favCommQueryFilter(); //获取商品并过滤
|
||||||
await $.wait(1000)
|
await $.wait(args_xh.unSubscribeInterval)
|
||||||
if(!$.endGoods && parseInt($.goodsTotalNum) !== parseInt($.goodsKeyWordsNum)) await favCommBatchDel();//取关商品
|
if(!$.endGoods && parseInt($.goodsTotalNum) !== parseInt($.goodsKeyWordsNum)) await favCommBatchDel();//取关商品
|
||||||
else console.log("不执行取消收藏商品\n")
|
else console.log("不执行取消收藏商品\n")
|
||||||
await $.wait(args_xh.unSubscribeInterval)
|
await $.wait(args_xh.unSubscribeInterval)
|
||||||
|
@ -165,10 +174,8 @@ let args_xh = {
|
||||||
function requireConfig(){
|
function requireConfig(){
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
if($.isNode() && process.env.JD_UNSUB){
|
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('=====环境变量配置如下=====')
|
||||||
|
console.log(`except: ${typeof args_xh.except}, ${args_xh.except}`)
|
||||||
console.log(`isNotify: ${typeof args_xh.isNotify}, ${args_xh.isNotify}`)
|
console.log(`isNotify: ${typeof args_xh.isNotify}, ${args_xh.isNotify}`)
|
||||||
console.log(`goodPageSize: ${typeof args_xh.goodPageSize}, ${args_xh.goodPageSize}`)
|
console.log(`goodPageSize: ${typeof args_xh.goodPageSize}, ${args_xh.goodPageSize}`)
|
||||||
console.log(`shopPageSize: ${typeof args_xh.shopPageSize}, ${args_xh.shopPageSize}`)
|
console.log(`shopPageSize: ${typeof args_xh.shopPageSize}, ${args_xh.shopPageSize}`)
|
||||||
|
|
Loading…
Reference in New Issue