JR Mturk Noblis Image Finder Helper

Makes it easier to select answer for images of people.

当前为 2016-06-21 提交的版本,查看 最新版本

// ==UserScript==
// @name        JR Mturk Noblis Image Finder Helper
// @namespace   https://gf.qytechs.cn/users/6406
// @description Makes it easier to select answer for images of people.
// @version     0.11
// @require     http://code.jquery.com/jquery-1.10.2.min.js
// @include     http*://s3.amazonaws.com/TurkAnnotator*
// @grant       none
// ==/UserScript==

var OPEN_URL_AUTO = true;
var CLOSE_POPWINDOW_AFTER = true;

var gQuestions = [];
var gQuestionIndex = 0;
var gOpenedWindow = null;
var gSubmitGo = false;

function isNoblisIMages() {
    var theValue = $('#instructions_subject_present:contains("Determine whether the person represented by this google image link")').length;
    if ($("#instructions_subject_present").css('display') == "block") return theValue;
    else return false;
}
function isNoblisEyeIMages() {
    var theValue = $('#instructions_eyes_visible:contains("focus on the eye region of the boxed face in each image")').length;
    if ($("#instructions_eyes_visible").css('display') == "block") return theValue;
    else return false;
}
function isNoblisMouthIMages() {
    var theValue = $('#instructions_nose_mouth_visible:contains("focus on the nose and mouth region of the boxed face in each image")').length;
    if ($("#instructions_nose_mouth_visible").css('display') == "block") return theValue;
    else return false;
}
function isNoblisForeheadIMages() {
    var theValue = $('#instructions_forehead_visible:contains("focus on the forehead region of the boxed face in each image as shown below")').length;
    if ($("#instructions_forehead_visible").css('display') == "block") return theValue;
    else return false;
}
function isNoblisFacialHairIMages() {
    var theValue = $('#instructions_facial_hair:contains("Select the facial hair type that is closest to the person shown below")').length;
    if ($("#instructions_facial_hair").css('display') == "block") return theValue;
    else return false;
}
function isNoblisIndoorOutdoorIMages() {
    var theValue = $('#instructions_indoor_outdoor:contains("For this task, choose \"Indoor\" when:")').length;
    if ($("#instructions_indoor_outdoor").css('display') == "block") return theValue;
    else return false;
}
function isNoblisRightEye() {
    var theValue = $('#instructions_right_eye_landmark:contains("Click on the center of the person\'s right eye as shown below. The center")').length;
    if ($("#instructions_right_eye_landmark").css('display') == "block") return theValue;
    else return false;
}
function isNoblisLeftEye() {
    var theValue = $('#instructions_left_eye_landmark:contains("Click on the center of the person\'s left eye as shown below. The center of the eye")').length;
    if ($("#instructions_left_eye_landmark").css('display') == "block") return theValue;
    else return false;
}
function isNoblisNoseBase() {
    var theValue = $('#instructions_nose_base_landmark:contains("Click on the center of the base of the person\'s nose as shown below. The base")').length;
    if ($("#instructions_nose_base_landmark").css('display') == "block") return theValue;
    else return false;
}

