Rekha R
Rekha R

Reputation: 191

How to autofill a text field in a pop up using greasemonkey?

So basically I have a text field, with the following Elements.

// The element locators for the text box are as follows:

type="text" name="custom_version_ui" value="" id="custom_version_ui" placeholder="" class="custom form-control form-control-full "

I want to auto-fill the text box for "custom_version_ui" with a specific value. This text box is present in a pop and doesn't come during page loading. (It comes once I click on the Add result button on the page which renders the pop-up).

The URL of the page doesnt change when we click on the 'Add Result' button. Is there a way to auto-fill such fields?

Upvotes: 0

Views: 798

Answers (1)

CennoxX
CennoxX

Reputation: 808

A possible solutions would be to use setInterval to search for the field from the moment you open the page and fill it, if the field is found:

var getElem = setInterval(()=>{
var elem = document.querySelector("#custom_version_ui");
if (elem){
    elem.placeholder = "specific value";
    clearInterval(getElem);
}
},500);

Another option would be, to add an eventListener to the Add result button and (possibly with a slight delay) auto-fill the text box.

Upvotes: 0

Related Questions