migrate config file to json; read them via fs.

This commit is contained in:
bossgeekgo
2024-02-11 23:43:10 +08:00
parent 4e2904721d
commit f9761a47bb
11 changed files with 154 additions and 126 deletions
@@ -1,16 +1,35 @@
import puppeteer from 'puppeteer-extra';
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
import { cookies as bossCookies } from '../../config/boss.mjs'
import targetCompanyList from '../../config/target-company-list.mjs'
import {
sleep,
sleepWithRandomDelay
} from '@bossgeekgo/utils/sleep.mjs'
import fs from 'node:fs'
import { get__dirname } from '@bossgeekgo/utils/legacy-path.mjs';
import path from 'node:path';
puppeteer.use(StealthPlugin())
const { cookies: bossCookies } = JSON.parse(
fs.readFileSync(
path.join(
get__dirname(),
'../../config/boss.json'
)
)
)
const targetCompanyList = JSON.parse(
fs.readFileSync(
path.join(
get__dirname(),
'../../config/target-company-list.json'
)
)
)
if (!bossCookies?.length) {
console.error('There is no cookies. you can save a copy with EditThisCookie extension.')
process.exit(1)