MCPcopy Create free account
hub / github.com/Semporia/Scripts / requireConfig

Function requireConfig

jd_try.js:102–170  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

100 }).finally(() => $.done())
101
102function requireConfig() {
103 return new Promise(resolve => {
104 console.log('开始获取配置文件\n')
105 $.notify = $.isNode() ? require('./sendNotify') : {sendNotify:async () => {}}
106
107 //获取 Cookies
108 $.cookiesArr = []
109 if ($.isNode()) {
110 //Node.js用户请在jdCookie.js处填写京东ck;
111 const jdCookieNode = require('./jdCookie.js');
112 Object.keys(jdCookieNode).forEach((item) => {
113 if (jdCookieNode[item]) {
114 $.cookiesArr.push(jdCookieNode[item])
115 }
116 })
117 if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {};
118 } else {
119 //IOS等用户直接用NobyDa的jd $.cookie
120 $.cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item);
121 }
122 console.log(`共${$.cookiesArr.length}个京东账号\n`)
123
124 if ($.isNode()) {
125 if (process.env.JD_TRY_CIDS_KEYS) {
126 args.cidsList = process.env.JD_TRY_CIDS_KEYS.split('@').filter(key => {
127 return Object.keys(cidsMap).includes(key)
128 })
129 }
130 if (process.env.JD_TRY_TYPE_KEYS) {
131 args.typeList = process.env.JD_TRY_TYPE_KEYS.split('@').filter(key => {
132 return Object.keys(typeMap).includes(key)
133 })
134 }
135 if (process.env.JD_TRY_GOOD_FILTERS) {
136 args.goodFilters = process.env.JD_TRY_GOOD_FILTERS.split('@')
137 }
138 if (process.env.JD_TRY_MIN_PRICE) {
139 args.minPrice = process.env.JD_TRY_MIN_PRICE * 1
140 }
141 if (process.env.JD_TRY_PAGE_SIZE) {
142 args.pageSize = process.env.JD_TRY_PAGE_SIZE * 1
143 }
144 if (process.env.JD_TRY_MAX_SUPPLY_COUNT) {
145 args.maxSupplyCount = process.env.JD_TRY_MAX_SUPPLY_COUNT * 1
146 }
147 } else {
148 let qxCidsList = []
149 let qxTypeList = []
150 const cidsKeys = Object.keys(cidsMap)
151 const typeKeys = Object.keys(typeMap)
152 for (let key of cidsKeys) {
153 const open = $.getdata(key)
154 if (open == 'true') qxCidsList.push(key)
155 }
156 for (let key of typeKeys) {
157 const open = $.getdata(key)
158 if (open == 'true') qxTypeList.push(key)
159 }

Callers 1

jd_try.jsFile · 0.70

Calls 4

jsonParseFunction · 0.70
logMethod · 0.45
isNodeMethod · 0.45
getdataMethod · 0.45

Tested by

no test coverage detected