JR zing receipt helper for mturk.com

A script for zings with buttons to make it easier to submit and allows keyboard shortcuts.

当前为 2014-11-25 提交的版本,查看 最新版本

// ==UserScript==
// @name        JR zing receipt helper for mturk.com
// @version     0.4
// @namespace   https://gf.qytechs.cn/users/6406
// @description A script for zings with buttons to make it easier to submit and allows keyboard shortcuts.
// @author      John Ramirez (JohnnyRS)
// @include     http*://*ibotta.com/duplicate_receipt_moderation/*
// @grant       none
// ==/UserScript==

// 0.4 - Added buttons at top. Allows keypad numbers to work. Hides the instructions at top.
// This script will hide the instructions but you can click on the instruction text to show the full
// instructions again. You will see 2 buttons at the top of the receipts for easy access. If the receipts
// are different then click on the first button. If they are the same then click on the second button.
// Once you push a button it will fill in the bottom radio buttons and submit the hit. You can also use
// keyboard shortcuts to make it easier but it will not submit the hit after. Pressing n or 1 will select
// the no option and focus on the submit button. Pressing y or 2 will select the yes option and focus on
// the submit button. Then you can press enter to submit the hit or click the submit button.
// This makes it a non auto submit script and won't cause problems with other hits.


var gLogging = false, gDebugging = true;
if (typeof console.log == 'function') gLogging = gDebugging; // Fix for browsers without console.log
else gDebugging=false;

function createButton(theId,theValue,theName,theStyle) {
    var theButton = document.createElement("INPUT"); theButton.id = theId;
    theButton.value = theValue;
    theButton.type = "button";
	if (typeof theName !== "undefined") theButton.name = theName;
	if (typeof theStyle !== "undefined") theButton.setAttribute("style",theStyle);
    return theButton;
}
function createMyElement(theElement,theClass,theId) {
    var theElement = document.createElement(theElement);
	  if (theId) theElement.id = theId;
    if (theClass) theElement.className = theClass;
    return theElement;
}
function searchInnerText(node,theText) {
	return node.innerHTML.indexOf(theText);
}
function searchInClass(theClass,theIndex,theText) {
	var classNode = document.getElementsByClassName(theClass)[theIndex];
	if (typeof classNode !== 'undefined') {
	   var retVal = searchInnerText(classNode,theText);
	   return (retVal!=-1) ? classNode.innerHTML.substr(retVal) : retVal;
	}
}
function toggleInstructions(theDiv) {
    arguments.callee.hiddenToggle = arguments.callee.hiddenToggle || false;
    arguments.callee.hiddenToggle = !arguments.callee.hiddenToggle;
	theDiv.style.overflow="hidden";
	if (arguments.callee.hiddenToggle) {
	   theDiv.style.height="25px";
	} else {
	   theDiv.style.height="auto";
	}
}
function moveInDiv(theNode,nodeNumbers) {
	var removedNode = null;
    var myDiv = createMyElement("div","theInstructions");
    var myH1 = createMyElement("h1","toggleMe");
    myH1.appendChild(document.createTextNode("Click here to show/hide instructions!"));
    myH1.setAttribute("style","color:blue;");
    myDiv.appendChild(myH1);
    for (var i=0; i<nodeNumbers+1; i++) {
       removedNode = theNode.removeChild(theNode.children[0]);
       myDiv.appendChild(removedNode);        
    }
	return myDiv;
}
function answerRadio(theRadio,submitButton,submitMe) {
	window.scrollTo(0,document.body.scrollHeight +20);
	theRadio.checked=true;
	if (submitMe) submitButton.click();     // Only when one of my buttons are pressed.
	else submitButton.focus();              // Only gives focus to the submit button and will not auto submit it for pressing keys.
}

if (searchInClass("warning",0,"ATTENTION: We are actively monitoring quality. Workers who repeatedly ignore the instructions")) {
    if (gDebugging && gLogging) console.log(".found a zing I can work with");
    
    var container = document.getElementsByClassName("container")[1];
    var instructions = moveInDiv(container,5);
    container.insertBefore(instructions,container.firstChild);
    
    var noDuplicates = document.getElementById("duplicatefalse");
    var yesDuplicates = document.getElementById("duplicatetrue");
    var submitButton = document.getElementsByClassName("submitctrl")[0].getElementsByClassName("btn")[0];
    
    var receipts = document.getElementsByClassName("row")[1];
    var liNodes = document.getElementsByTagName("li");
    var noBtn = createButton("noButton","No - DIFFERENT receipts (n) (1)","","margin-left: 25px; padding: 2px 40px;")
    var yesBtn = createButton("yesButton","Yes - Same receipts (y) (2)","","margin-left: 25px; padding: 2px 40px;")
    noBtn.onclick = function() { answerRadio(noDuplicates,submitButton,true); };
    yesBtn.onclick = function() { answerRadio(yesDuplicates,submitButton,true); };
	
    var myDiv = createMyElement("div","row");
    myDiv.setAttribute("style","padding:10px 0 20px 0; text-align:center;");
    myDiv.appendChild(noBtn);
    myDiv.appendChild(yesBtn);
    receipts.parentNode.insertBefore(myDiv, receipts);
    var theDivInstructions = document.getElementsByClassName("theInstructions")[0];
    toggleInstructions(theDivInstructions);
    theDivInstructions.onclick = function() { toggleInstructions(theDivInstructions); };
	
    document.onkeydown = function (e) {
        if (e.keyCode == 78 || e.keyCode == 49 || e.keyCode == 97) {                     // n=(78) or 1=(49)(97) pressed
			answerRadio(noDuplicates,submitButton);
        } else if (e.keyCode == 89 || e.keyCode == 50 || e.keyCode == 98) {              // y=(89) or 2=(50)(98) pressed
			answerRadio(yesDuplicates,submitButton);
        }
    };
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址