diff --git a/src/handlers/google.ts b/src/handlers/google.ts index 8501652..9caccf8 100644 --- a/src/handlers/google.ts +++ b/src/handlers/google.ts @@ -8,13 +8,13 @@ export default async function google( const googleAnchors = [ ...window.document.querySelectorAll("a[jsname=ACyKwe]"), ] as HTMLAnchorElement[]; - const googleNames = [...window.document.querySelectorAll(".VuuXrf")]; const results = googleAnchors - .map((a: HTMLAnchorElement, i: number): GoogleProps => { + .map((a: HTMLAnchorElement): GoogleProps => { + const parsedHref = new URL(new URL(a.href).searchParams.get("url")!); return { href: a.href!, - siteName: googleNames[i].textContent!, + siteName: parsedHref.hostname, heading: a.childNodes[1]?.textContent, }; }) @@ -26,12 +26,6 @@ export default async function google( ); } - if (!googleNames) { - throw new EngineParseError( - "Failed to find names in search result [google]" - ); - } - const convertToFormat = (result: GoogleProps, isHtml: boolean) => { return isHtml ? `

${result.siteName} - ${result.heading}

`