Skip to content

Instantly share code, notes, and snippets.

@douxxtech
Created May 4, 2025 10:25
Show Gist options
  • Select an option

  • Save douxxtech/bfea943fe5d785e9463099638ac347d6 to your computer and use it in GitHub Desktop.

Select an option

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
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