# pick-html-element

> Creates an interface for picking HTML elements on any website.

Latest version **1.1.1** (published 2020-10-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install pick-html-element
pnpm add pick-html-element
yarn add pick-html-element
bun add pick-html-element
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2020-10-22 |
| First published | 2020-10-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=14.10.0 |
| Dependencies | 3 |
| Unpacked size | 473.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | playfulcorgi |
| Maintainers | playfulcorgi |

## Links

- npm: https://www.npmjs.com/package/pick-html-element
- npm.io page: https://npm.io/package/pick-html-element

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.17.20
- [debounce](https://npm.io/package/debounce.md) ^1.2.0
- [css-selector-generator](https://npm.io/package/css-selector-generator.md) ^2.1.2

## Recent versions

- 1.1.1 (latest) — 2020-10-22

## README

# Pick HTML Element

![GitHub license](https://img.shields.io/github/license/playfulcorgi/pick-html-element) ![GitHub last commit](https://img.shields.io/github/last-commit/playfulcorgi/pick-html-element/main)

<!-- FIXME: show a gif of how the script work on a website -->

Generates an interface for picking HTML elements on any website using mouse and keyboard inputs. The interface sends out an event when an element is picked so that another script can pick up the collected information and act upon it.

To test the script on an example website, open `example/index.html` in Google Chrome.

![Pick HTML element in action](./README-media/pick-html-element-example.gif)

## How to use

### Add `dist/index.js` to the website

```html
<script src="{{path to script}}"></script>
```

### Show the selection interface to the user

```html
<script>
  window.pickHtmlElementScript.init()
</script>
```

### Listen for the select event

```html
<script>
  const listener = (event) => {
    console.log('User selected an HTML element. Details: ', event.detail)
    // Remove the interface for selecting an element or keep listening for more elements.
    window.pickHtmlElementScript.destroy()
  }

  window.addEventListener('pickHtmlElementScriptElementSelect', listener)
</script>
```

## Development

```shell
npm install
npm run-script build:watch
```

## Production

```shell
npm install
npm run-script build:production
```

## Testing

```shell
npm run-script test
```

## Docker

It's possible to run the development and production commands above inside a Docker container already configured with the right tools. To do so, use a prefix `./bin/exec` before each command. For example, `./bin/exec npm run-script build:watch`.

## Maintenance

The project uses ESLint and Prettier for maintaining a consistent code style across source files. Usually, these tools are picked up by the text editor and used automatically to validate and format code. They can be started manually using NPM commands specified inside package.json in the `scripts` section.

---
_Source: https://npm.io/package/pick-html-element · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
