ProductRnR

Marks a default radio button depending on the HIT.

Versión del día 26/10/2015. Echa un vistazo a la versión más reciente.

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Necesitará instalar una extensión como Tampermonkey para instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         ProductRnR
// @namespace    https://greasyfork.org/users/11580
// @version      1.5.3
// @description  Marks a default radio button depending on the HIT.
// @author       Kadauchi
// @icon         http://www.mturkgrind.com/data/avatars/l/1/1084.jpg?1432698290
// @include      https://www.mturkcontent.com/dynamic/*
// @grant        GM_log
// @require      http://code.jquery.com/jquery-2.1.4.min.js
// ==/UserScript==

// Marks radio buttons.
$(".label.nal").click();
$("input[value='notadult']").click(); // Marks Non-Adult.

// Checks to see if we are on Label images based on their relevance for the query.
if ($("b:contains(Unrelated/Only Indirectly Related)").length){
	ProductRnR_Relevance_Query();
}

function ProductRnR_Relevance_Query(){
	$(":radio").on('change',function(){
		$(this).next(":contains(Related)").parent().parent().css("opacity", "1").css({ backgroundColor: "lightgreen", opacity: "1"});
		$(this).next(":contains(Unrelated/Indirectly Related)").parent().parent().css("opacity", "1").css({ backgroundColor: "red", opacity: "1"});
		$(this).next(":contains(Image didn't load)").parent().parent().css({ backgroundColor: "", opacity: "0.1"});
	});
	$("input[value='QueryImage_Unrelated']").prop("checked", true).change();
	$(".documentbox").click(function(e){e.preventDefault();});
	$('.documentbox').contextmenu( function() {
		return false;
	});
	$(".documentbox").mousedown(function(e){
		switch (e.which) {
			case 1:
				if($(this).find("input:radio:checked").next(":contains(Related):not(:contains('Unrelated'))").length > 0){
					$(this).find("input[value='QueryImage_Unrelated']").prop("checked", true).change();return false;
				}
				if($(this).find("input:radio:checked").next(":contains(Image didn't load)").length > 0){
					$(this).find("input[value='QueryImage_Related']").prop("checked", true).change();return false;
				}
				if($(this).find("input:radio:checked").next(":contains(Unrelated/Indirectly Related)").length > 0){
					$(this).find("input[value='QueryImage_Related']").prop("checked", true).change();return false;
				}
				break;
			case 3:
				$(this).find("input[value='NoLoad']").prop("checked", true).change();return false;
				break;
		}
	});
	$("img").error(function(){
		$(this).parents(".documentbox").find("input[value='NoLoad']").prop("checked", true).change();
	});
}

// Checks to see if we are on mark excellent HITs.
if ($("b:contains(excellent)").length){
	ProductRnR_Excellent();
}

function ProductRnR_Excellent(){
	$(":radio").on('change',function(){
		$(this).next(":contains(Excellent)").parent().parent().css("opacity", "1").css({ backgroundColor: "lightgreen", opacity: "1"});
		$(this).next(":contains(Not Excellent)").parent().parent().css("opacity", "1").css({ backgroundColor: "red", opacity: "1"});
		$(this).next(":contains(Image didn't load)").parent().parent().css({ backgroundColor: "", opacity: "0.1"});
	});
	$("input[value='Excellent']").prop("checked", true).change();
	$(".documentbox").click(function(e){e.preventDefault();});
	$('.documentbox').contextmenu( function() {
		return false;
	});
	$(".documentbox").mousedown(function(e){
		switch (e.which) {
			case 1:
				if($(this).find("input:radio:checked").next(":contains(Excellent):not(:contains('Not'))").length > 0){
					$(this).find("input[value='Bad']").prop("checked", true).change();return false;
				}
				if($(this).find("input:radio:checked").next(":contains(Image didn't load)").length > 0){
					$(this).find("input[value='Excellent']").prop("checked", true).change();return false;
				}
				if($(this).find("input:radio:checked").next(":contains(Not Excellent)").length > 0){
					$(this).find("input[value='Excellent']").prop("checked", true).change();return false;
				}
				break;
			case 3:
				$(this).find("input[value='NoLoad']").prop("checked", true).change();return false;
				break;
		}
	});
	$("img").error(function(){
		$(this).parents(".documentbox").find("input[value='NoLoad']").prop("checked", true).change();
	});
}

// Enter will submit the HIT.
window.onkeydown = function(event) {
	if (event.keyCode === 13) {
		$("button[name='SubmitButton']").click();
	}
};