Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

285
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!