Element Selector Tool

Press Ctrl+E to get friendly CSS selectors for any element

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Author
jamubc
Daily installs
0
Total installs
3
Ratings
0 0 0
Version
6.2
Created
2025-07-14
Updated
2025-11-03
Size
39.2 KB
License
N/A
Applies to
All sites

Element-Selector-tree-tool (Source) (View on Greasyfork)

Tampermonkey Violentmonkey Web Script

A powerful userscript that provides developer-friendly CSS selectors for any DOM element with visual highlighting and a hierarchical tree view.​

Why it’s useful: Click any element to copy a precise, unique selector so AI or automation can generate a working userscript faster with fewer mistakes.​

[![Chrome](https://img.shields.io/badge/Chrome-✓-4285F4?logo=googlechrome&logoColor=white)](https://www.google.com/chrome/) [![Firefox](https://img.shields.io/badge/Firefox-✓-FF7139?logo=firefox&logoColor=white)](https://www.mozilla.org/firefox/) [![Safari](https://img.shields.io/badge/Safari-✓-006CFF?logo=safari&logoColor=white)](https://www.apple.com/safari/)
Highlighting an element and displaying its CSS selector Hierarchical tree view of DOM elements

Features

  • One-Click Copy and quick view: Click any highlighted element to copy its selector to clipboard
  • Interactive Tree View: Shows element hierarchy with syntax highlighting
  • Smart Selector Generation: Prioritizes reliable selectors (ID → data attributes → unique classes → semantic attributes)
  • Menu Options: Change hotkeys and toggle enable/disable directly from the menu

Installation

  1. Install a userscript manager like Tampermonkey or Violentmonkey or Userscript
  2. Click here to install the script
  3. The script will automatically run on all websites
  4. Setup your own hotkey!: image

Usage

  • hotkey defaults to Ctrl+E, you can change this in the menu *
  • Activate: Press Ctrl+E on any webpage
  • Inspect: Hover over elements to see their selectors and hierarchy
  • Copy: Click on any highlighted element to copy its CSS selector
  • Deactivate: Press Ctrl+E again to exit selector mode

Selector Priority

The tool generates selectors in this priority order:

  1. ID: #unique-id (most reliable)
  2. Data Attributes: [data-testid], [data-cy], [data-test]
  3. Stable Class Combo: button.primary.large (avoids hashed/dynamic classes)
  4. ARIA Attributes: [role="button"], [aria-label="Close"]
  5. Semantic Elements: input[name="email"], button[type="submit"]
  6. Contextual :has() (when applicable): e.g. label[for="id"]:has(+ input)
  7. Hierarchical Path: nearest‑ID path using :nth-of-type when needed

Contributing

Feel free to submit issues or pull requests to improve the tool's selector generation or user experience.

License

This project is licensed under the Apache License, Version 2.0 with Commons Clause License Condition v1.0 - see the LICENSE file for details.