I think I see what you mean by access now..
Just add this function to your content script and it will attach a event listener too all inputs on the page that returns the current input field.
All it does is uses a for
loop to loop through all inputs on the page, then add a click addEventListener
to each input, and have it return the current input
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<input type="text" name="text" id="input1" placeholder="Click me">
<input type="text" name="text" id="input2" placeholder="Click me">
<input type="text" name="text" id="input3" placeholder="Click me">
<br><br><br>
<div id="display"></div>
</body>
<script>
function inputs(){
for(let i = 0; i < document.querySelectorAll('input').length; i++){
document.querySelectorAll('input')[i].addEventListener('click', ()=>{
//Get the DOM element of whatever input user clicks on
var currentInput = document.querySelectorAll('input')[i];
console.log(currentInput);
//Just for example purposes
document.getElementById('display').innerText = 'You clicked on input...' + (i+1);
});
}
}
inputs();
</script>
</html>
Now that you have the exact input field the user is typing in.. you should be able to add the predicted words, by setting the input field equal to the current value of it + your predicted text.