Created
May 10, 2019 20:09
-
-
Save gu3st/4f38755dbad42305a2f1e027b70a7c03 to your computer and use it in GitHub Desktop.
Userscript to add a button to automatically submit an iRacing protest after a delay
This file contains 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 Automatically submit protest after a delay | |
// @namespace st.gu3 | |
// @match https://members.iracing.com/membersite/member/protest/file_protest.jsp | |
// @grant none | |
// ==/UserScript== | |
// | |
var script = document.createElement("script"); | |
script.textContent = "(" + protestMagic.toString() + ")();"; | |
setTimeout(() => { | |
document.body.appendChild(script); | |
console.log('Loaded EzProtest'); | |
}, 600) | |
function protestMagic(){ | |
var protestType = document.querySelectorAll('#selectViolation')[0] | |
var button = document.createElement('button') | |
button.innerText = "Submit Automatically" | |
button.onClick = () => { | |
setTimeout(__submit, 60*60*1000) | |
} | |
const oldChange = protestType.onchange | |
protestType.onchange = (e) => { | |
oldChange(e) | |
var submit = document.querySelectorAll('input[type="submit"]')[0] | |
submit.parentElement.insertBefore(button,submit.nextSibling); | |
} | |
function __submit(){ | |
var submit = document.querySelectorAll('input[type="submit"]')[0] | |
button.disabled = true | |
submit.click() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment