Al_Caughey / A2E:: flag-new-entries

// ==UserScript==
// @name         A2E:: flag-new-entries
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Highlight new entries on the Apply-to-Education Job Board
// @author       Al Caughey
// @match        https://www.applytoeducation.com/Applicant/AttOccasionalPostings.aspx?TAB=JB
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    var $ = window.jQuery; // attached jQuery from the browswer window to the tampermonkey script

    //Define the style for the new entries... must append !important to override other styles
    $("<style type='text/css'> .new{color:red!important;font-weight:bold!important;}</style>").appendTo("head");

    // load the current list from the local storage variable or set to null string
    // initially I used a session storage variable rather than local storage but changed to local storage so that the
    // the highlighting would persist across sessions
    var cjcl=localStorage.getItem("list-of-jobs")||''

    //console.log('current', cjcl)
    var njcl='' // set variable for new job code list to null

    //iterate through the first chicd of each table row in the absencelist table
    $('.absencelist tr td:first-child').each(function(){
        var cjc=$(this).text() // get the text from the table cell

        if ($.isNumeric( cjc )) { // if it's a number, I'm assuming its a job code
            njcl=(njcl==='')?cjc:njcl+', ' + cjc // append the job code to the new list
            if(cjcl.indexOf(cjc)==-1){ // if the job code does not exist in the old list
                $(this).addClass('new') // set the class of the table cell to new (as defined above)
                //console.log(cjc, 'new')
            }
        }
    })
    // over-write the local storage variable with the new job code list
    localStorage.setItem("list-of-jobs", njcl)
    //console.log(localStorage.getItem("list-of-jobs"))
})();