Skip to content

Commit

Permalink
feat: temporarily remove html parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Feb 25, 2024
1 parent ff9cc1c commit e6079ea
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
10 changes: 1 addition & 9 deletions src/lib/rsshub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,12 @@ import { parse } from "tldts"
import { parseRules } from "./rules"
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) {
const run = () => {
let resultWithParams
if (typeof rule.target === "function") {
try {
const template = parseHtml(html)
resultWithParams = rule.target(params, url, template.content)
template.remove()
resultWithParams = rule.target(params, url)
} catch (error) {
resultWithParams = ""
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export type Rule = {
title: string
docs: string
source: string[]
target: string | ((params: any, url: string, document: DocumentFragment) => string)
target: string | ((params: any, url: string) => string)
}

export type Rules = {
Expand Down

2 comments on commit e6079ea

@cubroe
Copy link

@cubroe cubroe commented on e6079ea Mar 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. What's the vision for this removal? Is it going to be restored soon or is there going to be a replacing scheme that supports Radar-ing feeds based on a page's DOM content? (With only URL components, whether from the source array (thus the params parameter) or the url parameter, looks not flexible enough to accommodate very generic routes.)

@DIYgod
Copy link
Owner Author

@DIYgod DIYgod commented on e6079ea Mar 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cubroe Currently all known DOM parsing methods will cause memory leaks in Chrome, which is a long-standing bug in Chrome. https://twitter.com/DIYgod/status/1761065494185156663

Please sign in to comment.