Skip to content

Add ability to remove 'text' node #165

@AdamWr

Description

@AdamWr

Related to - #106
Another issue when it could be useful - AdguardTeam/AdguardFilters#146786
AdguardTeam/AdguardFilters#146872


Test page - https://jsfiddle.net/yehz25L4/

Code:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
  </head>
  <body>
    <div id='test'> Advertisement <p> Test </p>
      <p> 1234 </p>
      <p> qwerty </p>
    </div>
  </body>
</html>

Rule which should remove text Advertisement:

fiddle.jshell.net#$?#:xpath(//div[contains(@id,"test")]/text()[contains(.,'Advertisement')]) { remove: true; }

ExtendedCss.query which should match element:

ExtendedCss.query(`:xpath(//div[contains(@id,"test")]/text()[contains(.,'Advertisement')])`)

I might be wrong, but I guess that it doesn't work currently, because isHtmlElement

export const isHtmlElement = (element: HTMLElement | Node | null): element is HTMLElement => {
return element instanceof HTMLElement;
};

returns false for text node and probably due to this, element is not matched.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions