event-override
The event-override snippet proxies events and event handlers to defuse events or change their attributes. It works by proxying addEventListener and the original Event class with a CustomEvent class.
Parameters
|
Name |
Description |
Mandatory |
Default |
|---|---|---|---|
|
eventType |
The type of the event to target (e.g., click, mouseover, someCustomEvent). |
Yes |
n.a. |
|
mode |
Operation mode: |
Yes |
n.a. |
|
needle |
Needle to look for in the event listener function's source — not in the event payload. Enclose in |
No |
'' |
|
property |
The name of the event property to rewrite, for example |
Only in |
null |
|
pattern |
Regex or literal text matched against the property value. Every match is replaced. Ignored outside |
Only in |
null |
|
replacement |
The replacement text. Defaults to an empty string, which deletes the matched text. Ignored outside |
No |
'' |
rewrite mode
rewrite adjusts the payload a listener reads off an event instead of suppressing the event entirely — useful when defusing the listener would break the page.
-
Only string values are rewritten. Any other type, and any value that does not match
pattern, is passed through untouched. -
Every match of
patterninside the value is replaced, not just the first. If the replacement produces no change, the original value is returned as-is. -
Rules are matched by property name, so one filter handles one property. If two
rewritefilters target the same property on the same event type, the first registered wins. -
Both
propertyandpatternare required. If either is missing the snippet logs an error and does nothing. -
Leave
needleempty unless the string you are matching on actually appears in the listener's own source code. It is tested against the listener, not against the payload, so a token that only exists in the event data will never match it.
Filter examples
|
Filter |
Result |
|---|---|
|
|
Disables all event listeners for the click event. |
|
|
Disables all event listeners for the custom event. |
|
|
Makes |
|
|
For every |
|
|
Deletes every |
Debugging
|
Message |
When |
Definition |
|---|---|---|
|
|
Right after the snippet fires |
|
|
|
After |
Calls to |
|
|
A listener matching the event type and needle was registered |
That listener will receive the proxied event. If this never appears, either the event type does not match, the |
|
|
|
The listener was dropped and never reached the native |
|
|
|
The listener asked for |
|
|
|
The rewrite happened. If the wrapping message appears but this one never does, the listener either does not read |