Avery Script

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

  1. Drexl

    Drexl Active Turker

    Messages:
    258
    Gender:
    Male
    Ratings:
    +293
    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 Administrator Former MTG MotM

    Messages:
    4,367
    Ratings:
    +8,589
    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();
    
     
    • Today I Learned Today I Learned x 1
  3. Drexl

    Drexl Active Turker

    Messages:
    258
    Gender:
    Male
    Ratings:
    +293
    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 Survey Slinger

    Messages:
    4,868
    Gender:
    Male
    Ratings:
    +11,870
    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
    • Today I Learned Today I Learned x 1