I am working on a JavaScript-based browser script / Chrome extension and I want to continuously monitor text that a user types into input fields or textareas on a webpage.
What I want to achieve
Detect text entered by the user in:
elementselementscontenteditable elements (if possible)
Read or log the current value every second
The solution should work without modifying the website’s source code (i.e., via a content script or injected JS)
What I have tried
Using
setInterval()to poll input valuesUsing
document.querySelectorAll('input, textarea')Listening to
inputandkeydownevents
However, I am unsure:
Which approach is more efficient (event listeners vs polling)
How to reliably detect dynamically created input fields
How to handle single-page applications (SPAs) where DOM updates frequently
Constraints
JavaScript only (no backend processing)
Runs in the browser (content script / injected script)
Should not rely on external libraries