$(function() {
    setTimeout( function() {
        if ( isNoblisIMages() ) {
            console.log("Found Noblis Images");
            if (OPEN_URL_AUTO) {
                var personLink = $("#person_link").attr("href");
                var windowWidth = "width=" + screen.width/2;
                var windowHeight = "height=" + (screen.height-(screen.height/10));
                var windowPosition = "left=0," + windowHeight + "," + windowWidth + ",top=0";
                if (personLink) {
                    gOpenedWindow = window.open(personLink,"imagesearch",windowPosition)
                    if (gOpenedWindow) gOpenedWindow.blur();
                    window.focus();
                }
            }
            if ($("#img_boundary")) {
                $("#img_boundary > div").each( function(i,theObject) {
                    if (i>0) {
                        $(theObject).find("div:first").width("140px");
                        $(theObject).find("img:first").css( {marginLeft : "130px"} );
                        $(theObject).find(":radio:eq(0)")[0].nextSibling.nodeValue = "Present (1)";
                        $(theObject).find(":radio:eq(1)")[0].nextSibling.nodeValue = "Not Present (2)";
                        $(theObject).find(":radio:eq(1)").click();
                        $(theObject).find(":radio:eq(2)")[0].nextSibling.nodeValue = "Can't tell (3)";
                        $(theObject).find(":radio:eq(3)")[0].nextSibling.nodeValue = "no Image (0)";
                        gQuestions.push(theObject);
                    }
                });
                $(gQuestions[gQuestionIndex]).css( "background-color", "#66CCCC" );
                $(document).keydown(function(event) {
                    //console.log(gQuestions.length);
                    if (gQuestionIndex<gQuestions.length) {
                        var goToNext = false;
                        if (event.which == 49 || event.which == 97) { // 1 - Present
                            $(gQuestions[gQuestionIndex]).find(":radio:eq(0)").click();
                            goToNext=true;
                        }
                        if (event.which == 50 || event.which == 98) { // 2 - Not Present
                            $(gQuestions[gQuestionIndex]).find(":radio:eq(1)").click();
                            goToNext=true;
                        }
                        if (event.which == 51 || event.which == 99) { // 3 - Can't Tell
                            $(gQuestions[gQuestionIndex]).find(":radio:eq(2)").click();
                            goToNext=true;
                        }
                        if (event.which == 48 || event.which == 96) { // 0 - Image Not Loaded
                            $(gQuestions[gQuestionIndex]).find(":radio:eq(3)").click();
                            goToNext=true;
                        }
                        if (goToNext) {
                            $(gQuestions[gQuestionIndex]).css( "background-color", "" );
                            gQuestionIndex++;
                            if (gQuestionIndex>=gQuestions.length) $("#button_div").css( "background-color", "#66CCCC" );
                            else {
                                $('html, body').animate({
                                    scrollTop: $(gQuestions[gQuestionIndex]).offset().top-21
                                }, 700);
                                $(gQuestions[gQuestionIndex]).css( "background-color", "#66CCCC" );
                            }
                        }
                    } else if (	event.which == 13) {
                        $("#submitbutton").click();
                        event.preventDefault();
                        event.stopPropagation();
                        if (OPEN_URL_AUTO && CLOSE_POPWINDOW_AFTER && gOpenedWindow) gOpenedWindow.close();
                   }
                });
            }
        } else if ( isNoblisRightEye() || isNoblisLeftEye() || isNoblisNoseBase() ) {
            console.log("left or right eye or Nose Base"); // nextbutton notvisiblebutton
            $("#nextbutton").html($("#nextbutton").html() + " (1)");
            $("#notvisiblebutton").html($("#notvisiblebutton").html() + " (2)");
            $(document).keydown(function(event) {
                if (event.which == 49 || event.which == 97) { // 1 - Next
                    if ($("#submitbutton").css('display') == "none") {
                        $("#nextbutton").click();
                        $("#nextbutton").css("background-color","#66FFFF");
                        $("#notvisiblebutton").css("background-color","#E8E8E8");
                    } else if ($("#submitbutton").css('display') == "inline") $("#submitbutton").click();
                }
                if (event.which == 50 || event.which == 98) { // 2 - Not Visible
                    $("#notvisiblebutton").click();
                    $("#notvisiblebutton").css("background-color","#66FFFF");
                    $("#nextbutton").css("background-color","#E8E8E8");
                }
            });
        } else if ( isNoblisEyeIMages() || isNoblisMouthIMages() || isNoblisForeheadIMages() || isNoblisFacialHairIMages() || isNoblisIndoorOutdoorIMages() ) {
			var facialHairHit = isNoblisFacialHairIMages();
			var indoorOutdoorHit = isNoblisIndoorOutdoorIMages();
			$("#nextbutton").focus();
			$("#annotator_div").append($("<div>").css({"margin-top":"300px"}));
			$("#annotator_div input:radio").each( function(index,value) {
				$("#annotator_div").find(":radio:eq(" + index + ")")[0].nextSibling.nodeValue = "(" + (index+1) + ") " + $("#annotator_div").find(":radio:eq(" + index + ")")[0].nextSibling.nodeValue;
			});
			var theCanvas =  ($("#thecanvas").length) ? $("#thecanvas") : $("#img_boundary");
			$('html, body').animate({
				scrollTop: $(theCanvas).offset().top-25
			}, 700);
            $(document).keydown(function(event) {
				var goToNext = false;
                if (event.which == 49 || event.which == 97) { // 1 - Covered Or Beard or indoor
                    if (indoorOutdoorHit) $("input[value='indoor']:first").click();
                    else if (facialHairHit) $("input[value='beard']:first").click();
                    else $("input[value='covered or partially covered']:first").click();
					goToNext=true;
                }
                if (event.which == 50 || event.which == 98) { // 2 - Not Covered or Moustache or outdoor
                    if (indoorOutdoorHit) $("input[value='outdoor']:first").click();
                    else if (facialHairHit) $("input[value='moustache']:first").click();
                    else$("input[value='not covered']:first").click();
					goToNext=true;
                }
                if (event.which == 51 || event.which == 99) { // 3 - bad box or Goatee
                    if (facialHairHit) $("input[value='goatee']:first").click();
                    else $("input[value='bad box']:first").click();
					goToNext=true;
                }
                if (event.which == 52 || event.which == 100 && facialHairHit) { // 4 - none
                    $("input[value='none']:first").click();
					goToNext=true;
                }
                if (event.which == 53 || event.which == 101 && facialHairHit) { // 5 - not visible
                    $("input[value='not visible']:first").click();
					goToNext=true;
                }
                if (event.which == 54 || event.which == 102 && facialHairHit) { // 6 - bad box
                    $("input[value='bad box']:first").click();
					goToNext=true;
                }
				if (goToNext) {
					if ($("#submitbutton").css("display") == "none") setTimeout( function() { 
							$("#nextbutton").click(); $("#nextbutton").focus(); 
							var theCanvas =  ($("#thecanvas").length) ? $("#thecanvas") : $("#img_boundary");
							$('html, body').animate({
								scrollTop: $(theCanvas).offset().top-25
							}, 700);
						}, 400);
					else { $("#submitbutton").focus(); gSubmitGo = true; }
				}
                if (event.which == 13 && !gSubmitGo) { // enter
					return false;
				}
            });
		}
    }, 1303);
});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址