Created
October 27, 2013 20:31
-
-
Save clooth/7187523 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
// Create dummy click event for automation | |
var click = new MouseEvent('click', { 'clientX': 1,'clientY': 1 }); | |
// Create button boilerplate | |
function createButton(title, action) { | |
var button = document.createElement('button'); | |
button.innerText = title; | |
button.onclick = function(e) { | |
e.preventDefault(); | |
action(e); | |
return false; | |
}; | |
return button; | |
} | |
function rapidClickSelector(selector) { | |
// Check original button state | |
var target = document.querySelector(selector); | |
var clickInterval = window.setInterval(function() { | |
if (document.querySelector(selector + '[disabled]')) { | |
clearInterval(clickInterval); | |
alert("Done messing with "+ selector); | |
} | |
target.dispatchEvent(click); | |
}, 10); | |
} | |
// Buttons container | |
var buttons = document.querySelector('#buttons'); | |
// Sell all button | |
var sellAll = createButton('Sell All', function(e) { | |
rapidClickSelector('#btn-sellloc'); | |
}); | |
// Hire all button | |
var hireAll = createButton('Hire All', function(e) { | |
rapidClickSelector('#btn-hirecoder'); | |
}); | |
// Init | |
buttons.appendChild(sellAll); | |
buttons.appendChild(hireAll); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment