Created
May 4, 2025 10:25
-
-
Save douxxtech/bfea943fe5d785e9463099638ac347d6 to your computer and use it in GitHub Desktop.
A really simple rebug mouse for websites, so you can get elements coordinates etc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const mouseDebug = Object.assign(document.createElement("div"), { | |
| id: "mouseDebug", | |
| style: "position:fixed;pointer-events:none;z-index:9999;background:red;width:6px;height:6px;border-radius:50%;" | |
| }); | |
| document.body.appendChild(mouseDebug); | |
| const coordDebug = Object.assign(document.createElement("div"), { | |
| id: "coordDebug", | |
| style: "position:fixed;top:0;left:0;color:white;background:black;font:12px monospace;padding:2px 4px;z-index:9999;pointer-events:none" | |
| }); | |
| document.body.appendChild(coordDebug); | |
| document.addEventListener("mousemove", (e) => { | |
| mouseDebug.style.left = e.clientX - 3 + "px"; | |
| mouseDebug.style.top = e.clientY - 3 + "px"; | |
| coordDebug.style.left = e.clientX + 10 + "px"; | |
| coordDebug.style.top = e.clientY + 10 + "px"; | |
| coordDebug.textContent = `x: ${e.clientX}px, y: ${e.clientY}px | ${((e.clientX / window.innerWidth) * 100).toFixed(1)}%, ${((e.clientY / window.innerHeight) * 100).toFixed(1)}%`; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment