{"id":13459405,"url":"https://github.com/antonmedv/finder","last_synced_at":"2025-05-13T00:17:01.545Z","repository":{"id":199511558,"uuid":"122220871","full_name":"antonmedv/finder","owner":"antonmedv","description":"CSS Selector Generator 🗺","archived":false,"fork":false,"pushed_at":"2024-12-13T15:46:01.000Z","size":297,"stargazers_count":1413,"open_issues_count":20,"forks_count":97,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-13T00:16:49.373Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antonmedv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"antonmedv"}},"created_at":"2018-02-20T16:02:13.000Z","updated_at":"2025-04-30T20:14:04.000Z","dependencies_parsed_at":"2024-06-18T12:17:23.314Z","dependency_job_id":"ec63441f-f19c-4f36-90fd-d935fde00580","html_url":"https://github.com/antonmedv/finder","commit_stats":{"total_commits":79,"total_committers":11,"mean_commits":7.181818181818182,"dds":"0.20253164556962022","last_synced_commit":"81377fca1d6ec8fa6c3b4f07b76a85cf83dab85b"},"previous_names":["antonmedv/finder"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmedv%2Ffinder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmedv%2Ffinder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmedv%2Ffinder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmedv%2Ffinder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antonmedv","download_url":"https://codeload.github.com/antonmedv/finder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253843225,"owners_count":21972874,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T09:01:20.528Z","updated_at":"2025-05-13T00:17:01.519Z","avatar_url":"https://github.com/antonmedv.png","language":"HTML","funding_links":["https://github.com/sponsors/antonmedv"],"categories":["HTML","CSS"],"sub_categories":[],"readme":"# finder\n\n![finder](https://medv.io/assets/finder.png)\n\n**The CSS Selector Generator**\n\n[![Test](https://github.com/antonmedv/finder/actions/workflows/test.yml/badge.svg)](https://github.com/antonmedv/finder/actions/workflows/test.yml)\n[![JSR](https://jsr.io/badges/@medv/finder)](https://jsr.io/@medv/finder)\n\n## Features\n\n* Generates **shortest** CSS selectors\n* **Unique** CSS selectors per page\n* Stable and **robust** CSS selectors\n* Size: **1.5kb** (minified \u0026 gzipped)\n\n## Install\n\n```bash\nnpm install @medv/finder\n```\n\n## Usage \n\n```ts\nimport { finder } from '@medv/finder';\n\ndocument.addEventListener('click', (event) =\u003e {\n  const selector = finder(event.target);\n});\n```\n\n## Example\n\nAn example of a generated selector:\n\n```css\n.blog \u003e article:nth-of-type(3) .add-comment\n```\n\n## Configuration\n\n```js\nconst selector = finder(event.target, {\n  root: document.body,\n  timeoutMs: 1000,\n});\n```\n\n### root\n\nDefines the root of the search. Defaults to `document.body`.\n\n### timeoutMs\n\nTimeout to search for a selector. Defaults to `1000ms`. After the timeout, finder fallbacks to `nth-child` selectors.\n\n### className\n\nFunction that determines if a class name may be used in a selector. Defaults to a word-like class names.\n\nYou can extend the default behaviour wrapping the `className` function:\n\n```js\nimport { finder, className } from '@medv/finder';\n\nfinder(event.target, {\n  className: name =\u003e className(name) || name.startsWith('my-class-'),\n});\n```\n\n### tagName\n\nFunction that determines if a tag name may be used in a selector. Defaults to `() =\u003e true`.\n\n### attr\n\nFunction that determines if an attribute may be used in a selector. Defaults to a word-like attribute names and values.\n\nYou can extend the default behaviour wrapping the `attr` function:\n\n```js\nimport { finder, attr } from '@medv/finder';\n\nfinder(event.target, {\n  attr: (name, value) =\u003e attr(name, value) || name.startsWith('data-my-attr-'),\n});\n```\n\n### idName\n\nFunction that determines if an id name may be used in a selector. Defaults to a word-like id names.\n\n### seedMinLength\n\nMinimum length of levels in fining selector. Defaults to `3`.\n\n### optimizedMinLength\n\nMinimum length for optimising selector. Defaults to `2`.\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonmedv%2Ffinder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonmedv%2Ffinder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonmedv%2Ffinder/lists"}