HITs Accepted/HIT Scraper Link on Dashboard

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

目前為 2014-10-15 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         HITs Accepted/HIT Scraper Link on Dashboard
// @namespace    http://ericfraze.com
// @version      0.3
// @description  Shows the number of hits you have accepted 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)";
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];
            }
            
            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").find(".container-content").prepend('<table class="metrics-table" width="100%"><tbody><tr class="metrics-table-header-row"><th class="metrics-table-first-header" >HITs Assigned to You</th></tr><tr class="even"><td id ="HITNumber" class="metrics-table-first-value">' + hitsAssigned + '</td></tr></tbody></table>');
    }else{
        $("#HITNumber").text(hitsAssigned);
    }
}