I am trying to write an extension that will search the webpage for a specific text element and write my const into it.
Some additional context: The process flow is essentially;
- Pop up prompts user to provide input
- User provides input and presses submit
- Some changes are made to the input and it is stored as 'data'
- Extension then searches webpage for specific text element called 'title'
- Extension then writes my 'data' const to this text element.
Here is what I have at the moment - I cannot get this to write. Not sure if it is not identifying the element or not writing correctly.
const titleInput = document.querySelectorAll('input[name="title"], textarea[name="title"]')[0];
if (titleInput.value[0]) {
titleInput.value = titleWithoutQuotes;
} else {
console.error('Title input field not found');
}
if (titleInput && titleInput.value) {