Skip to content

Instantly share code, notes, and snippets.

@TheFrostlixen
Last active December 30, 2017 09:50
Show Gist options
  • Save TheFrostlixen/426547361dc5f5798de4a3e37b1d1f2d to your computer and use it in GitHub Desktop.
Save TheFrostlixen/426547361dc5f5798de4a3e37b1d1f2d to your computer and use it in GitHub Desktop.
Amazon Mechanical Turk scripts for GreaseMonkey/TamperMonkey
// ==UserScript==
// @name mmmturkeybacon Add Hidden Stats to Dashboard (TheFrostlixen)
// @version 1.04
// @description Adds submission, return, and abandonment rates to the dashboard. Fixed source.
// @author TheFrostlixen
// @namespace https://greasyfork.org/en/users/34060
// @include https://www.mturk.com/mturk/dashboard
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
// @grant GM_log
// ==/UserScript==
var SUBMIT_ID = '00000000000000000000';
var RETURN_ID = '000000000000000000E0';
var ABANDON_ID = '00000000000000000070';
$(document).ready(function()
{
function RequestAjax( ID )
{
$.ajax(
{
url: 'https://www.mturk.com/mturk/requestqualification?qualificationId=' + ID,
type: 'GET',
context: this,
success: function(data) {
var $src = $(data);
var maxpagerate = $src.find('td[class="error_title"]:contains("You have exceeded the maximum allowed page request rate for this website.")');
if (maxpagerate.length == 0)
{
var submit_rate = $($src.find('#qualification_score')).next().text();
$('#'+ID).text( submit_rate + "%" );
}
},
error: function(xhr, status, error)
{
alert('mmmturkeybacon Add Hidden Stats to Dashboard: timeout error');
},
timeout: 3000
});
}
// Build table
var $submitted_table = $('th[id="hit_totals.desc_dolumn_header.tooltop.1"]').parents('td[width="50%"]');
$submitted_table.before('<td width="50%">\
<table class="metrics-table" width="100%">\
<tr class="metrics-table-header-row"><th id="hit_totals.desc_dolumn_header.tooltop.2" class="metrics-table-first-header">HITs You Have Accepted</th><th id="user_metrics.rate_column_header.tooltip.2">Rate</th>\
<tr class="odd" ><td class="metrics-table-first-value">HITs Accepted</td><td>&mdash;</td></tr>\
<tr class="even"><td class="metrics-table-first-value">... Submitted</td><td id="'+ SUBMIT_ID +'">___%</td></tr>\
<tr class="odd" ><td class="metrics-table-first-value">... Returned </td><td id="'+ RETURN_ID +'">___%</td></tr>\
<tr class="even"><td class="metrics-table-first-value">... Abandoned</td><td id="'+ ABANDON_ID+'">___%</td></tr>\
</table></td>' );
// Set the stats asynchronously
RequestAjax( SUBMIT_ID );
RequestAjax( RETURN_ID );
RequestAjax( ABANDON_ID );
});
// ==UserScript==
// @name Status Searchable Requester
// @description Replace status page contact links with a HIT search for that requester, and adds a separate contact link.
// @author TheFrostlixen
// @version 0.2
// @namespace https://greasyfork.org/en/users/34060
// @match https://www.mturk.com/mturk/statusdetail?*
// @grant none
// ==/UserScript==
// == CHANGELOG ==
// v0.1 Does what it should, quick and dirty implementation
Array.prototype.forEach.call( document.querySelectorAll('[title="Contact this Requester"'), function(el) {
var tag = document.createElement('a'); // make our new link tag
tag.href = el.href; // set it to the 'contact requester' existing link
el.href = "https://www.mturk.com/mturk/searchbar?selectedSearchType=hitgroups&requesterId=" + tag.search.split(/=|&/)[1]; // modify the original tag to search for the requester
el.target = "_blank"; // opens in new window
tag.innerHTML = "✉"; // add a cute ascii symbol for the contact link
el.parentElement.appendChild( tag ); // append the contact link tag to the parent (requester name)
});
// ==UserScript==
// @name 'Choose Subject of Homework Question'
// @version 1.0
// @description Selection hotkeys and auto-submit for Lili Dworkin's HIT 'Choose Subject of Homework Question'
// @author TheFrostlixen
// @include https://www.mturkcontent.com/dynamic/*
// @match https://www.mturk.com/mturk/accept?*
// @match https://www.mturk.com/mturk/previewandaccept?*
// @grant none
// @namespace https://greasyfork.org/en/users/34060
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
// ==/UserScript==
var submit = true;
var $j = jQuery.noConflict(true);
// verify HIT
if ( $j('strong:homework question')) { // check if this HIT should have this script active
document.addEventListener( "keydown", key, false); // add a keypress listener
$j("input[name='Q1Answer']").eq(5).click(); // check this by default
$j("input[id='submitButton']").focus(); // give focus to something in the window, also makes it easier to insta-submit
}
// Wait for keypress
function key(i) {
// Numpad 1-7
if (i.keyCode >= 97 && i.keyCode <= 103) {
// click the corresponding form named 'Q1Answer' and optionally submit
$j("input[name='Q1Answer']").eq(i.keyCode - 97).click();
if (submit) {
$j("input[id='submitButton']").click();
}
}
// Enter
else if (i.keyCode == 13) {
// submit the HIT as long as you have focus in the window
$j("input[id='submitButton']").click();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment