My extensions go through every input entered on an on any website that is loaded.
What I do is I consider every onkeydown and manipulate it if it has some value.
Instead of document.onkeydown = returnKey;
, use
document.addEventListener('keydown', returnKey, true);
The most important part of this line is the third argument. When the value of this parameter is true
, the event listener is triggered at capturing phase, which cannot be prevented using event.preventDefault();
or event.stopPropagation();
.