// ==UserScript==
// @name DCF - Shoe feature labelling
// @version 1.1
// @require https://code.jquery.com/jquery-2.1.4.min.js
// @include https://s3.amazonaws.com/mturk_bulk/hits*
// @include https://www.mturkcontent.com/dynamic/*
// ==/UserScript==
if ($('td:contains("Shoe feature labelling")').length){
var image_scaling = 2.0;
$('td:contains("Common Ambiguities")').wrapInner('<div class="instructions"></div>');
$(".instructions").before('<button id="toggle" type="button"><span>Show Instructions</span></button>').hide();
$('#toggle').click(function() {
$(".instructions").toggle();
$('#toggle').text() == 'Show Instructions' ? str = 'Hide Instructions' : str = 'Show Instructions';
$('#toggle span').html(str);
});
$('table:eq(1)').after('<img src="' + $('td:contains("Link to shoe image")').next().find('a').attr('href') + '">');
$('img').click(function(){
if ($(this).hasClass('zoomed')){
$(this).width($(this).width ()/image_scaling);
$(this).toggleClass('zoomed');
}
else{
$(this).width($(this).width ()*image_scaling);
$(this).toggleClass('zoomed');
}
});
$('table:eq(2) tr').append('<td class="filler"></td>');
$('.filler').each(function(index){
var fill_options = [];
$(this).prev().find('option').each(function(){
fill_options.push($(this).text().replace(/^\w\)/,'').split(':')[0]);
});
$(this).html('<span class="options_list' + index + '">' + fill_options.join('</span> | <span class="options_list' + index + '">') + '</span>');
});
$('[class^=options_list]').click(function(){
$(this).parent().prev().find('select')[0].selectedIndex = $(this).parent().find('[class^=options_list]').index($(this));
$('[class=' + $(this).attr('class') + ']').css('background-color','');
$(this).css('background-color','lightgreen');
});
$('table:eq(2) tr').each(function(){
$(this).find('span:last')[0].click();
});
}