This repository has been archived by the owner on Jan 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
61 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,41 @@ | ||
(() => { | ||
// Check if the script has already been executed | ||
if (window.__k6BrowserInteractionScriptRan) { | ||
return; | ||
} | ||
|
||
window.__k6BrowserInteractionScriptRan = true; | ||
|
||
const handledTargets = new Set(); | ||
|
||
function once(element, event) { | ||
// Check if the event target is already handled | ||
if (handledTargets.has(element)) { | ||
return; // Ignore if already handled | ||
} | ||
|
||
// Add the target to the Set | ||
handledTargets.add(element); | ||
|
||
// Optional: Remove the element from the Set after a timeout (if necessary) | ||
setTimeout(() => { | ||
handledTargets.delete(element); | ||
}, 500); // Allow reprocessing after 500ms | ||
|
||
window.k6browserInteractionOccurred(JSON.stringify({ event: event })) | ||
} | ||
|
||
window.k6browserInteractionOccurred(JSON.stringify({ event: "domcontentloaded" })) | ||
|
||
document.addEventListener('click', (event) => { | ||
window.k6browserInteractionOccurred(JSON.stringify({ event: "interact" })) | ||
once(event.target, "interact"); | ||
}); | ||
|
||
document.addEventListener('select', (event) => { | ||
once(event.target, "interact"); | ||
}); | ||
|
||
document.addEventListener('change', (event) => { | ||
window.k6browserInteractionOccurred(JSON.stringify({ event: "interact" })) | ||
document.addEventListener('input', (event) => { | ||
once(event.target, "interact"); | ||
}); | ||
})(); |
This file contains 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