mirror of
https://github.com/txtdot/txtdot
synced 2024-10-18 14:40:19 +03:00
fix: google main page
This commit is contained in:
parent
b42036321e
commit
5a067089cc
@ -50,13 +50,6 @@ export default async function google(
|
||||
"APjFqb"
|
||||
) as HTMLTextAreaElement;
|
||||
|
||||
const searchForm = `
|
||||
<form onsubmit="window.location.href = '/get?url=https://www.google.com/search?q='+ document.getElementById('q').value.split(' ').join('+'); return false">
|
||||
<input type="text" name="q" id="q" value="${search?.value}">
|
||||
<input type="button" value="Search" onclick="window.location.href = '/get?url=https://www.google.com/search?q='+ document.getElementById('q').value.split(' ').join('+');">
|
||||
</form>
|
||||
`;
|
||||
|
||||
const navLinks = [
|
||||
...window.document.querySelectorAll(
|
||||
"table[class=AaVjTc] > tbody > tr > td > a"
|
||||
@ -66,21 +59,28 @@ export default async function google(
|
||||
return `<td><a href="${link.href}">${link.innerHTML}</a></td>`;
|
||||
});
|
||||
|
||||
const currPage = (
|
||||
window.document.querySelector(".YyVfkd") as HTMLTableCellElement
|
||||
).cellIndex;
|
||||
const currPage =
|
||||
(window.document.querySelector(".YyVfkd") as HTMLTableCellElement)
|
||||
?.cellIndex || 0;
|
||||
|
||||
const pageTd = `<td>${currPage}</td>`;
|
||||
|
||||
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 = `<table>
|
||||
<tbody><tr>${navLinks.join("")}</tr></tbody>
|
||||
</table>`;
|
||||
|
||||
const searchForm = `
|
||||
<form onsubmit="window.location.href = '/get?url=https://www.google.com/search?q='+ document.getElementById('q').value.split(' ').join('+'); return false">
|
||||
<input type="text" name="q" id="q" value="${search?.value}">
|
||||
<input type="button" value="Search" onclick="window.location.href = '/get?url=https://www.google.com/search?q='+ document.getElementById('q').value.split(' ').join('+');">
|
||||
</form>
|
||||
`;
|
||||
|
||||
return {
|
||||
content: `${searchForm}${content.join("")}${navigation}`,
|
||||
content: `${searchForm}${content.join("")}${navigation || ""}`,
|
||||
textContent: textContent.join("\n"),
|
||||
title: window.document.title,
|
||||
lang: window.document.documentElement.lang,
|
||||
|
Loading…
Reference in New Issue
Block a user