Adapted engines to work with HandlerInput
This commit is contained in:
parent
456a472031
commit
bbbfe480eb
@ -1,12 +1,14 @@
|
||||
import { DOMWindow } from "jsdom";
|
||||
import { HandlerInput } from "./handler-input";
|
||||
import { IHandlerOutput } from "./handler.interface";
|
||||
import { EngineParseError } from "../errors/main";
|
||||
|
||||
export default async function google(
|
||||
window: DOMWindow,
|
||||
input: HandlerInput,
|
||||
): Promise<IHandlerOutput> {
|
||||
const document = input.parseDom().window.document;
|
||||
|
||||
const googleAnchors = [
|
||||
...window.document.querySelectorAll("a[jsname=ACyKwe]"),
|
||||
...document.querySelectorAll("a[jsname=ACyKwe]"),
|
||||
] as HTMLAnchorElement[];
|
||||
|
||||
if (!googleAnchors) {
|
||||
|
@ -2,15 +2,12 @@ import { IHandlerOutput } from "./handler.interface";
|
||||
import { Engines, EngineFunction, EnginesMatch } from "../types/handlers";
|
||||
import axios from "../types/axios";
|
||||
|
||||
import { JSDOM } from "jsdom";
|
||||
|
||||
import micromatch from "micromatch";
|
||||
|
||||
import readability from "./readability";
|
||||
import google, { GoogleDomains } from "./google";
|
||||
import stackoverflow, { StackOverflowDomains } from "./stackoverflow/main";
|
||||
|
||||
import { generateProxyUrl } from "../utils/generate";
|
||||
import isLocalResource from "../utils/islocal";
|
||||
|
||||
import { LocalResourceError, NotHtmlMimetypeError } from "../errors/main";
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { Readability } from "@mozilla/readability";
|
||||
import { HandlerInput } from "./handler-input";
|
||||
import { IHandlerOutput } from "./handler.interface";
|
||||
import { DOMWindow } from "jsdom";
|
||||
import { EngineParseError } from "../errors/main";
|
||||
|
||||
export default async function readability(
|
||||
window: DOMWindow
|
||||
input: HandlerInput,
|
||||
): Promise<IHandlerOutput> {
|
||||
const reader = new Readability(window.document);
|
||||
const reader = new Readability(input.parseDom().window.document);
|
||||
const parsed = reader.parse();
|
||||
|
||||
if (!parsed) {
|
||||
|
@ -1,13 +1,14 @@
|
||||
import { HandlerInput } from "../handler-input";
|
||||
import { IHandlerOutput } from "../handler.interface";
|
||||
import { DOMWindow } from "jsdom";
|
||||
import { EngineParseError } from "../../errors/main";
|
||||
import qPostsHandler from "./questions-posts";
|
||||
|
||||
export default async function stackoverflow(
|
||||
window: DOMWindow,
|
||||
input: HandlerInput,
|
||||
): Promise<IHandlerOutput> {
|
||||
const url = new URL(window.location.href);
|
||||
const window = input.parseDom().window;
|
||||
|
||||
const url = new URL(window.location.href);
|
||||
const path = url.pathname.split("/").filter((p) => p !== "");
|
||||
|
||||
let result: IHandlerOutput = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user