Captcha Counter

Counts the number of hits remaining before you get a captcha

当前为 2014-05-13 提交的版本,查看 最新版本

// ==UserScript==
// @name       Captcha Counter
// @version    0.2
// @match      https://www.mturk.com/mturk/*
// @copyright  2014+, Tjololo
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
// @namespace https://greasyfork.org/users/710
// @description Counts the number of hits remaining before you get a captcha
// ==/UserScript==

var hitId = "";
if (document.getElementsByName("hitId")[0])
    hitId = document.getElementsByName("hitId")[0].value;
var captchanum = 35;
var count = 0;
if (GM_getValue("captcha_counter")){
    count = GM_getValue("captcha_counter");
    console.log("Count: "+count);
}


if (!this.GM_getValue || (this.GM_getValue.toString && this.GM_getValue.toString().indexOf("not supported")>-1)) {
    this.GM_getValue=function (key,def) {
        return localStorage[key] || def;
        };
    this.GM_setValue=function (key,value) {
        return localStorage[key]=value;
        };
}

if(window.location.href.indexOf("accept") > -1) {
    if ($('input[name="userCaptchaResponse"]').length > 0) {
    	count = 0;
    	GM_setValue("captcha_counter",count);
        console.log("Captcha found: "+count);
	}
    else{
    	if (hitId != "" && $('div[class="message error"]').length == 0){
	        console.log("Accepted Hit");
	        count+=1;
	        GM_setValue("captcha_counter",count);
            console.log((captchanum-count)+" hits left until captcha!");
            if (count == 35)
                alert("Next hit is a captcha!");
	        //alert((captchanum-count)+" hits left until captcha!");
	    }
	    else{
	        console.log("No hit accepted");
	    }
    }
    
}
if (captchanum-count == 1)
    captchaCountStr = (captchanum-count)+" hit left until captcha!";
else if (captchanum-count == 0)
    captchaCountStr = "Last hit before captcha!";
else
    captchaCountStr = (captchanum-count)+" hits left until captcha!";

$('#theTime').parent().parent().parent().append('<tr><td align="left" valign="top" class="title_orange_text" nowrap="" style="padding-top: 3px; padding-left: 5px;"><b>Captcha:</b> <span>' + captchaCountStr + '</span></td></tr>');