// ==UserScript== // @name HITs Accepted on Dashboard/HIT Scraper Link // @namespace http://ericfraze.com // @version 0.8 // @description Shows the number of hits you have accepted, lists theme, and also a link to HIT scraper. // @author Eric Fraze // @match https://www.mturk.com/mturk/* // @grant none // @downloadURL none // ==/UserScript== var hitsAssigned = "N/A (there was an error or something, contact Magnilucent if it happens a lot)"; var hitString = ""; var title = []; var requester = []; var pay = []; var timeLeft = []; var returnURL = []; var continueURL = []; url = window.location.href; if ( url.indexOf("dashboard") !== -1 ) { $.ajax({ url: "https://www.mturk.com/mturk/myhits", dataType: "html", success: function(data) { if ( $("td:contains('There are currently no HITs assigned to you.')", data).length ) { hitsAssigned = 0; }else{ var text = $("td.title_orange_text[style='white-space: nowrap; padding-top: 1ex;']", data).text(); var regstring = /(\d{1,2})(\sResults)/; var reg = new RegExp(regstring); var groups = reg.exec(text); hitsAssigned = groups[1]; hitString = '' + '' + '' + '' + '' + '' + '' + ''; $('table[width="100%"][height="100%"]', data).each( function(i) { title[i] = $(this).find("a.capsulelink[href='#']").text().trim(); requester[i] = $(this).find(".requesterIdentity").text() pay[i] = $(this).find(".reward").text() timeLeft[i] = $(this).find("td[width='25%'] td.capsule_field_text").text().trim(); var sign = "odd" if ( ((i + 1)/2) == Math.round((i + 1)/2) ) sign = 'even'; timeLeft[i] = timeLeft[i].replace(" minutes", "m").replace(" seconds", "s");; returnURL[i] = $(this).find("a[href^='/mturk/return']").attr("href"); continueURL[i] = $(this).find("a[href^='/mturk/continue']").attr("href"); hitString += '' + '' + '' + '' + '' + '' + ''; }); hitString += '
' + 'Title' + '' + 'Requester' + '' + 'Reward' + '' + 'Time Left' + '' + 'Return' + '
' + (title[i].length > 60 ? title[i].substring(0, 60 - 3) + '...' : title[i]) + '' + (requester[i].length > 15 ? requester[i].substring(0, 15 - 3) + '...' : requester[i]) + '' + pay[i] + '' + timeLeft[i] + 'Return
'; } addHitNumber(); } }); } $(document).ready(function() { if ( $("td:contains('Your HIT Status')").length ) { $("#subtabs a:contains('Introduction')").attr("href", "https://www.mturk.com/mturk/findhits?match=true?hit_scraper"); $("#subtabs a:contains('Introduction')").text("HIT Scraper"); addHitNumber(); }else{ $("#subtabs").prepend("HIT Scraper | "); } }); function addHitNumber() { if ( !$("#HITNumber").length ){ $("td:contains('Your HIT Status')").parents("table").before('
HITs Assigned to You (' + hitsAssigned + ')
'); $("#HITInfo").append(hitString); }else{ $("#HITNumber").text(hitsAssigned); $("#HITInfo").empty(); $("#HITInfo").append(hitString); } }