HITs Accepted on Dashboard/HIT Scraper Link

Shows the number of hits you have accepted, lists theme, and also a link to HIT scraper.

当前为 2014-10-15 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         HITs Accepted on Dashboard/HIT Scraper Link
// @namespace    http://ericfraze.com
// @version      0.6
// @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
// ==/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 class="metrics-table" width="100%">' +
                    '<tbody><tr class="metrics-table-header-row">' +
                        '<th class="metrics-table-first-header">' +
                          'Title' +
                        '</th>' +
                        '<th>' +
                            'Requester' +
                        '</th>' +
                        '<th>' +
                            'Reward' +
                        '</th>' +
                        '<th>' +
                            'Time Left' +
                        '</th>' +
                        '<th>' +
                            'Return' +
                        '</th>' +
                        '<th>' +
                            'Continue' +
                        '</th>' +
                    '</tr>';
                
                $('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 += '<tr class="' + sign + '">' +
                                    '<td class="metrics-table-first-value">' + title[i] + '</td>' +
                                    '<td>' + requester[i] + '</td>' +
                                    '<td>' + pay[i] + '</td>' +
                                    '<td>' + timeLeft[i] + '</td>' +
                        			'<td style="text-align: center;"><a href="' + returnURL[i] + '">Return</a></td>' +
                                    '<td style="text-align: center;"><a href="' + continueURL[i] + '">Continue</a></td>' +
                                 '</tr>';
                });
                
                hitString += '</tbody></table>';
            }
            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("<a class='subnavclass' href='https://www.mturk.com/mturk/findhits?match=true?hit_scraper'>HIT Scraper</a><span class='almostblack_text'>&nbsp;|&nbsp;</span>"); 
    }
});

function addHitNumber() {
    if ( !$("#HITNumber").length ){
    	$("td:contains('Your HIT Status')").parents("table").before('<table width="760" align="center" cellspacing="0" cellpadding="0"><tbody><tr height="25px"><td width="10" bgcolor="#7fb4cf" style="padding-left: 10px;"></td><td width="100%" bgcolor="#7fb4cf" class="white_text_14_bold"><a href="https://www.mturk.com/mturk/myhits">HITs Assigned to You</a> (<span id="HITNumber">' + hitsAssigned + '</span>)</td><td width="10" align="right" bgcolor="#7fb4cf"></td></tr><tr><td class="container-content" colspan="3"><table class="metrics-table" width="100%"><tbody><tr><td id="HITInfo"></td></tr></tbody></table></td></tr></tbody></table>');
        $("#HITInfo").append(hitString);
    }else{
        $("#HITNumber").text(hitsAssigned);
        $("#HITInfo").empty();
        $("#HITInfo").append(hitString);
    }
}