fix: google results

This commit is contained in:
Artemy 2023-08-18 11:09:02 +03:00
parent 944e42e857
commit 87cba82ee6
3 changed files with 9 additions and 9 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "txtdot", "name": "txtdot",
"version": "1.0.0", "version": "1.1.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "txtdot", "name": "txtdot",
"version": "1.0.0", "version": "1.1.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@fastify/static": "^6.10.2", "@fastify/static": "^6.10.2",

View File

@ -1,6 +1,6 @@
{ {
"name": "txtdot", "name": "txtdot",
"version": "1.0.0", "version": "1.1.1",
"private": true, "private": true,
"description": "", "description": "",
"main": "dist/app.js", "main": "dist/app.js",

View File

@ -10,15 +10,15 @@ export default async function google(
] as HTMLAnchorElement[]; ] as HTMLAnchorElement[];
const googleNames = [...window.document.querySelectorAll(".VuuXrf")]; const googleNames = [...window.document.querySelectorAll(".VuuXrf")];
const results = googleAnchors.map( const results = googleAnchors
(a: HTMLAnchorElement, i: number): GoogleProps => { .map((a: HTMLAnchorElement, i: number): GoogleProps => {
return { return {
href: a.href!, href: a.href!,
siteName: googleNames[i].textContent!, siteName: googleNames[i].textContent!,
heading: a.childNodes[1].textContent!, heading: a.childNodes[1]?.textContent,
}; };
} })
); .filter((a) => a.heading);
if (!googleAnchors) { if (!googleAnchors) {
throw new EngineParseError( throw new EngineParseError(
@ -90,5 +90,5 @@ export default async function google(
interface GoogleProps { interface GoogleProps {
href: string; href: string;
siteName: string; siteName: string;
heading: string; heading: string | null;
} }