Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

269
Visualizações
How to simulate typing and change input value in Chrome extension content script

I need a way to change the value of the input field with my new value

I tried input.value didn't work. Tried this function:

  function simulateTyping(element, value, i) {
    i === 0 && element.setAttribute("value", value);
    i === 0 && (element.value = "");

    if (i < value.length) {
      element.value += value.charAt(i);
      element.dispatchEvent(
        new Event("textInput", {
          data: value.charAt(i),
          inputType: "textInput",
          bubbles: true,
          cancelable: true,
        })
      );
      element.dispatchEvent(
        new Event("input", {
          bubbles: true,
          data: value.charAt(i),
          cancelable: true,
        })
      );
      setTimeout(simulateTyping.bind(this, element, value, i + 1), 10);
    } else {
      element.dispatchEvent(
        new Event("change", {
          bubbles: true,
          cancelable: true,
        })
      );
      element.dispatchEvent(new Event("blur", { bubbles: true }));
      var evt = document.createEvent("KeyboardEvent");
      evt.initEvent("keyup", true, true);
      element.dispatchEvent(evt);
    }
  }

This function changed the value but suddenly the website is changing the value but If I type the number with my keyboard the website didn't change the value .

I think there is something more which we need to find to actually simulate real keypress This is the website https://tibiablackjack.com/crash

Video demo https://www.loom.com/share/cb568c04ac85427395c2f0e1481c7fb9

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda