forked from akai/readest
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
export const walkTextNodes = (root: HTMLElement): HTMLElement[] => {
|
||||
export const walkTextNodes = (root: HTMLElement, rejectTags: string[] = []): HTMLElement[] => {
|
||||
const elements: HTMLElement[] = [];
|
||||
const walk = (node: HTMLElement | Document | ShadowRoot, depth = 0) => {
|
||||
if (depth > 15) return;
|
||||
@@ -7,7 +7,11 @@ export const walkTextNodes = (root: HTMLElement): HTMLElement[] => {
|
||||
}
|
||||
const children = 'children' in node ? (Array.from(node.children) as HTMLElement[]) : [];
|
||||
for (const child of children) {
|
||||
if (child.tagName === 'STYLE' || child.tagName === 'LINK') {
|
||||
if (
|
||||
child.tagName === 'STYLE' ||
|
||||
child.tagName === 'LINK' ||
|
||||
rejectTags.includes(child.tagName.toLowerCase())
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (child.shadowRoot) {
|
||||
|
||||
Reference in New Issue
Block a user