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

282
Visualizações
TamperMonkey Script

I am trying to change a <textarea> field in an HTML login page into an <input> field, dynamically, on page load.

<div class="field input-field">
    <span class="user-icon">
    </span>
    <textarea class="qStr" data-qstrph="LDAP_SERVER_STR12" id="username" autocomplete="off" placeholder="Username">
    </textarea>
    <span class="reset-icon slice-img">
    </span>
</div>

The first thing I thought of was TamperMonkey, and using JavaScript to do this.

I reached out to a friend of mine, who is far more talented than I am, and asked him to make a small JavaScript bit to do what I'm wanting. He quickly came back with this:

const originalItem = document.getElementById("username")
const newItem = document.createElement("input")
newItem.setAttribute("type", "text")
newItem.setAttribute("class", "qStr")
newItem.setAttribute("data-qstrph", "LDAP_SERVER_STR12") 
newItem.setAttribute("id", "username")
newItem.setAttribute("autocomplete", "off")
newItem.setAttribute("placeholder", "Username")
originalItem.replaceWith(newItem)

When I run this snippet in the Chrome developer console, it does exactly what you'd expect it to do, and that's awesome! When I take the same block and put it into TamperMonkey, save the file, and make sure its an enabled script, and reload the HTML page -- nothing happens -- and this makes me sad:

Here is the code, as it is in TamperMonkey:

A screenshot showing code from a tampermonkey script

I'm not sure what I'm not doing right, as the code worked perfectly in the dev console.

Your input is appreciated, thank you!

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