12/01 - Thirsty Thursday!

Discussion in 'Daily mTurk HITs Threads' started by TissueHime, Dec 1, 2016.

Thread Status:
Not open for further replies.
  1. rdaneel

    rdaneel Well-Known Turker

    Messages:
    315
    Gender:
    Male
    Ratings:
    +813
    No, they're not. ;)

    The most useful thing you can learn, is to use Chrome's Dev console, and to paste in Jquery [in the correct frame], and then, play there. Meaning, if you were in the console, you could type:
    Code:
    (':radio')
    
    and you'd see this:
    Code:
    [<input id="size" name="sizeCount" type="radio" value="Yes">, <input id="size" name="sizeCount" type="radio" value="No">, <input id="flavor" name="flavorScent" type="radio" value="Yes">, <input id="flavor" name="flavorScent" type="radio" value="No">, <input id="brand" name="sameBrand" type="radio" value="Yes">, <input id="brand" name="sameBrand" type="radio" value="No">, <input id="logo" name="sameLogo" type="radio" value="Yes">, <input id="logo" name="sameLogo" type="radio" value="No">, <input id="edition" name="sameEdition" type="radio" value="Yes">, <input id="edition" name="sameEdition" type="radio" value="No">, <input id="language" name="sameLanguage" type="radio" value="Yes">, <input id="language" name="sameLanguage" type="radio" value="No">, <input id="package" name="samePackage" type="radio" value="Yes">, <input id="package" name="samePackage" type="radio" value="No">, <input id="product" name="sameProduct" type="radio" value="Yes">, <input id="product" name="sameProduct" type="radio" value="No">]
    
    And you can just select:
    Code:
    $(':radio')[0].value
    "Yes"
    $(':radio')[1].value
    "No"
    
    So if you want to default to the two products being the same size, you can just:
    Code:
    $(':radio')[0].click()
    
    And there you are. [2] would be the yes for same flavor and/or scent, [4] for brand, [6] for logo, and so on.

    Much easier than explicitly doing the id for each.
     
    • Like Like x 3
    • Today I Learned Today I Learned x 2
  2. Jagdpanzer

    Jagdpanzer Survey Slinger

    Messages:
    2,960
    Gender:
    Male
    Ratings:
    +3,443
    Chrome's Dev console? Is this something different than what comes up when I inspect a frame element?
     
  3. rs303909

    rs303909 Active Turker

    Messages:
    195
    Gender:
    Male
    Ratings:
    +175
    well hit PE at 3pm and Legends of Tomorrow just finished downloading so Im off for a beer and some videos....good luck with it guys...
     
  4. rs303909

    rs303909 Active Turker

    Messages:
    195
    Gender:
    Male
    Ratings:
    +175
    yeh thats the same thing
     
    • Today I Learned Today I Learned x 1
  5. rdaneel

    rdaneel Well-Known Turker

    Messages:
    315
    Gender:
    Male
    Ratings:
    +813
    Nope!

    Just use the drop down, to go from 'Top frame" to "Externalbalhbalbhalh", and if you want to use jquery, you have to paste it in:
    Code:
    javascript:(function() {var jquery = document.createElement('script'); jquery.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"; document.head.appendChild(jquery);})();
    
    ^^^ That. I haven't found a better way of doing it, but there probably is.

    From then on, you can do anything you would in a script, but instantly. It's how you know ahead of time your script will work. :^)

    For example, @rs303909 could be using it and $(':radio')[0].focus() to see if it worked for him. :)

    I'm almost tempted to script these, for easy money, but I have stupid rl adulting crap I have to do before tomorrow. If I were doing this, I'd see if it's usually 'yes' or 'no' and set all to that, and then:
    1 key to all yes. 1 key to all no.
    numpad 1 -8 to toggle any value: yes to no, no to yes. Enter to submit. Bob's your uncle.
    Script logic would just be:
    function() {
    if ( this_a9 === a9_we_care about) {
    set_defaults();
    keyboard_handler();
    }

    Good exercise for learning to script. Strive hard, and someday ya'll can have people who don't script accuse you of stealing all your code and embedding malware: shoot high with your aspirations. :)
     
    • Like Like x 1
    • Today I Learned Today I Learned x 1
  6. Jagdpanzer

    Jagdpanzer Survey Slinger

    Messages:
    2,960
    Gender:
    Male
    Ratings:
    +3,443


    Thanks for all of this. I'm somewhat lost and a lot tired but it gives me a lot of info I did not have.. :)

    Oh my dream, to attract the likes of that moron. :rolleyes:
     
    • Love Love x 1
  7. Nacho Ferret

    Nacho Ferret Active Turker

    Messages:
    305
    Ratings:
    +338
    You post some of the most mind blowing stuff on this forum, but, if I may ask, do you now if there is a way to include more than one radio within the brackets instead of having 8 separate lines in the script?
     
  8. rdaneel

    rdaneel Well-Known Turker

    Messages:
    315
    Gender:
    Male
    Ratings:
    +813
    Sure.
    Code:
    $(':radio:even').click();
    
    Set all to 'yes'. Change to ':radio:odd' for all no.

    What if you want some yes, and some no?
    Code:
    var myarray = [1, 2,4,6]
    for ( i = 0; i < myarray.length; i++) {
          $(':radio')[myarray[i]].click();
    
    That's kind of sloppy, and you shouldn't use .length in the actual for loop [more efficient to calculate it once outside it] but that's the general idea. You definitely wouldn't want 8 separate lines. :)
     
    • Like Like x 3
  9. slothbear

    slothbear Survey Slinger

    Messages:
    10,821
    Gender:
    Male
    Ratings:
    +22,069
    Here's a working script for these A9s. It could be a little better, but it works. It autofills yes on everything, but that's easily changed at the top of the script. 1-8 keys/numpad toggle radios. Mess around with it if you want, or keep it around and copy/paste parts of it to build your own.

    Code:
    // ==UserScript==
    // @name         A9 - Differences
    // @version      0.1
    // @description  1-8 toggle radios.
    // @author       slothbear
    // @include      https://s3.amazonaws.com/mturk_bulk*
    // @require      http://code.jquery.com/jquery-3.1.1.min.js
    
    // ==/UserScript==
    
    // Set true to autocheck Yes, false for No
    var size = true;              
    var flavor = true;            
    var brand = true;            
    var logo = true;              
    var edition = true;
    var language = true;
    var package = true;
    var product = true;
    var choiceArr = [size,flavor,brand,logo,edition,language,package,product];
    $(function(){
    
        $('#size').focus();
        autofiller(choiceArr);
        hotkeys();
    
    });
    
    function hotkeys(){
        $(document).keydown(function (e) {
            switch (e.which) {
                case 49: 
                    $(':radio[value="Yes"]').click();
                    break;
                case 50:
                    $(':radio[value="No"]').click();
                    break;
                case 97: //1
                    toggler("size");
                    break;
                case 98: //2
                    toggler("flavor");
                    break;
                case 99: //3
                    toggler("brand");
                    break;
                case 100: //4
                    toggler("logo");
                    break;
                case 101: //5
                    toggler("edition");
                    break;
                case 102: //6
                    toggler("language");
                    break;
                case 103: //7
                    toggler("package");
                    break;
                case 104: //8
                    toggler("product");
                    break;
                case 13: 
                    $('#submitButton').click();
            }
        });
    }
    
    function toggler(choice){
        $('input[id='+ choice + ']').not(':checked').prop("checked", true);
    }
    
    function autofiller(arr){
        var arrLength = arr.length;
        for (var i=0; i<arrLength; i++){
            if(arr[i]){
                $(':radio').eq(i*2).click();
            } else {
                $(':radio').eq(i*2+1).click();
            }
        }
    }
    
    
    

    I'll do a handful to make sure, but I think it should work.

    edit: changed it a bit. Keys 1&2 set all to Yes/No. Numpad toggles single radios. Pared down some repeated code. Mostly becuase @rdaneel said so.
     
    • Like Like x 1
    • Love Love x 1
    Last edited: Dec 2, 2016
  10. WimpLo

    WimpLo Survey Slingin' Batch Masta Former MTG MotM

    Messages:
    34,824
    Gender:
    Female
    Ratings:
    +73,337
    Title: Attitudes to Sex | PANDA
    Requester: Brooks Lab [A13GGWKMR6Y4JR] (TO)
    TO Ratings:
    ★★★★★ 3.33 Communicativity
    ★★★★★ 3.57 Generosity
    ★★★★ 4.43 Fairness
    ★★★★ 4.43 Promptness
    Number of Reviews: 16 | TOS Flags: 1
    Submit a new TO review
    Description: Help us understand more about what influences individuals' attitudes to sex
    Time: 25 minutes
    HITs Available: 1
    Reward: $0.50
    Qualifications: None
    under 4 min
     
    • Like Like x 1
  11. ChrisTurk

    ChrisTurk Administrator

    Messages:
    56,679
    Ratings:
    +162,927
    I don't know if its "better" but I use this since its easier to toggle on/off than finding the damn link/code to insert every time.

    Code:
    // ==UserScript==
    // @name         _Inject JS
    // @version      1.0
    // @description  Enable JS on stuff so I can use the damn console.
    // @author       ChrisTurk
    // @include      *
    // @require      https://code.jquery.com/jquery-2.1.4.min.js
    // @grant
    // ==/UserScript==
    
    $( document ).ready(function(){
        //
        var script = document.createElement('script');script.src = "https://code.jquery.com/jquery-latest.min.js";
        document.getElementsByTagName('head')[0].appendChild(script);
        console.log('success');
    });
    
    It breaks a whole slew of websites (mostly ones that use AJAX IME) but its great for on/off testing for me. YMMV :dunno:

    ETA: I use a wildcard * for the include since I write scripts for every site I visit more than once a week now, but you could probably limit it to mTurk ones with no ill side effects.
     
    • Like Like x 1
    • Today I Learned Today I Learned x 1
    • Love Love x 1
  12. rdaneel

    rdaneel Well-Known Turker

    Messages:
    315
    Gender:
    Male
    Ratings:
    +813
    There's supposedly some way to do it with snippets, but I've never figured it out. I'm glad I'm not the only one with the problem; presumably, it'd work if the page already had it as an include.

    My process is I've got it as a bookmarklet on my Turk user profile [and I'm still surprised not everyone uses a separate one just for turking], so when I open dev console, I usually just drag it over. On reload, I select proper frame again, arrow up a few times, hit enter, and go to town.

    Your way's also good, though. :)
     
    • Today I Learned Today I Learned x 1
  13. Jagdpanzer

    Jagdpanzer Survey Slinger

    Messages:
    2,960
    Gender:
    Male
    Ratings:
    +3,443
    Ok really BettZeit now. Tomorrow guys.
     
    • Like Like x 2
  14. Aqualea

    Aqualea Active Turker

    Messages:
    270
    Gender:
    Female
    Ratings:
    +307
    Title: Answer a survey about your political opinions | PANDA
    Requester: Mauricio J. Alvarez [A2XURABF35EM8A] (TO)
    TO Ratings:
    ♥♥♥♥♥ 5.00 Communicativity
    ♥♥♥♥♥ 3.09 Generosity
    ♥♥♥♥ 4.76 Fairness
    ♥♥♥♥ 4.76 Promptness
    Number of Reviews: 39 | TOS Flags: 0
    Submit a new TO review
    Description: Give us your opinion about the 2016 elections
    Time: 30 minutes
    HITs Available: 14
    Reward: $1.00
    Qualifications: HIT approval rate (%) is greater than 95;Total approved HITs is greater than 50;Location is US
     
  15. TissueHime

    TissueHime Survey Slinger

    Messages:
    2,210
    Gender:
    Male
    Ratings:
    +2,407

    ok
     
  16. WimpLo

    WimpLo Survey Slingin' Batch Masta Former MTG MotM

    Messages:
    34,824
    Gender:
    Female
    Ratings:
    +73,337
  17. rdaneel

    rdaneel Well-Known Turker

    Messages:
    315
    Gender:
    Male
    Ratings:
    +813
    Heh. ;)

    Check out some of my scripts for what I do there: basically, create an object, where you use the key you want to check as the left of the :, and what you want to happen as the right. It's a bit more complicated with different functions, but let's say you just did it with your toggler:
    var myObj = { 97 : 'size', 98: 'flavor', 99, 'brand' ... };

    if ( myObj.hasOwnProperty(e.which) ) {
    toggler( myObj[e.which] );
    }
    ^^^^ Will do the same thing as your cases, but way cleaner. Eth and me actually got out the performance metrics, and this way seems decent, though I think we found something faster [than hasOwnProperty], but it's negligible.

    It's way easier to modify your code when it's not 3 pages long. :)
     
    • Today I Learned Today I Learned x 1
    • Love Love x 1
  18. slothbear

    slothbear Survey Slinger

    Messages:
    10,821
    Gender:
    Male
    Ratings:
    +22,069
    Nice! That would definitely clean everything up. I'll check it out, Thanks!
    [​IMG]


    edit: Yeah, that's a lot easier to deal with. Thanks again!
     
    Last edited: Dec 2, 2016
  19. Kintsugi

    Kintsugi Active Turker

    Messages:
    151
    Gender:
    Male
    Ratings:
    +429
    Apologies if this doesn't belong in the main thread. Which part of the code in a script determines which HITs it should load for? I'd like a script to only load for A9s as an example, but not every other hit. Also, how can I go force a script to load when testing a saved frame source locally?
     
  20. THFYM

    THFYM Survey Slinger Former MTG MotM

    Messages:
    8,887
    Gender:
    Male
    Ratings:
    +23,050
    You have to have

    Code:
    // @include      https://s3.amazonaws.com/*
    in the header. This will run on EVERY hit hosted on s3.amazonaws.com, not just A9s. To get around that, you'll need a sanity check.

    Find something unique to the hit. In the case of these A9s:

    Code:
     
    if ($("td:contains(Compare the largest product in each image and answer the following questions:)").length){
    
    ALL YOUR CODE GOES HERE
    
    }
    
     
    • Love Love x 2
Thread Status:
Not open for further replies.