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

Function changeFile

jd_bean_sign.js:152–170  ·  view source on GitHub ↗
(content)

Source from the content-addressed store, hash-verified

150}
151
152async function changeFile (content) {
153 console.log(`开始替换变量`)
154 let newContent = content.replace(/var Key = '.*'/, `var Key = '${cookie}'`);
155 newContent = newContent.replace(/const NodeSet = 'CookieSet.json'/, `const NodeSet = '${NodeSet}'`)
156 if (process.env.JD_BEAN_STOP && process.env.JD_BEAN_STOP !== '0') {
157 newContent = newContent.replace(/var stop = '0'/, `var stop = '${process.env.JD_BEAN_STOP}'`);
158 }
159 const zone = new Date().getTimezoneOffset();
160 if (zone === 0) {
161 //此处针对UTC-0时区用户做的
162 newContent = newContent.replace(/tm\s=.*/, `tm = new Date(new Date().toLocaleDateString()).getTime() - 28800000;`);
163 }
164 try {
165 await fs.writeFileSync(JD_DailyBonusPath, newContent, 'utf8');
166 console.log('替换变量完毕');
167 } catch (e) {
168 console.log("京东签到写入文件异常:" + e);
169 }
170}
171async function deleteFile(path) {
172 // 查看文件result.txt是否存在,如果存在,先删除
173 const fileExists = await fs.existsSync(path);

Callers 1

jd_bean_sign.jsFile · 0.85

Calls 1

logMethod · 0.45

Tested by

no test coverage detected