diff --git a/src/handlers/google.ts b/src/handlers/google.ts index 0e3f5c3..1a007cf 100644 --- a/src/handlers/google.ts +++ b/src/handlers/google.ts @@ -50,13 +50,6 @@ export default async function google( "APjFqb" ) as HTMLTextAreaElement; - const searchForm = ` -
- - -
- `; - const navLinks = [ ...window.document.querySelectorAll( "table[class=AaVjTc] > tbody > tr > td > a" @@ -66,21 +59,28 @@ export default async function google( return `${link.innerHTML}`; }); - const currPage = ( - window.document.querySelector(".YyVfkd") as HTMLTableCellElement - ).cellIndex; + const currPage = + (window.document.querySelector(".YyVfkd") as HTMLTableCellElement) + ?.cellIndex || 0; const pageTd = `${currPage}`; if (currPage === 1) navLinks.splice(currPage - 1, 0, pageTd); - else navLinks.splice(currPage, 0, pageTd); + else if (currPage !== 0) navLinks.splice(currPage, 0, pageTd); const navigation = `${navLinks.join("")}
`; + const searchForm = ` +
+ + +
+ `; + return { - content: `${searchForm}${content.join("")}${navigation}`, + content: `${searchForm}${content.join("")}${navigation || ""}`, textContent: textContent.join("\n"), title: window.document.title, lang: window.document.documentElement.lang,