Makes it easier to select answer for images of people.
当前为
// ==UserScript==
// @name JR Mturk Noblis Image Finder Helper
// @namespace https://greasyfork.org/users/6406
// @description Makes it easier to select answer for images of people.
// @version 0.7
// @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 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() ) {
$("#nextbutton").focus();
$("#annotator_div").append($("<div>").css({"margin-top":"300px"}));
var nextSibling = $("#annotator_div").find(":radio:eq(0)")[0].nextSibling;
nextSibling.nodeValue = "(1) " + nextSibling.nodeValue;
nextSibling = $("#annotator_div").find(":radio:eq(1)")[0].nextSibling;
nextSibling.nodeValue = "(2) " + nextSibling.nodeValue;
nextSibling = $("#annotator_div").find(":radio:eq(2)")[0].nextSibling;
nextSibling.nodeValue = "(3) " + nextSibling.nodeValue;
$('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
$("input[value='covered or partially covered']:first").click();
goToNext=true;
}
if (event.which == 50 || event.which == 98) { // 2 - Not Covered
$("input[value='not covered']:first").click();
goToNext=true;
}
if (event.which == 51 || event.which == 99) { // 3 - bad box
goToNext=true;
$("input[value='bad box']:first").click();
}
if (goToNext) {
if ($("#submitbutton").css("display") == "none") setTimeout( function() {
$("#nextbutton").click(); $("#nextbutton").focus();
$('html, body').animate({
scrollTop: $("#thecanvas").offset().top-25
}, 700);
}, 400);
else { $("#submitbutton").focus(); gSubmitGo = true; }
}
if (event.which == 13 && !gSubmitGo) { // enter
return false;
}
});
}
}, 1303);
});