jess.a.manngmail.com / Apply to Tomoson

// ==UserScript==
// @name	    Apply to Tomoson
// @namespace   http://jess-mann.com
// @version     0.1
// @description Easily apply to tomoson promotions. NOTE: This script assumes jQuery is already loaded by tomoson. As of this date (5/14/16), it is version 1.7.1.
// @author      Jess Mann
// @match	    https://www.tomoson.com/promotions/apply/*
// @match	    https://www.tomoson.com/promotions/applied/approved/*
// @grant	    none
// @require     https://raw.githubusercontent.com/uzairfarooq/arrive/master/minified/arrive.min.js
// ==/UserScript==

(function() {
    'use strict';

    //Checks every box on the page with known names, and checks the amazon prime dropdown.
    function check_boxes()
    {
        //Select "yes" to the "do you have amazon prime" question.
        $('select#have_amazon_prime').val(2);
        //Find inputs with known names, and check them.
        $('input[name=agree], input[name=agree_read_product_details], input[name=ftc-agree], input[name=instructions-agree], input[name=agree_special_instructions]').prop('checked',true);

        //doesn't work. there's some javascript at work, and hidden inputs on the page.
        //the idea was to check or uncheck social networks I wanted. Maybe I'll do this one day.
        //$('task-icons-facebook-link.unchecked span.unchecked').click();
        //$('input#task_facebook, input#task_twitter').val(1);

        //Log it
        console.log('Checked all boxes, and set amazon prime to true.');
    };

    $(document).ready(function() {
        //check everything currently on the page
        check_boxes();

        //run it every time the verify button appears (loaded via ajax)
        $('.layout-page').arrive('.verify-button, button.success', function() {
            check_boxes();
        });
    });
})();