Skip to content

Commit b3831fb

Browse files
shadoathclaude
andcommitted
fix: Update Chrome Web Store crawler selector for user count
Google changed the CWS detail page DOM layout — a new "Add to Chrome" div was appended as the last child of the header section, causing the `div:last-child` selector to miss the user count element. The crawler threw on `weeklyActiveUsers` extraction, which nullified the entire extension entry in the GraphQL response. Replace the positional `div:last-child` selector with a text-content search for the div containing " users", making it resilient to future DOM reordering. Add a test fixture from the current (Apr 2026) CWS HTML. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 53371e3 commit b3831fb

2 files changed

Lines changed: 161 additions & 3 deletions

File tree

src/services/__tests__/fixtures/chrome-web-store/2026-04-17-hmdcmlfkchdmnmnmheododdhjedfccka.html

Lines changed: 150 additions & 0 deletions
Large diffs are not rendered by default.

src/services/chrome-crawler.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,17 @@ export async function crawlExtension(
6262

6363
const weeklyActiveUsersText = tryExtract("weeklyActiveUsers", validateInt, [
6464
() => {
65-
const userCountRow = document.querySelector(
66-
"main > * > section:first-child > section > div > div:last-child",
67-
) as HTMLElement | null;
65+
// Find the header div whose text contains " users" (resilient to DOM reordering)
66+
const headerDivs = document.querySelectorAll(
67+
"main > * > section:first-child > section > div > div",
68+
);
69+
let userCountRow: HTMLElement | null = null;
70+
for (const div of headerDivs) {
71+
if ((div as HTMLElement).textContent?.includes(" users")) {
72+
userCountRow = div as HTMLElement;
73+
break;
74+
}
75+
}
6876
removeAnchorChildren(userCountRow);
6977
return (
7078
userCountRow?.textContent

0 commit comments

Comments
 (0)