mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 11:07:43 +00:00
chore: refactor config and fix audits (#406)
This commit is contained in:
+12
-12
@@ -1,16 +1,16 @@
|
||||
import {Config} from './config';
|
||||
import {Logger} from './logger';
|
||||
import {Stores} from './store/model';
|
||||
import {adBlocker} from './adblocker';
|
||||
import {config} from './config';
|
||||
import {fetchLinks} from './store/fetch-links';
|
||||
import {getSleepTime} from './util';
|
||||
import {logger} from './logger';
|
||||
import puppeteer from 'puppeteer-extra';
|
||||
import resourceBlock from 'puppeteer-extra-plugin-block-resources';
|
||||
import stealthPlugin from 'puppeteer-extra-plugin-stealth';
|
||||
import {tryLookupAndLoop} from './store';
|
||||
|
||||
puppeteer.use(stealthPlugin());
|
||||
if (Config.browser.lowBandwidth) {
|
||||
if (config.browser.lowBandwidth) {
|
||||
puppeteer.use(resourceBlock({
|
||||
blockedTypes: new Set(['image', 'font'])
|
||||
}));
|
||||
@@ -23,7 +23,7 @@ if (Config.browser.lowBandwidth) {
|
||||
*/
|
||||
async function main() {
|
||||
if (Stores.length === 0) {
|
||||
Logger.error('✖ no stores selected', Stores);
|
||||
logger.error('✖ no stores selected', Stores);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -31,28 +31,28 @@ async function main() {
|
||||
|
||||
// Skip Chromium Linux Sandbox
|
||||
// https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#setting-up-chrome-linux-sandbox
|
||||
if (Config.browser.isTrusted) {
|
||||
if (config.browser.isTrusted) {
|
||||
args.push('--no-sandbox');
|
||||
args.push('--disable-setuid-sandbox');
|
||||
}
|
||||
|
||||
// Add the address of the proxy server if defined
|
||||
if (Config.proxy.address) {
|
||||
args.push(`--proxy-server=http://${Config.proxy.address}:${Config.proxy.port}`);
|
||||
if (config.proxy.address) {
|
||||
args.push(`--proxy-server=http://${config.proxy.address}:${config.proxy.port}`);
|
||||
}
|
||||
|
||||
const browser = await puppeteer.launch({
|
||||
args,
|
||||
defaultViewport: {
|
||||
height: Config.page.height,
|
||||
width: Config.page.width
|
||||
height: config.page.height,
|
||||
width: config.page.width
|
||||
},
|
||||
headless: Config.browser.isHeadless
|
||||
headless: config.browser.isHeadless
|
||||
});
|
||||
|
||||
const promises = [];
|
||||
for (const store of Stores) {
|
||||
Logger.debug(store.links);
|
||||
logger.debug(store.links);
|
||||
if (store.setupAction !== undefined) {
|
||||
store.setupAction(browser);
|
||||
}
|
||||
@@ -73,6 +73,6 @@ async function main() {
|
||||
try {
|
||||
void main();
|
||||
} catch (error) {
|
||||
Logger.error('✖ something bad happened, resetting nvidia-snatcher', error);
|
||||
logger.error('✖ something bad happened, resetting nvidia-snatcher', error);
|
||||
void main();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user