Skip to content

Instantly share code, notes, and snippets.

@clooth
Created October 27, 2013 20:31
Show Gist options
  • Save clooth/7187523 to your computer and use it in GitHub Desktop.
Save clooth/7187523 to your computer and use it in GitHub Desktop.
// 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