// ==UserScript==
// @name Auto HIT Cap
// @namespace https://www.mturkcrowd.com/members/aveline.7/
// @version 1.0
// @description Probably does nothing.
// @author aveline
// @icon https://i.imgur.com/jsju8Wy.png
// @include */worker.mturk.com/projects/*
// @require http://code.jquery.com/jquery-3.2.1.min.js
// @grant none
// ==/UserScript==
const returnHIT = document.getElementsByClassName("btn btn-secondary")[0];
const acceptHIT = document.getElementsByClassName("btn btn-primary")[0];
window.addEventListener("message", function(e){
if (e.data == "ReturnHIT"){
returnHIT.click();
} else if (e.data == "AcceptHIT"){
acceptHIT.click();
}
});
var page = document.getElementsByTagName("body")[0];
if (page.innerHTML.indexOf('Time Elapsed') != -1) {
setTimeout(function(){
window.top.postMessage("ReturnHIT",'*');
window.stop()
},500);
} else {
setTimeout(function(){
window.top.postMessage("AcceptHIT",'*');
window.stop()
},500);
}