Skip to content

Instantly share code, notes, and snippets.

@cuylerstuwe
Last active September 30, 2018 18:26
Show Gist options
  • Select an option

  • Save cuylerstuwe/d66577f412c1bef634960c9f02ab3d11 to your computer and use it in GitHub Desktop.

Select an option

Save cuylerstuwe/d66577f412c1bef634960c9f02ab3d11 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name IA FJ
// @namespace salembeats
// @version 1.2
// @description .
// @author Cuyler Stuwe (salembeats)
// @include https://s3.amazonaws.com/mturk_bulk/hits/*
// @include https://www.mturkcontent.com/dynamic/*
// @grant none
// ==/UserScript==
function isInIframe() {
return window !== window.top;
}
function getGid() {
const referrer = document.referrer;
if(!referrer.includes("projects/")) {return undefined;}
return referrer.match(/projects\/([^/]*)/)[1];
}
function submitYes() {
document.getElementById("radio-yes").click();
document.getElementById("submitButton").click();
}
function submitNo() {
document.getElementById("radio-no").click();
document.getElementById("submitButton").click();
}
function isThisGidOneOf(gids) {
const hitGid = getGid();
for(const gid of gids) {
if(gid === hitGid) {return true;}
}
return false;
}
function attachYesNoKeyListeners(yesKeyString, noKeyString) {
document.body.addEventListener("keydown", e => {
if(e.key === yesKeyString) {
submitYes();
}
if(e.key === noKeyString) {
submitNo();
}
});
}
function main() {
if(!isThisGidOneOf([
"3KAZLCS3F9ALRMAYYRWSFLQVGVFAPS",
"3QG9DTEQJM5BBV7ZADAN7FYQESJAWR",
"3VXAY8PXA64321NMLRVIK2X07XVBUU",
"3RC2K8SGE3RRAMPS6IYJ5KN2GL1GXS",
"37NNZ8MO8T49HBSPE9D3B96X851EQM",
"3QG9DTEQJM5BBV7ZADAN7FYRGSJAWV",
"3IXQCB6XJ9IYPWM3RWXP1TFCI24IT2",
"3I21NMEA63SXE1Y4WEAERCIBG6DHSL",
"3IBVVLBPPNIUK7699EIPDUUC1FYJTM",
"3DMF13TAPZJ9KKLY9J8ZIQGEKT4JUC"
])) {
return;
}
attachYesNoKeyListeners("f", "j");
window.focus();
window.addEventListener("keydown", e => {
if(e.key === "Shift") {
window.top.postMessage({clickTradeHit: true}, "*");
}
});
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment