// ==UserScript==
// @name Kadabot Export
// @namespace http://kadauchi.com/
// @version 1.0.0
// @description Does stuff.
// @author Kadauchi
// @icon http://kadauchi.com/avatar4.jpg
// @include /^https://www\.mturk\.com/mturk/(searchbar|findhits|viewhits|viewsearchbar|sortsearchbar|sorthits)/
// @grant GM_log
// @require https://code.jquery.com/jquery-3.1.0.min.js
// ==/UserScript==
var mtc_username = 'kadabot';
var $hits = $('table[cellpadding="0"][cellspacing="5"][border="0"][border="0"]').children('tbody').children('tr');
for (var i = 0; i < $hits.length; i++) {
$hits.eq(i).find('a.capsulelink').after('<button class="export" value="' + i + '" style="margin-left: 3px;">Export</button>');
}
$('button.export').click(function () {
var reque = $hits.eq($(this).val()).find('span.requesterIdentity').text().trim();
var title = $hits.eq($(this).val()).find('a.capsulelink').text().trim();
var confi = confirm('Are you sure you want to export this HIT?\n\nRequester: ' + reque + '\n\nTitle: ' + title);
if (confi === true) {
_send($hits.eq($(this).val()).html());
}
});
function _send (data) {
$.post('http://162.243.142.80:8080/export-hit',{data: data, user: mtc_username});
}