Ahab / Mision reward timer

// ==UserScript==
// @name         Mision reward timer
// @namespace    torn
// @version      0.2
// @description  Show time left for mission rewards
// @author       Ahab [1735214]
// @match        *www.torn.com/loader.php?sid=missions
// @license      MIT
// @require      https://gist.githubusercontent.com/BrockA/2625891/raw/9c97aa67ff9c5d56be34a55ad6c18a314e5eb548/waitForKeyElements.js
// @updateURL    https://openuserjs.org/meta/Ahab/Mision_reward_timer.meta.js
// ==/UserScript==

var setTo = 2 //1 = On hover | 2 = Always show

function wholeTime(){
    if(setTo == 1){
        //On timer hover
        $("div[class^='time']").one('mouseenter', function(){
            $(this).attr('title',timef($(this).attr('data-timeleft')))
        })
    }else if(setTo == 2){
        $.each($("div[class^='time']"), function(index , value){
            $(this).parent().parent().parent().append('<div class="addtime" style="clear: left;"></div>')
            $("ul[class^='rewards-list']").children().css('height','100%');
            $("div[class^='addtime']").countdown({until: $(this).attr('data-timeleft'), compact:true, onExpiry: end, alwaysExpire:true});
        })
    }
}

function end(){
    $(this)[0].parent().remove()
}

function timef(seconds){
    var days     = Math.floor(seconds / (24*60*60));
    seconds -= days    * (24*60*60);
    var hours    = Math.floor(seconds / (60*60));
    seconds -= hours   * (60*60);
    var minutes  = Math.floor(seconds / (60));
    seconds -= minutes * (60);
    return ((0<days)?(days+"d, "):"")+hours+"h, "+minutes+"m, "+seconds+"s";
}

waitForKeyElements(".rewards-slider", wholeTime);