Script help

Discussion in 'Help & Guides' started by GucciCthulhu, Aug 10, 2018.

  1. GucciCthulhu

    GucciCthulhu Active Turker

    Messages:
    369
    Gender:
    Male
    Ratings:
    +982
    For A9's Pearls Sequin Stud

    What I wanted it to do:
    Mark yes for pearl if I pressed 1
    yes for sequin if I pressed 2
    yes for stud if I pressed 3

    It's currently only clicking the yes radio button for pearl and not working for sequin or stud.

    Code:
    $(document).ready(function() {
    $('[name="pearl"]').focus();
    $(this).keydown(function(e) {
    if (e.keyCode == 49) {
    $('input[name="pearl"][value="YesPearl"]').click();
    }
    });
    });
    $(this).keydown(function(e) {
    if (e.keyCode == 50) {
    $('input[name="sequinl"][value="YesSequin"]').click();
    }
    });
    $(this).keydown(function(e) {
    if (e.keyCode == 51) {
    $('input[name="stud"][value="YesStud"]').click();
    }
    });
    $('input[value="NoPearl"]').click();
    $('input[value="NoSequin"]').click();
    $('input[value="NoStud"]').click();
    $(document).keyup(function(event) {
        if(event.which == 13){
            event.preventDefault();
            $("#submitButton").click();
        }
    });
     
    • Like Like x 1
  2. GucciCthulhu

    GucciCthulhu Active Turker

    Messages:
    369
    Gender:
    Male
    Ratings:
    +982
    Fixed. I cleaned it up. There were too many braces, I just needed to wrap it up in one set. Even though I have an @ require I added the first line to get rid of the $(jQuery) is not defined error in tampermonkey.

    Code:
    var $ = window.jQuery;
    $(document).ready(function() {
      $('input[value="NoPuffy"]').click();
      $('input[value="NoButton"]').click();
      $('[name="puffy"]').focus();
      $(this).keydown(function(e) {
          if (e.keyCode == 50) {
            $('input[name="button"][value="YesButton"]').click();
             }
        });
      $(this).keydown(function(e) {
          if (e.keyCode == 49) {
            $('input[name="puffy"][value="YesPuffy"]').click();
             }
        });
    });
    

    And here's a fiddle with the HIT.
     
    • Like Like x 1