03/10 - Frantic Friday!

Discussion in 'Daily mTurk HITs Threads' started by TissueHime, Mar 10, 2017.

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

    slothbear Survey Slinger

    Messages:
    10,822
    Gender:
    Male
    Ratings:
    +22,072
    This is ugly, but it works well enough for these. up/w down/s to go forward or back 1-3 to choose selections. You can set autosubmit after the third selection on or off at the top.
    It highlights the search terms in the product titles too.

    Code:
    // ==UserScript==
    // @name         Huzefa Dargahwala Helper
    // @version      0.1
    // @description  this is a little ugly and could be better...
    // @author       slothbear
    // @include      https://www.mturk.com/mturk/*
    // @require      http://code.jquery.com/jquery-3.1.1.min.js
    
    // ==/UserScript==
    
    $(function(){
        "use strict";
    
        // will autosubmit after 3rd selection if set to true
        var searchRelevancy_autosubmit = false;
    
    
        // SANITY CHECK
        if ($('li').eq(0).text().indexOf('Over-the-Range Microwave') > -1) searchRelevancy();
    
    
        function searchRelevancy(){
            log('Starting searchRelevancy()...');  
            hideInstructions($('div.overview-wrapper'));
            $('input[type="radio"]').eq('0').focus();
            $('div.question-wrapper').eq('0').css('background-color', '#bffff1');
    
            var counter = 0;
    
            $(document).keydown(function(e){
                if (e.key.match(/[1-3]/)) {
                    var keyNum = parseInt(e.key) - 1;
                    var tempCounter = counter * 3;
                    $('input[type="radio"]').eq(tempCounter + keyNum).click();
                    changeCount(1);
                } else if (e.key === 'ArrowUp' || e.key === 'w') {
                    e.preventDefault();
                    changeCount(-1);
                } else if (e.key === 'ArrowDown' || e.key === 's') {
                    e.preventDefault();
                    changeCount(1);
                }
            });
    
    
            function changeCount(change){
                counter = counter + change;
                log('counter = ' + counter);
                if (counter < 3) {
                    $('html, body').animate({
                        scrollTop: $('input[type="radio"]').eq(counter * 3).offset().top
                    }, 400);
                }
                $('div.question-wrapper').css('background-color', 'white');
                $('div.question-wrapper').eq(counter).css('background-color', '#bffff1');
                if (counter > 2) {
                    $('body').css('background-color', 'orange');
                    if (searchRelevancy_autosubmit) $('input[name="/submit"]').click();
                } else {
                    $('body').css('background-color', 'white');
                }
            }
    
    
            //HIGHLIGHTER
            // CALL 'setHighlightStylesheet()' BEFORE HIGHLIGHTING BEGINS
            // HIGHLIGHT WITH:
            // $('element').highlight('string');
            /*
    highlight v4
    Highlights arbitrary terms.
    <http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
    MIT license.
    Johann Burkard
    <http://johannburkard.de>
    <jb@eaio.com>
    */
            // HIGHLIGHT WITH:
            // $('element').highlight('string');     or    $('element').removeHighlight();
    
            // CALL THIS BEFORE HIGHLIGHTING BEGINS
            function setHighlightStylesheet(){
                var highlightColor = 'yellow';
                //next 3 lines set css style for highliter...
                var sheet = document.createElement('style');
                sheet.innerHTML = '.highlight { font-weight: bold; background-color: ' + highlightColor + '; font-size: 110%;}';
                document.body.appendChild(sheet);
            }
    
            jQuery.fn.highlight = function(pat) {
                function innerHighlight(node, pat) {
                    var skip = 0;
                    if (node.nodeType == 3) {
                        var pos = node.data.toUpperCase().indexOf(pat);
                        if (pos >= 0) {
                            var spannode = document.createElement('span');
                            spannode.className = 'highlight';
                            var middlebit = node.splitText(pos);
                            var endbit = middlebit.splitText(pat.length);
                            var middleclone = middlebit.cloneNode(true);
                            spannode.appendChild(middleclone);
                            middlebit.parentNode.replaceChild(spannode, middlebit);
                            skip = 1;
                        }
                    }
                    else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
                        for (var i = 0; i < node.childNodes.length; ++i) {
                            i += innerHighlight(node.childNodes[i], pat);
                        }
                    }
                    return skip;
                }
                return this.length && pat && pat.length ? this.each(function() {
                    innerHighlight(this, pat.toUpperCase());
                }) : this;
            };
    
            // THIS DOES THE HIGHLIGHT FOR THE THREE SEARCH TERM/PRODUCT TITLE SECTIONS
            setHighlightStylesheet();
            for (var z = 0; z < 3; z++) {
                var searchWords = $('p:contains(Search Term)').eq(z).text().substring(13);
                var wordArr = searchWords.split(' ');
                wordArr = wordArrCleaner(wordArr);
                log('wordArr #' + z + ': ' + wordArr);
                highlightProductTitles(wordArr, z);
            }  
        }
    
        function highlightProductTitles(searchArr, pos){
            for (var i = 0; i < searchArr.length; i++) {
                $('p:contains(Product Title)').eq(pos).highlight(searchArr[i]);
            }
        }
    
        function wordArrCleaner(wordArr){
            for (var i = 0; i < wordArr.length; i++) {
                if (wordArr[i].substring(wordArr[i].length-1) === 's') {
                    wordArr.push(wordArr[i].substring(0, wordArr[i].length-1));
                }
            }
            return wordArr;
        }
    
        //LOGGER
        function log(text){
            var scriptName = "HUZEFA HELPER";
            var logPrefix = '[' + scriptName + '] '; // Logs to conosle with log('string')
            console.log(logPrefix + text);
        }
    
        //HIDE INSTRUCTIONS
        function hideInstructions(instructions){ // Hides instructions behind a button
            instructions.toggle();
            var instructionButton = '<button type="button" id="instructionButton">Instructions</button>';
            instructions.before(instructionButton); // Hides where instructions were
            //$('body').before(instructionButton); // Hides between body and head
            $('#instructionButton').click(function(){
                instructions.toggle();
            });
        }  
    });
     
    • Today I Learned Today I Learned x 3
    • Love Love x 2
    • Like Like x 1
    • 5/5 Pay 5/5 Pay x 1
  2. Ten

    Ten Survey Slinger

    Messages:
    5,518
    Gender:
    Male
    Ratings:
    +8,149
    Man. Where are the night crew at?
     
  3. Ten

    Ten Survey Slinger

    Messages:
    5,518
    Gender:
    Male
    Ratings:
    +8,149
    Title: Answer a short survey about shopping for a pair of running shoes. | PANDA
    Worker: Preview | Accept | Requester
    Requester: Dominique Braxton [A1UWGJFMSA75XB] (Contact)
    TO: [Pay: 3.94] [Fair: 3.93] [Comm: 3.40] [Fast: 4.14] [Reviews: 19] [ToS: 0]
    Description:
    Provide your opinion of several pairs of running shoes
    Time: 1 hour
    HITs Available: 1
    Reward: $0.35
    Qualifications: Total approved HITs GreaterThanOrEqualTo 500; HIT approval rate (%) GreaterThanOrEqualTo 99; Location EqualTo US;
    HIT exported from Mturk Suite v1.14.9
     
    • Nom Nom Nom! Nom Nom Nom! x 1
  4. Sunlite

    Sunlite Survey Slinger

    Messages:
    5,028
    Gender:
    Female
    Ratings:
    +7,755
    I'm here, but tired tonight- only slept like 6 hours- playing games and doing a few Eric's here and there...thinking about going back to day shift...
     
  5. SAJ

    SAJ Survey Slinger

    Messages:
    27,503
    Gender:
    Male
    Ratings:
    +51,497
    Resting from the :flame::flame::flame::flame:Friday that I lucked into all day by actually waking up before noon for a change lol


    edit: and tbh it still is sort of :flame:right now I just need a break from pushing keys
     
    • 5/5 Pay 5/5 Pay x 1
    • Love Love x 1
  6. Sunlite

    Sunlite Survey Slinger

    Messages:
    5,028
    Gender:
    Female
    Ratings:
    +7,755
    I missed all the good stuff sleeping from noon to 6ish...
     
  7. Melting Glacier

    Melting Glacier PE: $30.01 - That's over $1.25/hour! ┬┴┤( ͡° ͜ʖ├┬┴

    Messages:
    6,157
    Gender:
    Male
    Ratings:
    +11,423
    Uhhhh.. :eek: Mine was four lines... :oops:

    Man, that's pretty awesome! I like the colors and the highlighting is really helpful. I kept thinking about building up Multi-Highlight but this is much better. Solid work, dude. Thanks!! :adore: They feel even more like PI Search now, lol.
     
    • Like Like x 2
  8. SAJ

    SAJ Survey Slinger

    Messages:
    27,503
    Gender:
    Male
    Ratings:
    +51,497
    Yeah quite a bit today... I got on and turking at 8 ish and didn't get up from it till almost 4 for a quick break o_O Today was a reminder of how everyday once was
     
  9. Ten

    Ten Survey Slinger

    Messages:
    5,518
    Gender:
    Male
    Ratings:
    +8,149
    I got my sleep ruined by a cat so I was down for a few more hours than I normally am. (4-6 hours of sleep a day FTW!)
     
    • Like Like x 1
  10. slothbear

    slothbear Survey Slinger

    Messages:
    10,822
    Gender:
    Male
    Ratings:
    +22,072
    yay pi search! ha. I'll mess around with it later and make it a little nicer, but I think I'm done for the night after I clear out this queue.

    The highlighter part of it is pretty much just cut/pasted from the pi script.
     
  11. LurkinNturkin

    LurkinNturkin Active Turker

    Messages:
    323
    Gender:
    Male
    Ratings:
    +1,149
    I used to do well playing online poker when it was all over the place... I feel your pain
     
    • Like Like x 1
  12. Ten

    Ten Survey Slinger

    Messages:
    5,518
    Gender:
    Male
    Ratings:
    +8,149
    Title: First (of two - the second hit will go out next week) research survey on individual differences and positive behaviors at work | PANDA
    Worker: Preview | Accept | Requester
    Requester: Uta Bindl [AAVL1EGES8XF2] (Contact)
    TO: [Pay: 5.00] [Fair: 5.00] [Comm: 5.00] [Fast: 5.00] [Reviews: 16] [ToS: 0]
    Description:
    This is a research survey on positive behaviors at work. You will be asked questions about your current job and your personality. Next week, we will contact you about a second hit - please only partake now if you are happy to do the second survey, too.
    Time: 60 minutes
    HITs Available: 1
    Reward: $3.00
    Qualifications: US High School Graduate is 1; Employment Status: Unemployed is 0; HIT approval rate (%) is not less than 95; Location is US;
    HIT exported from Mturk Suite v1.14.9
     
    • Nom Nom Nom! Nom Nom Nom! x 4
  13. LurkinNturkin

    LurkinNturkin Active Turker

    Messages:
    323
    Gender:
    Male
    Ratings:
    +1,149
    This was a pretty good one
     
  14. SAJ

    SAJ Survey Slinger

    Messages:
    27,503
    Gender:
    Male
    Ratings:
    +51,497
    haha :ay: I was a grinder :az:
     
    • Love Love x 1
  15. TissueHime

    TissueHime Survey Slinger

    Messages:
    2,396
    Gender:
    Male
    Ratings:
    +2,710
    40 minutes left for dibs!
    if you do call it, please tag me or else I might miss it
     
  16. Melting Glacier

    Melting Glacier PE: $30.01 - That's over $1.25/hour! ┬┴┤( ͡° ͜ʖ├┬┴

    Messages:
    6,157
    Gender:
    Male
    Ratings:
    +11,423
    I, for one, would like to welcome our new Search Relevancy overlord! :emoji_bow:

    Sounds good, man. It works really well already, so save the cleanup for later. Btw I'm still using your sticky MTG modbar script, but I modded it to float the reports counter that mods see. @WimpLo is using it too! :D
     
    • Like Like x 1
  17. slothbear

    slothbear Survey Slinger

    Messages:
    10,822
    Gender:
    Male
    Ratings:
    +22,072
    Nice. Glad it's getting some use!
     
    • Like Like x 1
    • Love Love x 1
  18. slothbear

    slothbear Survey Slinger

    Messages:
    10,822
    Gender:
    Male
    Ratings:
    +22,072
    Today's Projected Earnings: $60.75 + Bonuses: $4.65 = $65.40
    + $45 tedlab (that's sat in my queue for several days) and it's $25 bonus (someday).

    Later turkeys!
     
    • 5/5 Pay 5/5 Pay x 4
    • Like Like x 2
  19. Ten

    Ten Survey Slinger

    Messages:
    5,518
    Gender:
    Male
    Ratings:
    +8,149
    Today's Projected Earnings: $27.41 + Bonuses: $0.15 = $27.56 (Exported from Mturk Suite v1.14.9)

    Over my goal with a hour to spare! WOOOH!
     
    • Like Like x 1
    • 5/5 Pay 5/5 Pay x 1
  20. Kadauchi

    Kadauchi Administrator Former MTG MotM

    Messages:
    4,368
    Ratings:
    +8,598
    Very nice. IMO some things can be minified a bit (just personal taste, not meaning to be critical or rude). But your use of functions like the hideinstructions and stuff is great. One constructive piece of feedback would be to take the jquery minified code and all of you functions + the highlight script and save it to a gist. Then you can call the gist as a library and it will allow access to all of your functions and jquery without the function being at the bottom (those functions i assume you use across many of your scripts).

    So it'd be like this which is what I do. Then boom, all of your functions are loaded along with jquery, ezpz.
    Code:
    // @require      https://gist.githubusercontent.com/Kadauchi/000/raw/000/kadaquery
     
    • Today I Learned Today I Learned x 3
Thread Status:
Not open for further replies.