// ==UserScript==
// @name         Bamboo HR Employee Name Quiz
// @namespace    https://bamboohr.com/employee_quiz
// @version      0.3.0
// @description  Lets you check your memory for who is who in your company.
// @author       Ben Johnson
// @match        https://*.bamboohr.com/employees/directory.php
// @grant        none
// ==/UserScript==

function applyStyles() {
    // Initialize all the names to hidden (via changing the text to white)
    $('.JobInfo__name, .JobInfo__name a').css('color', 'white');
    // Always hide the email address, as this could give you too much of a hint
    $('.ContactInfo').hide()

    // On hover in, show the name, and then rehide on hover out
    $('.JobInfo__name, .JobInfo__name a').hover(
        function(){ $(this).css('color', 'black');},
        function(){ $(this).css('color', 'white');}
    );

    // Hide the Group Headers which contain the first letter of the last name
    // of the employee, since this gives too much of a hint for the person
    $('div.GroupHeader').hide();
}

(function() {
    // Sleep to allow time for all employees to load
    setTimeout(applyStyles, 1000);
})();

// On every scroll event, reapply the styles. I'm not exactly sure why this
// is required, but it probably has to do with some fancy javascript for loading
// that they're using on the site. This is no doubt a pretty big hack, but it
// doesn't seem to cause any performance issues and is probably good enough for now.
$(window).scroll(function() {
    applyStyles();
});