@empiricalrun/playwright-utils
Advanced tools
Comparing version
# @empiricalrun/playwright-utils | ||
## 0.6.1 | ||
### Patch Changes | ||
- de76cd6: fix: wrap mouse-pointer highlighter in try/catch | ||
## 0.6.0 | ||
@@ -4,0 +10,0 @@ |
@@ -6,7 +6,8 @@ "use strict"; | ||
page.on("load", async () => { | ||
await page?.evaluate(() => { | ||
const box = document.createElement("div"); | ||
box.classList.add("empirical-mouse-pointer"); | ||
const styleElement = document.createElement("style"); | ||
styleElement.textContent = ` | ||
try { | ||
await page?.evaluate(() => { | ||
const box = document.createElement("div"); | ||
box.classList.add("empirical-mouse-pointer"); | ||
const styleElement = document.createElement("style"); | ||
styleElement.textContent = ` | ||
.empirical-mouse-pointer { | ||
@@ -57,26 +58,30 @@ pointer-events: none; | ||
`; | ||
document.head.appendChild(styleElement); | ||
document.body.appendChild(box); | ||
document.addEventListener("mousemove", (event) => { | ||
box.style.left = `${event.pageX}px`; | ||
box.style.top = `${event.pageY}px`; | ||
updateButtons(event.buttons); | ||
}, true); | ||
document.addEventListener("mousedown", (event) => { | ||
updateButtons(event.buttons); | ||
box.classList.add(`button-${event.button + 1}`); | ||
}, true); | ||
document.addEventListener("mouseup", (event) => { | ||
updateButtons(event.buttons); | ||
box.classList.remove(`button-${event.button + 1}`); | ||
}, true); | ||
// @ts-ignore | ||
function updateButtons(buttons) { | ||
for (let i = 0; i < 5; i++) { | ||
box.classList.toggle(`button-${i + 1}`, (buttons / Math.pow(2, i)) % 2 >= 1); | ||
document.head.appendChild(styleElement); | ||
document.body.appendChild(box); | ||
document.addEventListener("mousemove", (event) => { | ||
box.style.left = `${event.pageX}px`; | ||
box.style.top = `${event.pageY}px`; | ||
updateButtons(event.buttons); | ||
}, true); | ||
document.addEventListener("mousedown", (event) => { | ||
updateButtons(event.buttons); | ||
box.classList.add(`button-${event.button + 1}`); | ||
}, true); | ||
document.addEventListener("mouseup", (event) => { | ||
updateButtons(event.buttons); | ||
box.classList.remove(`button-${event.button + 1}`); | ||
}, true); | ||
// @ts-ignore | ||
function updateButtons(buttons) { | ||
for (let i = 0; i < 5; i++) { | ||
box.classList.toggle(`button-${i + 1}`, (buttons / Math.pow(2, i)) % 2 >= 1); | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
catch (e) { | ||
console.log(`Error adding mouse pointer highlighter`, e); | ||
} | ||
}); | ||
} | ||
exports.addMousePointerHighlighter = addMousePointerHighlighter; |
{ | ||
"name": "@empiricalrun/playwright-utils", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "registry": "https://registry.npmjs.org/", |
Sorry, the diff of this file is not supported yet
26792
1.22%505
1%