diff --git a/src/fb-pixel-lookup.ts b/src/fb-pixel-lookup.ts index 559e06f..5752d4d 100644 --- a/src/fb-pixel-lookup.ts +++ b/src/fb-pixel-lookup.ts @@ -15,6 +15,7 @@ export const FB_ADVANCED_MATCHING_PARAMETERS = { 'ud[country]': 'Country', 'ud[external_id]': 'An ID from another database.' }; + // https://web.archive.org/web/20200519201636/https://developers.facebook.com/docs/facebook-pixel/reference export const FB_STANDARD_EVENTS = [ { @@ -98,4 +99,3 @@ export const FB_STANDARD_EVENTS = [ eventName: 'ViewContent' } ]; -// const parseFacebookPixesParamete diff --git a/src/logger.ts b/src/logger.ts index ad39651..384a090 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -7,8 +7,6 @@ import { createLogger, format, transports } from 'winston'; export const getLogger = ({ outDir = '', quiet = false }) => { const log_transports = []; - let filename; - log_transports.push( new transports.Console({ level: 'info', @@ -16,7 +14,7 @@ export const getLogger = ({ outDir = '', quiet = false }) => { }) ); - filename = outDir ? path.join(outDir, 'inspection-log.ndjson') : tmpNameSync({ postfix: '-log.ndjson' }); + const filename = outDir ? path.join(outDir, 'inspection-log.ndjson') : tmpNameSync({ postfix: '-log.ndjson' }); log_transports.push( new transports.File({ diff --git a/src/pptr-utils/default.ts b/src/pptr-utils/default.ts index 8720c77..0a12bd0 100644 --- a/src/pptr-utils/default.ts +++ b/src/pptr-utils/default.ts @@ -2,6 +2,7 @@ import fs from 'fs'; import path from 'path'; import { Page } from 'puppeteer'; import { promisify } from 'util'; + const writeFile = promisify(fs.writeFile); export const savePageContent = async (index, outDir, page: Page, screenshot = true) => { @@ -17,6 +18,7 @@ export const savePageContent = async (index, outDir, page: Page, screenshot = tr console.log(`couldnt save page content: ${JSON.stringify(error)}`); } }; + /** * Default Puppeteer options for dev */ diff --git a/src/pptr-utils/interaction-utils.ts b/src/pptr-utils/interaction-utils.ts index 2f1f840..a77e533 100644 --- a/src/pptr-utils/interaction-utils.ts +++ b/src/pptr-utils/interaction-utils.ts @@ -39,10 +39,8 @@ export const fillForms = async (page: Page, timeout = 6000) => { const timeoutPromise = new Promise(resolve => { setTimeout(() => { if (isInteracting) { - // console.log('Interaction ongoing. Waiting for safe exit.'); return; } - // console.log('Timeout reached. Exiting fillForms().'); resolve('Timeout'); }, timeout); }); @@ -59,7 +57,6 @@ export const fillForms = async (page: Page, timeout = 6000) => { if (!page.isClosed()) { isInteracting = true; - // console.log(`Inspecting element ${count}`); if (count > 100) { break; } @@ -67,29 +64,22 @@ export const fillForms = async (page: Page, timeout = 6000) => { const pHandle = await el.getProperty('type'); const pValue = await pHandle.jsonValue(); - // console.log(`Input is type ${pValue}`); const autoCompleteHandle = await el.getProperty('autocomplete'); const autoCompleteValue = (await autoCompleteHandle.jsonValue()) as string; - // console.log(`Autocomplete attribute is: ${autoCompleteValue}`); let autoCompleteKeys = []; - // console.log('Checking autocomplete value'); if (autoCompleteValue) { if (autoCompleteValue.includes('cc-name')) { - // console.log('Autocomplete includes cc-name.'); autoCompleteKeys = ['cc-name']; } else { - // console.log('Autocomplete does not include cc-name.'); autoCompleteKeys = Object.keys(DEFAULT_INPUT_VALUES).filter(k => (autoCompleteValue as string).includes(k)); } } if (pValue === 'submit' || pValue === 'hidden') { - // console.log('Type is either submit or hidden.'); continue; } else if (autoCompleteKeys.length > 0) { - // console.log('Autocomplete keys > 0'); await el.focus(); await page.keyboard.press('Tab', { delay: 100 @@ -97,14 +87,12 @@ export const fillForms = async (page: Page, timeout = 6000) => { await el.press('Backspace'); await page.keyboard.type(DEFAULT_INPUT_VALUES[autoCompleteKeys[0] as string]); } else if (Object.keys(DEFAULT_INPUT_VALUES).includes(pValue as string)) { - // console.log('Default input values includes pValue'); await el.focus(); await page.keyboard.press('Tab', { delay: 100 }); await el.press('Backspace'); await page.keyboard.type(DEFAULT_INPUT_VALUES[pValue as string]); - // console.log(' ... done with test'); } isInteracting = false; } else { @@ -137,6 +125,7 @@ export const autoScroll = async page => { const distance = 150; const COUNT_MAX = 5; let count = 0; + const timer = setInterval(() => { const scrollHeight = document.body.scrollHeight; window.scrollBy(0, distance); diff --git a/src/types.ts b/src/types.ts index edac6e7..21a5f66 100644 --- a/src/types.ts +++ b/src/types.ts @@ -64,6 +64,7 @@ export interface LinkObject { innerHtml: string; innerText: string; } + export const SESSION_RECORDERS_LIST = [ 'mc.yandex.ru/metrika/watch.js', 'mc.yandex.ru/metrika/tag.js',