commit
66ae5226b7
@ -1,6 +1,9 @@
|
|||||||
<h1 align="center">
|
<h1 align="center">
|
||||||
<a href="https://github.com/TxtDot/txtdot"><img src="https://github.com/TxtDot/.github/blob/main/imgs/TXTDot%20gh.png?raw=true" alt="txt." width="200"></a>
|
<a href="https://github.com/TxtDot/txtdot"><img src="https://github.com/TxtDot/.github/blob/main/imgs/TXTDot%20gh.png?raw=true" alt="txt." width="200"></a>
|
||||||
<br>
|
<br>
|
||||||
|
<a href="https://txtdot.github.io/documentation"><img alt="Documentation" src="https://img.shields.io/badge/Documentation-green"></a>
|
||||||
|
<a href="https://github.com/TxtDot/instances"><img alt="Instances" src="https://img.shields.io/badge/Instances-green"></a>
|
||||||
|
<br>
|
||||||
<a href="https://github.com/TxtDot/txtdot/blob/main/LICENSE"><img alt="MIT license" src="https://img.shields.io/github/license/txtdot/txtdot?color=blue"></a>
|
<a href="https://github.com/TxtDot/txtdot/blob/main/LICENSE"><img alt="MIT license" src="https://img.shields.io/github/license/txtdot/txtdot?color=blue"></a>
|
||||||
<a href="https://github.com/TxtDot/txtdot/releases/latest"><img alt="Latest release" src="https://img.shields.io/github/v/release/TxtDot/txtdot?display_name=release"></a>
|
<a href="https://github.com/TxtDot/txtdot/releases/latest"><img alt="Latest release" src="https://img.shields.io/github/v/release/TxtDot/txtdot?display_name=release"></a>
|
||||||
<a href="https://matrix.to/#/#txtdot:matrix.org"><img alt="Matrix chat" src="https://img.shields.io/badge/chat-matrix-blue"></a>
|
<a href="https://matrix.to/#/#txtdot:matrix.org"><img alt="Matrix chat" src="https://img.shields.io/badge/chat-matrix-blue"></a>
|
||||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "txtdot",
|
"name": "txtdot",
|
||||||
"version": "1.2.0",
|
"version": "1.3.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "txtdot",
|
"name": "txtdot",
|
||||||
"version": "1.2.0",
|
"version": "1.3.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/static": "^6.10.2",
|
"@fastify/static": "^6.10.2",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "txtdot",
|
"name": "txtdot",
|
||||||
"version": "1.2.0",
|
"version": "1.3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/app.js",
|
"main": "dist/app.js",
|
||||||
|
@ -3,17 +3,17 @@ import { IHandlerOutput } from "./handler.interface";
|
|||||||
import { EngineParseError } from "../errors/main";
|
import { EngineParseError } from "../errors/main";
|
||||||
|
|
||||||
export default async function google(
|
export default async function google(
|
||||||
input: HandlerInput,
|
input: HandlerInput
|
||||||
): Promise<IHandlerOutput> {
|
): Promise<IHandlerOutput> {
|
||||||
const window = input.parseDom().window;
|
const window = input.parseDom().window;
|
||||||
|
|
||||||
const googleAnchors = [
|
const googleAnchors = [
|
||||||
...window.document.querySelectorAll("a[jsname=ACyKwe]"),
|
...window.document.querySelectorAll("a[jsname=UWckNb]"),
|
||||||
] as HTMLAnchorElement[];
|
] as HTMLAnchorElement[];
|
||||||
|
|
||||||
if (!googleAnchors) {
|
if (!googleAnchors) {
|
||||||
throw new EngineParseError(
|
throw new EngineParseError(
|
||||||
"Failed to find anchors in search result [google]",
|
"Failed to find anchors in search result [google]"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,31 +43,9 @@ export default async function google(
|
|||||||
});
|
});
|
||||||
|
|
||||||
const search = window.document.getElementById(
|
const search = window.document.getElementById(
|
||||||
"APjFqb",
|
"APjFqb"
|
||||||
) as HTMLTextAreaElement;
|
) as HTMLTextAreaElement;
|
||||||
|
|
||||||
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 || 0;
|
|
||||||
|
|
||||||
const pageTd = `<td>${currPage}</td>`;
|
|
||||||
|
|
||||||
if (currPage === 1) navLinks.splice(currPage - 1, 0, pageTd);
|
|
||||||
else if (currPage !== 0) navLinks.splice(currPage, 0, pageTd);
|
|
||||||
|
|
||||||
const navigation = `<table>
|
|
||||||
<tbody><tr>${navLinks.join("")}</tr></tbody>
|
|
||||||
</table>`;
|
|
||||||
|
|
||||||
const searchForm = `
|
const searchForm = `
|
||||||
<form onsubmit="window.location.href = '/get?url=https://www.google.com/search?q='+ document.getElementById('q').value.split(' ').join('+'); return false">
|
<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="text" name="q" id="q" value="${search?.value}">
|
||||||
@ -76,7 +54,7 @@ export default async function google(
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: `${searchForm}${content.join("")}${navigation}`,
|
content: `${searchForm}${content.join("")}`,
|
||||||
textContent: textContent.join("\n"),
|
textContent: textContent.join("\n"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user