1

I cannot get my autologin Tampermonkey script to work on a webpage.

This is the source of the page:

<p>
    <label for="username" style="opacity: 1;">Gebruikersnaam</label>
    <input type="text" name="username" id="username" autocomplete="off" autofocus="">
</p>
<p>
    <label for="password">Wachtwoord</label>
    <input type="password" name="password" id="password" autocomplete="off">
</p>
<button id="authLeftPaneLoginButton" class="smscButton">
    Aanmelden
</button>

A translation for some words:
Gebruikersnaam means username
Wachtwoord means password
Aanmelden means login

Here is the tampermonkey code I am using:

waitForKeyElements('document.getElementById("username")', enterUsername())
function enterUsername (jNode) { 
    $("#username").val("username_here"); 
} 
$("#password").val("password_here");
Elias Benevedes
  • 363
  • 1
  • 8
  • 26

1 Answers1

1
  1. That is not how to use waitForKeyElements(). The first parameter needs to be a jQuery selector.
  2. You need to wait for both the username and password.
  3. Don't hardcode credentials in a script!! That is a dangerously bad practice. You will get pwned.

To fix your immediate problem, the code would be like this:

waitForKeyElements ('#username', enterUsername);
waitForKeyElements ('#password', enterPassword);

function enterUsername (jNode) { 
    jNode.val ("username_here"); 
} 

function enterPassword (jNode) { 
    jNode.val ("password_here"); 
} 


But, to avoid certain doom, use a login framework that protects your credentials.

Community
  • 1
  • 1
Brock Adams
  • 90,639
  • 22
  • 233
  • 295
  • So then i append this script at the end of the login framework and change "username_here" and "password_here" to usr and pword? or do i have to use one of the functions to decrypt them first? – Warre Dujardin Mar 03 '15 at 13:20
  • Yes, just make those first 2 changes and also change the `@include` to match your site. Decryption is handled automatically by that framework. – Brock Adams Mar 03 '15 at 20:03