Say I want to be able to detect if someone calls the following method:
document.querySelectorAll('input');
Is it possible for me to hook this call so that if any other scripts loaded in my context, I can log its execution?
Context: I'm thinking of ways to mitigate Man in the Browser Attacks via a chrome extension, and function hooking is one thing I thought of.
This question neatly demonstrates that I can hook a call for my own uses, but clearly other scripts would have to use MY hooked function, which defeats what I'm after. I'd like to be able to hook document.querySelectorAll()
at a level that all other scripts are invisibly using it.
[EDIT] Additional information
Specifically, I'm looking for a way to be able to detect when document.querySelectorAll('input');
gets called, anywhere in my context, period. The context in this case would be a loaded page with multiple scripts imported.
For the record, I'm pretty sure that this can't be done via javascript alone without modifying the interpreter its running on.