Search code examples
javascriptuserscriptsgreasemonkey-4

Userscript to click login button (https://steamcommunity.com/login)


I'm trying to automatically login to when https://steamcommunity.com/login/ is opened.

Using either submit() or click() redirects me to https://steamcommunity.com/login/# instead of being logged in. If I remove steamLoginForm.submit(); and click the button manually it works; so I assume I have to click/submit differently.

// ==UserScript==
// @name     SteamLogin
// @include  https://steamcommunity.com/login/
// ==/UserScript==


var steamLoginForm = document.getElementById("loginForm");

steamLoginForm.elements.namedItem("steamPassword").setAttribute("autocomplete", "on");
steamLoginForm.elements.namedItem("remember_login").checked = true; 
steamLoginForm.elements.namedItem("steamAccountName").value = "accountName";
steamLoginForm.submit();


Solution

  • I just simply use the following.

    document.getElementById("steamAccountName").value="username";
    document.getElementById("steamPassword").value="password";
    document.getElementById("SteamLogin").click();