您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
A script add on for Panda Crazy sending commands to main script.
当前为
// ==UserScript== // @name JR Mturk Panda Crazy Helper // @version 0.3.3 // @namespace https://greasyfork.org/users/6406 // @description A script add on for Panda Crazy sending commands to main script. // @include http*://www.mturk.com/mturk/myhits* // @include http*://www.mturk.com/mturk/findhits* // @include http*://www.mturk.com/mturk/sorthits* // @include http*://www.mturk.com/mturk/viewhits* // @include http*://www.mturk.com/mturk/searchbar* // @include http*://www.mturk.com/mturk/sortsearchbar* // @include http*://www.mturk.com/mturk/sortmyhits* // @include http*://www.mturk.com/mturk/findquals* // @include http*://www.mturk.com/mturk/status* // @include http*://www.mturk.com/mturk/transferearnings* // @include http*://www.mturk.com/mturk/youraccount* // @include http*://www.mturk.com/mturk/pendingquals* // @include http*://www.mturk.com/mturk/requestqualification* // @include http*://www.mturk.com/mturk/previewandaccept?* // @include http*://www.mturk.com/mturk/preview?* // @include http*://www.mturk.com/mturk/accept?* // @include http*://www.mturk.com/mturk/continue?* // @include http*://www.mturk.com/mturk/return* // @include http*://www.mturk.com/mturk/submit* // @include http*://www.mturk.com/mturk/dashboard* // @include http*://worker.mturk.com/* // @include http*://*mturkcrowd.com/threads/* // @include http*://*turkerhub.com/threads/* // @include http*://*mturkforum.com/showthread* // @include http*://*turkernation.com/showthread* // @include http*://www.reddit.com/r/HITsWorthTurkingFor* // @exclude http*://*mturk.com/mturk/findhits?*hit_scraper* // @require http://code.jquery.com/jquery-2.1.4.min.js // @grant GM_getValue // @grant GM_setValue // @grant GM_deleteValue // ==/UserScript== var gScriptVersion = "0.3.3"; var gScriptName = "pandacrazy"; var gLocation = window.location.href; var gOtherScripts = {"TPE":-1,"HDM":-1,"PEFT":-1,"MTSPE":-1}; var gScriptsCounter = {"TPE":-1,"HDM":-1,"PEFT":-1,"MTSPE":-1}; var gConstantSearch = null; var gJobDataDefault = {"requesterName":"","requesterId":"","groupId":"","pay":"","title":"","duration":"0","hitsAvailable":0,"timeLeft":"","totalSeconds":0,"hitId":"","qual":"", "continueURL":"","returnURL":"","durationParsed":{},"jobNumber":"-1","friendlyRName":"","friendlyTitle":"","assignedOn":"","description":"","keywords":"","timeData":{}, "assignmentID":"","hitSetID":""}; function createMessageData(command,data) { return {"time":(new Date().getTime()),"command":command,"data":data}; } function sendCommandMessage(data) { localStorage.setItem("JR_message_" + gScriptName, JSON.stringify(data)); } function createQueueData(length) { return {"queueLength":length}; } function createProjectedData(earnings) { return {"projectedEarnings":earnings}; } function createJobData(jobData) { return {"groupId":jobData.groupId,"title":jobData.title,"requesterName":jobData.requesterName,"requesterId":jobData.requesterId, "pay":jobData.pay,"duration":jobData.duration,"hitsAvailable":jobData.hitsAvailable}; } function setAttributes(el, attrs) { for (var key in attrs) { el.setAttribute(key, attrs[key]); } } function elementInit(theElement,theClass,theText,theStyle) { if (theClass) theElement.className = theClass; if (theText) theElement.textContent = theText; if (theStyle) theElement.style = theStyle; return theElement; } function createSpan(theClass,theText,theStyle) { var span = document.createElement("span"); return elementInit(span,theClass,theText,theStyle); } function createSpanButton(toDo,theClass,theText,theBackgroundColor,theColor,theFontSize,addStyle) { var backgroundColor = (typeof theBackgroundColor != 'undefined') ? theBackgroundColor : "initial"; var textColor = (typeof theColor != 'undefined') ? theColor : "initial", fontSize = (typeof theFontSize != 'undefined') ? theFontSize : "9px"; var theButton = createSpan("nonselectable " + theClass,theText,"font-size:" + fontSize + "; padding:0px 2px; background-color:" + backgroundColor + "; color:" + textColor + "; border:2px groove darkgrey; cursor:default; margin:0px 1px;" + addStyle); if (toDo) theButton.addEventListener("click", function (e) { toDo(e); }); return theButton; } function speakThisNow(thisText) { if('speechSynthesis' in window){ var speech = new SpeechSynthesisUtterance(thisText); speech.lang = 'en-US'; window.speechSynthesis.speak(speech); } } function getTimeLeft(theTime) { if (theTime!==null && theTime!=="") { var tempArray = (theTime.indexOf("second") != -1) ? theTime.split("second")[0].trim().split(" ") : null; var seconds = (tempArray) ? parseInt(tempArray[tempArray.length-1]) : 0; tempArray = (theTime.indexOf("minute") != -1) ? theTime.split("minute")[0].trim().split(" ") : null; var minutes = (tempArray) ? parseInt(tempArray[tempArray.length-1]) : 0; tempArray = (theTime.indexOf("hour") != -1) ? theTime.split("hour")[0].trim().split(" ") : null; var hours = (tempArray) ? parseInt(tempArray[tempArray.length-1]) : 0; tempArray = (theTime.indexOf("day") != -1) ? theTime.split("day")[0].trim().split(" ") : null; var days = (tempArray) ? parseInt(tempArray[tempArray.length-1]) : 0; tempArray = (theTime.indexOf("week") != -1) ? theTime.split("week")[0].trim().split(" ") : null; var weeks = (tempArray) ? parseInt(tempArray[tempArray.length-1]) : 0; return( {"weeks":weeks,"days":days,"hours":hours,"minutes":minutes,"seconds":seconds} ); } else return null; } function formatTimeLeft(resetNow,thisDigit,timeString,lastDigit) { formatTimeLeft.timeFill = formatTimeLeft.timeFill || 0; if (resetNow) formatTimeLeft.timeFill = 0; var missingDigit = (lastDigit!="0" && thisDigit=="0") ? true : false; if (( thisDigit!="0" || missingDigit) && formatTimeLeft.timeFill<2) { formatTimeLeft.timeFill++; if (missingDigit) { return "00 " + timeString + "s"; } else { var addZero = (thisDigit<10) ? ((formatTimeLeft.timeFill==1) ? false : true) : false, plural = (thisDigit==1) ? false : true; return ((addZero) ? "0" : "") + thisDigit + " " + ((plural) ? (timeString+"s") : timeString) + " "; } } else return ""; } function convertToTimeString(timeData) { var returnString = ""; returnString += formatTimeLeft(true,timeData.weeks,"week",false); returnString += formatTimeLeft(false,timeData.days,"day",timeData.weeks); returnString += formatTimeLeft(false,timeData.hours,"hour",timeData.days); returnString += formatTimeLeft(false,timeData.minutes,"minute",timeData.hours); returnString += formatTimeLeft(false,timeData.seconds,"second",timeData.minutes); return returnString.trim(); } function convertTimeToSeconds(timeData) { var totalSeconds = timeData.seconds + ((timeData.minutes) ? (timeData.minutes*60) : 0) + ((timeData.hours) ? (timeData.hours*3600) : 0) + ((timeData.days) ? (timeData.days*86400) : 0) + ((timeData.weeks) ? (timeData.weeks*604800) : 0); return totalSeconds; } function convertSecondsToTimeData(seconds) { var timeData = {}; timeData.weeks = Math.floor(seconds/604800); seconds = seconds - (timeData.weeks*604800); timeData.days = Math.floor(seconds/86400); seconds = seconds - (timeData.days*86400); timeData.hours = Math.floor(seconds/3600); seconds = seconds - (timeData.hours*3600); timeData.minutes = Math.floor(seconds/60); seconds = seconds - (timeData.minutes*60); timeData.seconds = seconds; return timeData; } function convertToSeconds(milliseconds,fixed) { fixed = fixed || 2; var seconds = parseFloat((milliseconds/1000.0 * 100) / 100).toFixed(fixed) + ""; return seconds.replace(/\.0*$/,""); } function convertToMilliseconds(seconds) { if (seconds) return seconds*1000 + ""; else return "0"; } function sendMessageData(command,theData) { var messageData = createMessageData(command,theData); sendCommandMessage(messageData); } function sendQueueData(queueLength) { sendMessageData("queueData",createQueueData(queueLength)); } function sendProjectedData(projectedEarnings) { sendMessageData("projectedEarnings",createProjectedData(projectedEarnings)); } function sendJobData(jobData) { sendMessageData("addJob",createJobData(jobData)); } function sendJobOnceData(jobData) { sendMessageData("addOnceJob",createJobData(jobData)); } function sendJobSearchData(jobData) { sendMessageData("addSearchJob",createJobData(jobData)); } function sendPingMessage() { localStorage.setItem("JR_message_ping_" + gScriptName, JSON.stringify({"command":"areYouThere","time":(new Date().getTime())})); } function appendPandaButtons(element,jobData) { $(element).append($("<span>").css({"font-size":"9px"}).html("Add: ") .append($("<button>").html("Panda").css({"font-size":"10px","line-height":"10px","padding":"1px","color":"black"}) .data("jobData",jobData).attr({"type":"button"}) .click(function(e) { sendJobData($(e.target).data("jobData")); return false; })) .append($("<button>").html("Once").css({"font-size":"10px","line-height":"10px","padding":"1px","color":"black"}) .data("jobData",jobData).attr({"type":"button"}) .click(function(e) { sendJobOnceData($(e.target).data("jobData")); return false; })) ); } function doSortResultsTable() { var sortResultsTable = $("#sortresults_form").next("table"); $(sortResultsTable).find("> tbody > tr").each(function(i, row) { var jobData = jQuery.extend(true, {}, gJobDataDefault); var titleElement = $("#capsule" + i + "-0"); var capsulelink = $(titleElement).closest("tr").find('.capsulelink a[href*="roupId="]').eq(0); jobData.groupId = (capsulelink.length) ? capsulelink.attr("href").split(/groupId=/i)[1] : ""; jobData.title = $(titleElement).text().trim(); var requesterElement = $(row).find(".requesterIdentity"); jobData.requesterName = $(requesterElement).text().trim(); jobData.requesterId = $(requesterElement).closest("a").attr("href").split("&requesterId=")[1]; jobData.duration = $("#duration_to_complete\\.tooltip--" + i).closest("tr").find(".capsule_field_text").text().trim(); jobData.hitsAvailable = $("#number_of_hits\\.tooltip--" + i).closest("tr").find(".capsule_field_text").text().trim(); var rewardTrTarget = $("#reward\\.tooltip--" + i).closest("tr"); jobData.pay = $(rewardTrTarget).find(".reward").text().replace("$","").trim(); $(rewardTrTarget).append($("<td rowspan='2' width='100%'>").append($("<div>") .attr({"class":"JR_PandaCrazy"}).css({"text-align":"center","width":"100%","display":"inline-block"}))); $(row).find(".JR_PandaCrazy").append($("<span>").html("[ PandaCrazy ]<br>")); appendPandaButtons($(row).find(".JR_PandaCrazy"),jobData); }); } function parseHitsInfo(reactInfo,finalUrl) { var jobData = jQuery.extend(true, {}, gJobDataDefault); jobData.hitSetID = reactInfo.hit_set_id; jobData.hitsAvailable = reactInfo.assignable_hits_count; jobData.continueURL = ""; jobData.returnURL = ""; jobData.groupId = reactInfo.hit_set_id; jobData.requesterName = reactInfo.requester_name; jobData.requesterId = reactInfo.requester_id; jobData.totalSeconds = reactInfo.assignment_duration_in_seconds; jobData.timeData = convertSecondsToTimeData(jobData.totalSeconds); jobData.title = reactInfo.title; jobData.timeLeft = convertToTimeString(jobData.timeData); jobData.pay = parseFloat(reactInfo.monetary_reward.amount_in_dollars).toFixed(2); jobData.duration = jobData.timeLeft; return jobData; } function parseNewHitPageRequesters(projectDetailBar,finalUrl) { var jobData = jQuery.extend(true, {}, gJobDataDefault); var tempPrevDiv = projectDetailBar[0].getElementsByClassName("col-sm-4 col-xs-5"); if (tempPrevDiv.length===0) tempPrevDiv = projectDetailBar[0].getElementsByClassName("col-md-6 col-xs-12"); // col-md-6 col-xs-12 if (tempPrevDiv.length===0) tempPrevDiv = projectDetailBar[0].getElementsByClassName("col-xs-12"); // col-xs-12 var reactInfo = tempPrevDiv[0].querySelector("div").dataset.reactProps; if (reactInfo) { reactInfo = JSON.parse(reactInfo).modalOptions; var contactRequesterUrl = reactInfo.contactRequesterUrl, contactVar = (contactRequesterUrl.indexOf("requester_id") != -1) ? "requester_id%5D=" : "requesterId="; jobData.hitsAvailable = reactInfo.assignableHitsCount; var thisTaskID = finalUrl.split("tasks/")[1]; jobData.hitId = (thisTaskID) ? thisTaskID.split("?")[0]: ""; var thisAssignmentID = finalUrl.split("assignment_id=")[1]; jobData.assignmentID = (thisAssignmentID) ? thisAssignmentID.split("&")[0]: ""; var thisGroupID = finalUrl.split("projects/")[1]; jobData.groupId = (thisGroupID) ? thisGroupID.split("/")[0]: ""; jobData.hitSetID = jobData.groupId; jobData.continueURL = finalUrl; jobData.returnURL = ""; jobData.requesterName = reactInfo.requesterName; tempContact = contactRequesterUrl.split(contactVar); if (tempContact.length) jobData.requesterId = contactRequesterUrl.split(contactVar)[1].split("&")[0]; jobData.totalSeconds = reactInfo.assignmentDurationInSeconds; jobData.timeData = convertSecondsToTimeData(jobData.totalSeconds); jobData.title = reactInfo.projectTitle; jobData.timeLeft = convertToTimeString(jobData.timeData); jobData.pay = parseFloat(reactInfo.monetaryReward.amountInDollars).toFixed(2); jobData.duration = jobData.timeLeft; } return jobData; } function sendHighestAmount() { var highestAmount = (gOtherScripts.MTSPE>gOtherScripts.TPE && gOtherScripts.MTSPE>gOtherScripts.HDM && gOtherScripts.MTSPE>gOtherScripts.PEFT) ? gOtherScripts.MTSPE : (gOtherScripts.TPE>gOtherScripts.HDM && gOtherScripts.TPE>gOtherScripts.PEFT) ? gOtherScripts.TPE : (gOtherScripts.HDM>gOtherScripts.PEFT) ? gOtherScripts.HDM : gOtherScripts.PEFT; sendProjectedData(highestAmount); } function searchThisUntil(scriptNN,searchThis,doThis,counterMax,reset) { if (!counterMax) return; gScriptsCounter[scriptNN]++; if (reset) gScriptsCounter[scriptNN] = 0; if (searchThis()) doThis(); else { if (gScriptsCounter[scriptNN]<counterMax) setTimeout( function() { searchThisUntil(scriptNN,searchThis,doThis,counterMax,false); },1000 ); } } function searchMTSPE(searchTimer) { searchThisUntil("MTSPE",function() { if ($("#tpe_earnings").length || $("mts-tpe-earnings").length) return true; else return false; },function() { var theEarnings = ($("#tpe_earnings").length) ? $("#tpe_earnings").text() : ($("mts-tpe-earnings").length) ? $("mts-tpe-earnings").text() : null; if (theEarnings) gOtherScripts.MTSPE = parseFloat(theEarnings.split("/")[0].replace("$","")); sendHighestAmount(); },searchTimer,true); } function searchTPE(searchTimer) { searchThisUntil("TPE",function() { if ($("#TPE_div a:contains('Today\\'s Projected Earnings')").length) return true; else return false; },function() { gOtherScripts.TPE = parseFloat($("#TPE_div .reward").html().replace("$","")); sendHighestAmount(); },searchTimer,true); } function searchHDM(searchTimer) { searchThisUntil("HDM",function() { var dbStatus = ($("#hdbStatusText").length) ? $("#hdbStatusText").html() : null; if (dbStatus!==null && (dbStatus==="" || dbStatus=="Update Complete!")) return true; else return false; },function() { gOtherScripts.HDM = parseFloat($("#projectedDayProgress").attr("value")); sendHighestAmount(); },searchTimer,true); } function searchPEFT(searchTimer) { searchThisUntil("PEFT",function() { if ($("a:contains('Projected Earnings for Today')").length) return true; else return false; },function() { var thisPEFT = $("a:contains('Projected Earnings for Today')").closest("td").next().html().replace("$",""); gOtherScripts.PEFT = parseFloat(thisPEFT); sendHighestAmount(); },searchTimer,true); } function findProjectedEarnings() { // find if Projected Earnings scripts are installed and get info. if ( ($("#tpe_earnings").length || $("mts-tpe").length) && gOtherScripts.MTSPE==-1) { searchMTSPE(40); } if ($("#TPE_div").length && gOtherScripts.TPE==-1) { searchTPE(40); $("#TPE_div a").click( function() { searchTPE(300); } ); } if ($("#projectedDayProgress").length && gOtherScripts.MHDM==-1) { searchHDM(40); $("#hdbUpdate").click( function() { searchHDM(2300); } ); } searchPEFT(70); } function pcContainer(thisGroupId,thisRequesterName,thisRequesterId,thisTitle) { var pcContainer = $(createSpan("PCSpanButtons","","")).append(document.createTextNode(" [PC] Add: ")) .append($(createSpanButton(function(e) { window.open("https://worker.mturk.com/requesters/PandaCrazyAdd/projects?JRGID=" + thisGroupId + "&JRRName=" + thisRequesterName + "&JRRID=" + thisRequesterId + "&JRTitle=" + thisTitle, "PandaCommand", "height=200,width=200"); },"","Panda", "lightgrey","red","11px"))) .append($(createSpanButton(function(e) { window.open("https://worker.mturk.com/requesters/PandaCrazyOnce/projects?JRGID=" + thisGroupId + "&JRRName=" + thisRequesterName + "&JRRID=" + thisRequesterId + "&JRTitle=" + thisTitle, "PandaCommand", "height=200,width=200"); },"","Once", "lightgrey","red","11px"))) .append($(createSpanButton(function(e) { window.open("https://worker.mturk.com/requesters/PandaCrazySearch/projects?JRGID=" + thisGroupId + "&JRRName=" + thisRequesterName + "&JRRID=" + thisRequesterId + "&JRTitle=" + thisTitle, "PandaCommand", "height=200,width=200"); },"","Search", "lightgrey","red","11px"))); return pcContainer; } function addMessageButtons(thisMessage) { var myContainer=null, thisGroupId=null, thisRequesterName=null, thisRequesterId=null, thisTitle=null; if ($(thisMessage).find(".ctaBbcodeTable, .cms_table").length) { var theAcceptUrl = $(thisMessage).find("a:contains('Accept')"), format=1; if (!theAcceptUrl.length) { format=2; theAcceptUrl = $(thisMessage).find("a:contains('PANDA')"); } if (theAcceptUrl.length) { thisGroupId = theAcceptUrl.attr("href").split("/projects/")[1].split("/tasks/")[0]; thisRequesterName = escape($(thisMessage).find("b:contains('Requester:')").next("a").text().trim()); thisRequesterId = ($(thisMessage).find("b:contains('Requester:')").next("a")).get(0).nextSibling.nodeValue.trim(); thisRequesterId = thisRequesterId.split("]")[0].replace("[","").replace("]",""); thisTitle = escape($(thisMessage).find("b:contains('Title:')").next("a").text().trim()); myContainer = pcContainer(thisGroupId,thisRequesterName,thisRequesterId,thisTitle); if ($(thisMessage).find("a:contains('Contact')").length) $(thisMessage).find("a:contains('Contact')").after($(myContainer)); else if ($(thisMessage).find("b:contains('TO Ratings:')").length) $(thisMessage).find("b:contains('TO Ratings:')").prev().before($(myContainer)); } } else if ($(thisMessage).find(".vw-div:first").length) { var vwDiv = $(thisMessage).find(".vw-div:first"); if (vwDiv.length && $(thisMessage).find("a:contains('PANDA')").length) { thisGroupId = $(thisMessage).find("a:contains('PANDA')").attr("href").split("/projects/")[1].split("/tasks/")[0]; thisRequesterName = escape($(thisMessage).find("a:first").text().trim()); thisRequesterId = $(thisMessage).find("span:first").text().trim(); thisRequesterId = thisRequesterId.split("]")[0].replace("[","").replace("]",""); thisTitle = escape($(thisMessage).find("i").text().trim()); myContainer = pcContainer(thisGroupId,thisRequesterName,thisRequesterId,thisTitle); $(vwDiv).prev().append(myContainer); } } else if ($(thisMessage).find("a[href*='turkerview.com/requesters/']").length) { var turkerviewNode = $(thisMessage).find("a[href*='turkerview.com/requesters/']"); var thisOne = $(thisMessage); if ($(thisMessage).find(".quoteContainer").length) thisOne = $(thisMessage).find(".quoteContainer"); thisGroupId = $(thisOne).find("a:first").attr("href").split("/projects/")[1].split("/tasks")[0]; thisRequesterName = escape($(thisOne).find("a[href*='worker.mturk.com/requesters']").get(0).previousSibling.nodeValue.slice(0, -2).trim().replace("Requester: ","")); thisRequesterId = $(turkerviewNode).attr("href").replace("https://turkerview.com/requesters/",""); thisTitle = escape($(thisOne).find("a:first").get(0).previousSibling.nodeValue.slice(0, -2).trim()); myContainer = pcContainer(thisGroupId,thisRequesterName,thisRequesterId,thisTitle); $(thisOne).find("a[href*='turkerview.com/requesters/']").prev().before(myContainer); } $(thisMessage).addClass("JRDoneButtonized"); } function addPageButtons() { $("blockquote:not('.quoteContainer, .JRDoneButtonized')").each( function() { addMessageButtons(this); }); } function mainListener(e) { if ( e.key == 'JR_message_pong_' + gScriptName && e.newValue && gLocation == (JSON.parse(e.newValue).url)) { window.removeEventListener("storage", mainListener, false); var noHitsError = ($("td.error_title:contains('There are currently no HITs assigned to you.')").length > 0), buttonPosition=null; var noHitsAlert = ($("#alertboxHeader:contains('There are currently no HITs assigned to you.')").length > 0); var returnedAlert = ($("#alertboxHeader:contains('The HIT has been returned.')").length > 0); if (gLocation.indexOf("mturk.com/mturk/myhits") != -1 || returnedAlert) { // Get queue number and data then send to Panda Crazy var queueLength = 0, queueData = null; if (noHitsError) { sendQueueData(0); } else { var numberQueueText = $("td.title_orange_text").html(); if (numberQueueText) { var words = numberQueueText.trim().split(' '); if ($.isNumeric(words[words.length - 2])) queueLength = parseInt(words[words.length - 2]); sendQueueData(queueLength); } } } else if (gLocation.indexOf("mturk/findhits") != -1 || gLocation.indexOf("mturk/sorthits") != -1 || gLocation.indexOf("mturk/sortsearchbar") != -1 || gLocation.indexOf("mturk/viewhits") != -1 || gLocation.indexOf("mturk/searchbar") != -1 || noHitsAlert) { // Add buttons to add pandas for Panda Crazy doSortResultsTable(); } else if (gLocation.indexOf("mturk.com/mturk/preview") != -1 || gLocation.indexOf("mturk.com/mturk/return") != -1 || gLocation.indexOf("mturk.com/mturk/submit") != -1 || gLocation.indexOf("mturk.com/mturk/continue") != -1) { var jobData = jQuery.extend(true, {}, gJobDataDefault); if ($("#alertBox").text().indexOf("There are no HITs in this group available") != -1) { jobData.groupId = gLocation.split("groupId=")[1].split("&")[0]; $("#alertBox").append($("<div>").attr({"id":"JR_PandaCrazyTop"}).append($("<span>").html("[Panda Crazy] "))); appendPandaButtons($("#JR_PandaCrazyTop"),jobData); doSortResultsTable(); } else { var capsulelinkElement = $("form[name='hitForm'] .capsulelink_bold"); var tableInfo = $(capsulelinkElement).closest("table").closest("table"); buttonPosition = $("#theTime").closest("td"); jobData.groupId = (gLocation.indexOf("groupId=") != -1) ? gLocation.split("groupId=")[1].split("&")[0] : ""; jobData.title = $(capsulelinkElement).find("div").text().trim(); jobData.requesterId = ($("input[name='requesterId']:first").val()) ? $("input[name='requesterId']:first").attr("value") : ""; var tempNameNode = $("#requester\\.tooltip").closest("td").nextAll(".capsule_field_text:first"); jobData.requesterName = (tempNameNode) ? (($(tempNameNode).find("a").length) ? $(tempNameNode).find("a").text() : $(tempNameNode).text()) : ""; jobData.requesterName = jobData.requesterName.trim(); jobData.duration = $("#time_left\\.tooltip").closest("td").next().text().trim(); jobData.hitsAvailable = $("#number_of_hits\\.tooltip").closest("td").next().text().trim(); jobData.pay = $("#reward\\.tooltip").closest("td").next().text().replace("$","").replace(" per HIT","").trim(); $(buttonPosition).append($("<div>").attr({"class":"JR_PandaCrazy"}).html("[PC] ")); appendPandaButtons($(".JR_PandaCrazy:first"),jobData); } } else if ( gLocation.indexOf("worker.mturk.com") != -1 ) { // ref=w_wp_acpt_top : accept | ref=w_wp_rtrn_top : return var projectDetailBar = $(".project-detail-bar"), requestersInfo={}; var mturkAlertDanger = $(".mturk-alert-danger"); if (mturkAlertDanger.length && $(mturkAlertDanger).find(".mturk-alert-content:contains('There are no more of these HITs available')")) { var savedGID = GM_getValue("JRHoldGID"); if (savedGID && savedGID!=="" && $("button:contains('Accept')").length === 0) { $(mturkAlertDanger).find(".p-b-0").append($("<span>").attr({"class":"JR_PandaCrazy"}).css({"font-size":"10px","margin-left":"10px"}).html("[PC] ")); var thisJobData = jQuery.extend(true, {}, gJobDataDefault); thisJobData.groupId = savedGID; appendPandaButtons($(mturkAlertDanger).find(".JR_PandaCrazy:first"),thisJobData); } } GM_deleteValue("JRHoldGID"); if (projectDetailBar.length) { requestersInfo = parseNewHitPageRequesters(projectDetailBar,gLocation); if ($("button:contains('Skip')").length) buttonPosition = $(".col-md-6.col-xs-12:first").find("div"); else if ($(".checkbox.m-y-0").length) buttonPosition = $(".col-md-6.col-xs-12:first").find(".col-sm-8.col-xs-7").find(".checkbox:first"); else buttonPosition = $(".col-md-6.col-xs-12:first").find(".col-sm-8.col-xs-7"); $(buttonPosition).append($("<span>").attr({"class":"JR_PandaCrazy"}).css({"font-size":"9px","margin-left":"10px"}).html("[PC] ")); appendPandaButtons($(".JR_PandaCrazy:first"),requestersInfo); } else { var projectsControls = $(".row.projects-info-header:first").next(); var tempPrevDiv = projectsControls[0].getElementsByClassName("col-xs-12"); var reactInfo = tempPrevDiv[0].querySelector("div").dataset.reactProps; reactInfo = JSON.parse(reactInfo).bodyData; $(".hit-set-table-row").bind("DOMSubtreeModified", function() { if ($(this).find(".expanded-row").length) { if (!$(this).data("JR-expandedDesc")) { $(this).data({"JR-expandedDesc":"true"}); var reactIDString = $(this).data("reactid"); var reactID = reactIDString.split("$")[1]; var thisJobData=parseHitsInfo(reactInfo[reactID]); $(this).find(".p-b-md").append($("<div>").attr({"class":"JR_PandaCrazy"}).css({"font-size":"10px","margin-left":"10px"}).html("[PC] ")); appendPandaButtons($(this).find(".JR_PandaCrazy:first"),thisJobData); } } else { $(this).removeData("JR-expandedDesc"); } }); } } else if (gLocation.indexOf("mturk.com/mturk/dashboard") != -1) { setTimeout( findProjectedEarnings,900 ); } } } $(function() { if (gLocation.indexOf("worker.mturk.com/requesters/PandaCrazy") != -1) { var sendFormat = (gLocation.indexOf("PandaCrazyAdd") != -1) ? 1 : (gLocation.indexOf("PandaCrazyOnce") != -1) ? 2 : (gLocation.indexOf("PandaCrazySearch") != -1) ? 3 : 0; if (sendFormat>0) { var jobData = jQuery.extend(true, {}, gJobDataDefault); if ( gLocation.indexOf("JRGID=") != -1) jobData.groupId = gLocation.split("JRGID=")[1].split("&")[0]; if ( gLocation.indexOf("JRRID=") != -1) jobData.requesterId = gLocation.split("JRRID=")[1].split("&")[0]; if ( gLocation.indexOf("JRRName=") != -1) jobData.requesterName = unescape(gLocation.split("JRRName=")[1].split("&")[0]); if ( gLocation.indexOf("JRTitle=") != -1) jobData.title = unescape(gLocation.split("JRTitle=")[1].split("&")[0]); if (sendFormat==1) sendJobData(jobData); else if (sendFormat==2) sendJobOnceData(jobData); else sendJobSearchData(jobData); setTimeout( function() { window.top.close(); },400); } } else if (gLocation.indexOf("mturk.com/") != -1) { $("a[href*='/projects/']").bind("click", function() { var secondPart = $(this).attr("href").split("/projects/")[1]; var thisGID = (secondPart) ? secondPart.split("/")[0] : ""; if (thisGID) GM_setValue("JRHoldGID",thisGID); }); if (gLocation.indexOf("www.mturk.com/") != -1) { $("a:contains('All HITs')").attr("href","https://www.mturk.com/mturk/findhits?match=false&doNotRedirect=true"); $("a:contains('HITs Available To')").attr("href","https://www.mturk.com/mturk/findhits?match=true&doNotRedirect=true"); $("a:contains('HITs Assigned')").attr("href","https://www.mturk.com/mturk/myhits?doNotRedirect=true"); $("a:contains('Dashboard')").attr("href","https://www.mturk.com/mturk/dashboard?doNotRedirect=true"); $("img[alt^='Your Account']").closest("a").attr("href","https://www.mturk.com/mturk/dashboard?doNotRedirect=true"); $("img[alt^='HITs']").closest("a").attr("href","https://www.mturk.com/mturk/findhits?match=false&doNotRedirect=true"); $("img[alt^='Qualifications']").closest("a").attr("href","https://www.mturk.com/mturk/findquals?earned=true&requestable=false&doNotRedirect=true"); $("img[src='/media/return_hit.gif']").closest("a").attr("href",$("img[src='/media/return_hit.gif']").closest("a").attr("href") + "&doNotRedirect=true"); $("#search_go_button").before("<input type='hidden' name='doNotRedirect' value='true'>"); $(".capsulelink:contains('Return this HIT')").find("a").each( function() { $(this).attr("href",$(this).attr("href") + "&doNotRedirect=true"); }); $(".requesterIdentity").closest("a").each( function() { $(this).attr("href",$(this).attr("href") + "&doNotRedirect=true"); }); $(".statusDateColumnValue").find("a").each( function() { $(this).attr("href",$(this).attr("href") + "&doNotRedirect=true"); }); $("form[name='statusDetailForm']").append("<input type='hidden' name='doNotRedirect' value='true'>"); $("form[name='statusDetailForm']").closest("td").next().find("a").each( function() { $(this).attr("href",$(this).attr("href") + "&doNotRedirect=true"); }); $("form[name='hitGroupsForm']").append("<input type='hidden' name='doNotRedirect' value='true'>"); $("form[name='hitGroupsForm']").find("a:not([href='#'])").each( function() { $(this).attr("href",$(this).attr("href") + "&doNotRedirect=true"); }); } else { if ( !$(".navbar-sub-nav.navbar-nav:contains('Your HITs Queue')").length ) { $(".nav.navbar-nav.hidden-xs-down:not(:contains('HITs Queue'))").append('<li class="nav-item"><a class="nav-link" href="https://worker.mturk.com/tasks">HITs Queue</a></li>'); } if ( $("button:contains('Return')").length ) { $(".col-xs-12.navbar-content a.navbar-brand:first").after("<div class='navbar-divider hidden-xs-down'></div><ul class='nav navbar-nav hidden-xs-down'><li class='nav-item'><a class='nav-link' style='color:white;' href='https://worker.mturk.com/tasks'>HITs Queue</a></li></ul>"); } } window.addEventListener("storage", mainListener, false); setTimeout( function() { sendPingMessage(); }, 500); } else { $("a[href*='/projects/']").bind("click", function() { var secondPart = $(this).attr("href").split("/projects/")[1]; var thisGID = (secondPart) ? secondPart.split("/")[0] : ""; if (thisGID) GM_setValue("JRHoldGID",thisGID); }); addPageButtons(); if ($('#messageList').length) { var targetObserveNode = $('#messageList')[0]; var config = { childList: true }; var callback = function(mutations) { for (var index = 0; index < mutations.length; index++) { addMessageButtons(mutations[index].addedNodes[0]); } }; var observer = new MutationObserver(callback); observer.observe(targetObserveNode, config); } } });