Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"plugin:jest/recommended"
],
"rules": {
"no-extra-semi": "off",
"camelcase": "off",
"no-console": "off",
"no-unused-vars": "off",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
41 changes: 26 additions & 15 deletions src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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
}
}

Expand Down