Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yuyz0112/content-finder

DOM selector generator with content awareness
https://github.com/yuyz0112/content-finder

Last synced: about 1 month ago
JSON representation

DOM selector generator with content awareness

Awesome Lists containing this project

README

        

# content-finder

Fork from https://github.com/antonmedv/finder

## What's the difference

### 1. return the path stack instead of the selector string

```html

Hello World


World
```

If we get the first `` element from this HTML with `finder`, it will return `p > span`.

With `content-finder` we will have:

```js
[{ name: "p", content: null }, { name: "span", content: null }];
```

### 2. use content as part of the selector

```html

foo


bar


```

If we get the first `

` element from this HTML with `finder`, it will return `p:nth-child(1)`.

With `content-finder` we wil have:

```js
[{ name: "p", content: "foo" }];
```

This means there is only one `


` element has the content `foo`. Comparing to the nth-child selector, the selector with content is more semantic.

Although content selector is not part of the standard CSS selector, there are some libraries/frameworks support query by content (e.g., jQuery, Cypress).