skip to Main Content

I am trying to write a simple Chrome extension that copies some information from one webpage and fills the appropriate input fields on another. The input field’s value is (visibly) set by JavaScript: inputField.value = "some value" in a content script injected into the webpage. Then, when I click on other input fields, its value changes back to its original value (which is not desirable). I am trying to find the cause of this.

(The website is https://mojezasielky.posta.sk/#dashboard – you would probably have to register – specifically "Balík -> Nová zásielka".)

I tried adding

inputField.dispatchEvent(new Event("input", {bubbles: true}));
inputField.dispatchEvent(new Event("change", {bubbles: true}));

expecting that maybe something listens for these events, but it still behaves the same.

What could be the cause of this behavious? How can I prevent this?

2

Answers


  1. Chosen as BEST ANSWER

    The solution for this answer worked for me. Specifically, I had to add:

    const BLUR = new Event("blur", {bubbles: true});
    inputField.dispatchEvent(BLUR);
    

    I still don't know why, but it seems understandable that something is listening for this event.


  2. After registering and opening the dashboard, I cannot find "Nová zásielka" after clicking on "Balík". So I could not test my ideas directly.

    The ideas:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search