diff --git a/.eslintrc.json b/.eslintrc.json index 135a2c5..04d4583 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -29,6 +29,7 @@ "plugin:jest/recommended" ], "rules": { + "no-extra-semi": "off", "camelcase": "off", "no-console": "off", "no-unused-vars": "off", diff --git a/package.json b/package.json index 62d49e4..218fc42 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ }, "scripts": { "build": "tsc", + "start": "powershell -Command \"node dist/index.js generate-all CodingWithCalvin --upload --token $(gh auth token)\"", "format:write": "npx prettier --write .", "format:check": "npx prettier --check .", "lint": "npx eslint src --ext .ts,.tsx", diff --git a/src/browser.ts b/src/browser.ts index 3c584bb..44adae9 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -90,7 +90,10 @@ export async function uploadSocialPreviewViaBrowser( const editClicked = await page.evaluate(() => { const summaries = document.querySelectorAll('summary, button') for (const el of summaries) { - if (el.textContent?.includes('Edit') && el.closest('[class*="social"]')) { + if ( + el.textContent?.includes('Edit') && + el.closest('[class*="social"]') + ) { ;(el as HTMLElement).click() return true } @@ -132,13 +135,17 @@ export async function uploadSocialPreviewViaBrowser( // Look for and click save button const buttons = await page.$$('button[type="submit"], button') for (const button of buttons) { - const text = await button.evaluate( - el => el.textContent?.toLowerCase() || '' - ) - if (text.includes('save') || text.includes('update')) { - await button.click() - await delay(2000) - break + try { + const text = await button.evaluate( + el => el.textContent?.toLowerCase() || '' + ) + if (text.includes('save') || text.includes('update')) { + await button.click() + await delay(2000) + break + } + } catch { + // Skip buttons that aren't clickable } } @@ -256,13 +263,17 @@ export async function uploadAllViaBrowser( // Look for and click save button const buttons = await page.$$('button[type="submit"], button') for (const button of buttons) { - const text = await button.evaluate( - el => el.textContent?.toLowerCase() || '' - ) - if (text.includes('save') || text.includes('update')) { - await button.click() - await delay(2000) - break + try { + const text = await button.evaluate( + el => el.textContent?.toLowerCase() || '' + ) + if (text.includes('save') || text.includes('update')) { + await button.click() + await delay(2000) + break + } + } catch { + // Skip buttons that aren't clickable } }