1. Glad you stopped in for a visit!

    Please feel free to peruse around and if you have a minute make sure to sign up for an account! We're one of the largest, most active, and helpful communities you'll find for learning about mTurk & registered accounts automatically get access to tons of useful features on the site.

    Features for members include:

    • The ability to post messages - our community is incredibly helpful & happy to welcome newcomers who are looking to learn the ropes!
    • Live thread update - no need to refresh pages to see new posts/HITs they flow onto the page automatically as they're posted.
    • Desktop alerts - direct PANDAs from exported HITs right on your desktop
    • Access to the full list of HITs exported through the Daily HIT Log
    • TurkerView account which will grant you extra access to HIT review information all across mTurk through TVJS

    But most importantly you'll be joining an amazing community. You'll find all types here, from stay-at-home Moms to IT pros. We're a great group - feel free to join us!

Avery Script

Discussion in 'mTurk Scripts & Resources' started by Drexl, Sep 9, 2018.

  1. Drexl

    Drexl Active Member

    Messages:
    256
    Gender:
    Male
    Ratings:
    +292 / 0 / -0
    So I put this together for the Avery's. 1 selects Does want to cross, 2 selects probably wants to cross etc.
    Code:
    // ==UserScript==
    // @name        Avery
    // @author      Drexl
    // @description 1,2,3,4,5 keybinds.
    // @include     *1.amazonaws.com/task/*
    // @require     https://code.jquery.com/jquery-3.1.1.min.js
    // ==/UserScript==
    
    
    $(document).keyup(function(event) {
        if(event.which == 49){
          $("#jspsych-image-button-response-button-0").click();
      }
    
    });
    
    $(document).keyup(function(event) {
        if(event.which == 50){
          $("#jspsych-image-button-response-button-1").click();
      }
    
    });
    
    $(document).keyup(function(event) {
        if(event.which == 51){
          $("#jspsych-image-button-response-button-2").click();
      }
    
    });
    
    $(document).keyup(function(event) {
        if(event.which == 52){
          $("#jspsych-image-button-response-button-3").click();
      }
    
    });
    
    $(document).keyup(function(event) {
        if(event.which == 53){
          $("#jspsych-image-button-response-button-4").click();
      }
    
    });
    
    
    Trying to figure out how to auto copy the completion code at the end and paste it into the other tab. I can't find the id number for the green button. http://prntscr.com/kshwxm I can't figure out what to use to make that command. Tried a few different things to hotkey the green button and still couldn't.

    Tried

    $(document).keyup(function(event) {
    if(event.which == 49){
    $(class="js-copy-code-btn btn btn-success").click();
    }

    and

    $(document).keyup(function(event) {
    if(event.which == 49){
    $("#js-copy-code-btn btn btn-success").click();
    }

    wouldn't work. No idea how to write a script that would copy the completion code and paste it in another tab but for now I'm trying to figure this button thing out. There's a next button on the instructions I'm trying to hotkey as well to get past. If anyone can help me out please let me know. Thx
     
  2. Kadauchi

    Kadauchi Well-Known Member

    Messages:
    3,688
    Ratings:
    +6,673 / 7 / -0
    Looks like you're pretty close.

    On the first you just missed the brackets.
    Code:
    $('[class="js-copy-code-btn btn btn-success"]').click();
    
    On the second you need to use the class selector "." instead of the id selector "#" and you need it on every class.
    Code:
    $('.js-copy-code-btn.btn.btn-success').click();
    
    Since that class is likely unique you could just select it by the specific one instead of having to use all 3. Makes it a bit more clear.
    Code:
    $('.js-copy-code-btn').click();
    
     
    • Useful / Informative Useful / Informative x 1
  3. Drexl

    Drexl Active Member

    Messages:
    256
    Gender:
    Male
    Ratings:
    +292 / 0 / -0
    Thank you, once I can get this down I think I can figure out how to make a lot of hits more efficient for me. Selecting buttons and finding what to use to get it to click confuses me, still trying to get the bare basics down.
     
  4. Eisenpower

    Eisenpower Well-Known Member

    Messages:
    4,788
    Gender:
    Male
    Ratings:
    +11,783 / 8 / -0
    Code:
    $(document)
    is selecting the whole document and
    Code:
    $(document).keyup
    is setting the whole document to listen for a key release. So, instead of adding a bunch of listeners for the whole document listening for the same thing, you can put all of your if statements inside of one listener like:


    Code:
    $(document).keyup(function(event) {
    
       if(event.which == 49){
         $("#jspsych-image-button-response-button-0").click();
       }
    
       if(event.which == 50){
         $("#jspsych-image-button-response-button-1").click();
       }
    
    });
     
    • Like Like x 1
    • Useful / Informative Useful / Informative x 1