feat: temporarily remove html parsing
This commit is contained in:
parent
ff9cc1cc2f
commit
e6079ea1a8
|
|
@ -4,20 +4,12 @@ import { parse } from "tldts"
|
||||||
import { parseRules } from "./rules"
|
import { parseRules } from "./rules"
|
||||||
import type { RSSData, Rule } from "./types"
|
import type { RSSData, Rule } from "./types"
|
||||||
|
|
||||||
const parseHtml = (html) => {
|
|
||||||
const template = document.createElement('template');
|
|
||||||
template.innerHTML = html;
|
|
||||||
return template;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ruleHandler(rule: Rule, params, url, html, success, fail) {
|
function ruleHandler(rule: Rule, params, url, html, success, fail) {
|
||||||
const run = () => {
|
const run = () => {
|
||||||
let resultWithParams
|
let resultWithParams
|
||||||
if (typeof rule.target === "function") {
|
if (typeof rule.target === "function") {
|
||||||
try {
|
try {
|
||||||
const template = parseHtml(html)
|
resultWithParams = rule.target(params, url)
|
||||||
resultWithParams = rule.target(params, url, template.content)
|
|
||||||
template.remove()
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
resultWithParams = ""
|
resultWithParams = ""
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ export type Rule = {
|
||||||
title: string
|
title: string
|
||||||
docs: string
|
docs: string
|
||||||
source: string[]
|
source: string[]
|
||||||
target: string | ((params: any, url: string, document: DocumentFragment) => string)
|
target: string | ((params: any, url: string) => string)
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Rules = {
|
export type Rules = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue