[Script] Panda Crazy Linker

Discussion in 'mTurk Scripts & Resources' started by ceedj, Dec 20, 2017.

  1. ceedj

    ceedj Survey Slinger

    Messages:
    2,767
    Gender:
    Male
    Ratings:
    +6,020
    Go hog wild with Panda Crazy buttons...everywhere!

    Nah, just puts them on the redirect page, grabbing the Group ID from a link. This was abandoned after JR got his Panda Crazy Helper buttons working on the forum, but looking for some lost Panda's on TurkerView brought it back to life!

    All you need to do to use it on your favorite mturk websites is to simply add it to the include section near the top of the script. Generally it should use the wildcard (*) at the end of the link, like in the code below. It should parse the old www links as well as most of the exporters. Still needs a bit of checking to keep it off certain mTurk pages, but it works well. Enjoy!

    Code:
    // ==UserScript==
    // @name         Panda Crazy Linker
    // @namespace    https://turkerhub.com/
    // @version      1.0
    // @description  Longshot, but we'll try...
    // @author       ceedj
    // @include      https://turkerview.com/requesters/*
    // @include      https://worker.mturk.com/projects*
    // @grant        GM_setValue
    // @grant        GM_getValue
    // @grant        GM_log
    // @require      https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
    // ==/UserScript==
    
    $(document).ready(function(){
        var FinalGID;
        var WorkGID;
        var TempGID;
        // JR's PC code, pretty much ripped from my own mod to Overwatch
        function PC_Once(){localStorage.setItem("JR_message_pandacrazy", JSON.stringify({"time":(new Date().getTime()),"command":"addOnceJob","data":{"groupId":FinalGID} }));}
        function PC_Panda(){localStorage.setItem("JR_message_pandacrazy", JSON.stringify({"time":(new Date().getTime()),"command":"addJob","data":{"groupId":FinalGID} }));}
    
    
           //      Referring site listener
        $('a').click(function () {
            var TempID1 = $(this).prop('href');
            if (TempID1.indexOf("groupId") != -1)
            {WorkGID = TempID1.split("=")[1]; //The split on www
    
            } else
                     if (TempID1.indexOf("/tasks") !=-1) //Spiltting Worker
              { switch (TempID1.length){
                case 98:
                    WorkGID = (TempID1).slice(34,-34);
                    break;
                case 84:
                    WorkGID = (TempID1).slice(34,-20);
                    break;
                case 71:
                    WorkGID = (TempID1).slice(34,-7);
                    break;
                case 70:
                    WorkGID = (TempID1).slice(34,-6);
                    break;
                default:
                    break;
                    //alert("This isn't a valid group ID buddy!");
            }
              GM_setValue("amtGID",WorkGID);
              }
    
            else {TempID1 = "null";}
        });
    
    //Temp mTurk listener - will only load on no more HITs pages, will load the last clicked Panda
            if(window.location.href.indexOf("https://worker.mturk.com/projects?filters") != -1) {
            var temor = GM_getValue("amtGID");
                FinalGID = temor;
                var HitDone = $('h3:contains(HIT submitted)'); //saving for a check later
    //Build the buttons
                $("span[class='h2 text-muted result-count-info']").after($("<button>").html("Once").css({"font-size":"16px","padding":"1px","color":"black"}).click(PC_Once));
                $("span[class='h2 text-muted result-count-info']").after($("<button>").html("Panda").css({"font-size":"16px","padding":"1px","color":"black"}).click(PC_Panda));
                $("span[class='h2 text-muted result-count-info']").append($("<span>").html("     [PC] Add: ").css({"font-size":"16px","line-height":"10px","padding":"1px","color":"black"}));
    
        } else {
            var HitDone2 = $('h3:contains(HIT submitted)');} //saving for a check later
    });
     
    • Like Like x 2
    • Today I Learned Today I Learned x 1
    Last edited: Dec 20, 2017