Created
December 31, 2025 21:25
-
-
Save jakeayy/672dff2d9b7e1b1d58b117d4d99bb3d6 to your computer and use it in GitHub Desktop.
JS hack with Proxy that overrides isTrusted's state in Element events to true
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
| Element.prototype.addEventListener = new Proxy( | |
| Element.prototype.addEventListener, | |
| { | |
| apply(target, props, args) { | |
| const h = args[1]; | |
| args[1] = (ev) => | |
| h( | |
| new Proxy(ev, { | |
| get: (target, p) => p === "isTrusted" || target[p], | |
| }), | |
| ); | |
| return Reflect.apply(target, props, args); | |
| }, | |
| }, | |
| ); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's a POC. It most likely breaks removeEventListener so you need to write your own code for that