feat: pagination in google

This commit is contained in:
Artemy 2023-08-17 17:58:09 +03:00
parent e2ba8c8e05
commit f99504fe7d
2 changed files with 27 additions and 1 deletions

View File

@ -44,8 +44,30 @@ export default async function google(
</form>
`;
const navLinks = [
...window.document.querySelectorAll(
"table[class=AaVjTc] > tbody > tr > td > a"
),
].map((l) => {
const link = l as HTMLAnchorElement;
return `<td><a href="${link.href}">${link.innerHTML}</a></td>`;
});
const currPage = (
window.document.querySelector(".YyVfkd") as HTMLTableCellElement
).cellIndex;
const pageTd = `<td>${currPage}</td>`;
if (currPage === 1) navLinks.splice(currPage - 1, 0, pageTd);
else navLinks.splice(currPage, 0, pageTd);
const navigation = `<table>
<tbody><tr>${navLinks.join("")}</tr></tbody>
</table>`;
return {
content: `${searchForm}${content.join("")}`,
content: `${searchForm}${content.join("")}${navigation}`,
textContent: textContent.join("\n"),
title: window.document.title,
lang: window.document.documentElement.lang,

View File

@ -62,3 +62,7 @@ main {
background: var(--bg2);
color: var(--fg);
}
a {
text-decoration: none;
}