Main Level 2 Solution

Intro 2

OmegaExtern
9 years ago | edited 9 years ago

0

It is using span with custom style which sets the text’s foreground color/colour to black to hide it (as by default, this site uses the black background color/colour), answer can be seen if you select all (cmd/ctrl+A) while on web-page.

Here is my automated JavaScript solution for Main Level 2.
By saying “automated”, I mean when you execute the following JavaScript script I wrote, it will display username and password to your screen.
It will autofill user and pass elements/fields with appropriate values, and automatically submit the form for you as you run the code :)
<3 XPath.

Run the following JavaScript code from JavaScript console in your web-browser while on web-page:
```function getElementByXPath(xpath)
{
return document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}

var username = String(getElementByXPath(“//[@id=\"main-content\”]/div/div[2]/div[2]/form/fieldset/span[1]“).innerText);
var password = String(getElementByXPath(”//
[@id=\“main-content\”]/div/div[2]/div[2]/form/fieldset/span[2]“).innerText);
document.getElementById("user”).value = username;
document.getElementById(“pass”).value = password;
console.log(username);
console.log(password);
alert(“Username: ” + username + “\nPassword: ” + password);
document.getElementsByTagName(“input”)[3].click();```

P.S. I love JavaScript.

Greetings from OmegaExtern.

0replies
1voice
405views
Discussion thread has been locked. You can no longer add new posts.
1 of 1

This site only uses cookies that are essential for the functionality of this website. Cookies are not used for tracking or marketing purposes.

By using our site, you acknowledge that you have read and understand our Privacy Policy, and Terms of Service.

Dismiss