Created
November 24, 2015 15:54
-
-
Save rgorsuch/a4cae58b2755f48c8f7e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Splunk | |
// @namespace https://splunk:8000/en-US/account/ | |
// @include https://splunk:8000/en-US/account/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
// perl -ne 'chomp; print join("", map { sprintf "\\%o", ord } split("", $_)) . "\n"' | |
// Run this, type your password, then ctrl+d | |
function $x() { | |
var x=''; | |
var node=document; | |
var type=0; | |
var fix=true; | |
var i=0; | |
var cur; | |
function toArray(xp) { | |
var final=[], next; | |
while (next=xp.iterateNext()) { | |
final.push(next); | |
} | |
return final; | |
} | |
while (cur=arguments[i++]) { | |
switch (typeof cur) { | |
case "string": x+=(x=='') ? cur : " | " + cur; continue; | |
case "number": type=cur; continue; | |
case "object": node=cur; continue; | |
case "boolean": fix=cur; continue; | |
} | |
} | |
if (fix) { | |
if (type==6) type=4; | |
if (type==7) type=5; | |
} | |
// selection mistake helper | |
if (!/^\//.test(x)) x="//"+x; | |
// context mistake helper | |
if (node!=document && !/^\./.test(x)) x="."+x; | |
var result=document.evaluate(x, node, null, type, null); | |
if (fix) { | |
// automatically return special type | |
switch (type) { | |
case 1: return result.numberValue; | |
case 2: return result.stringValue; | |
case 3: return result.booleanValue; | |
case 8: | |
case 9: return result.singleNodeValue; | |
} | |
} | |
return fix ? toArray(result) : result; | |
} | |
function message_found(msg) { | |
// check whether the message is present | |
return $x('//p[contains(., "' + msg + '")]').length > 0; | |
} | |
function login() { | |
setTimeout(function() { | |
//alert("Try from timeout ..."); | |
document.getElementById('username').value = ''; | |
document.getElementById('password').value = ''; | |
if (!message_found("Invalid username or password")) { | |
document.querySelector(".btn").click(); | |
} | |
}, 3000); | |
} | |
login(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment