Element Selector Tool

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
jamubc
日安装量
0
总安装量
3
评分
0 0 0
版本
6.2
创建于
2025-07-14
更新于
2025-11-03
大小
39.2 KB
许可证
暂无
适用于
所有网站

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.