Ahab / Nom logo

// ==UserScript==
// @name         Nom logo
// @namespace    torn
// @version      1.0
// @description  Anniversary logo noms
// @author       Ahab [1735214]
// @include      *torn.com*
// @license      MIT
// ==/UserScript==

var setting = 1 //0 = noms to current eaten | 1 = noms to full logo | 2 = full logo no noms
var on = 'on' //on = works year round
var timetoeat = 250 //time in miliseconds
var message = 'Cake All The Time'

if($("a[class*='letters']").length == 0 && on == 'on'){
   $("div[id*='tcLogo']").css("background-image", "url('')").children()[0].remove()
   $("div[id*='topHeaderBanner']").attr('class', 'header msg responsive-sidebar-header torn-birthday')
   $("div[id*='tcLogo']").append('<a aria-label="Index page" class="letters unscaled" href="/"><div class="t-letter " data-letter="t"><span class="letter t-used-0"></span></div><div class="o-letter " data-letter="o"><span class="letter o-used-0"></span></div><div class="r-letter " data-letter="r"><span class="letter r-used-0"></span></div><div class="n-letter " data-letter="n"><span class="letter n-used-0"></span></div><span class="ribbon">'+message+'</span></a>')
}

if($("div[class*='t-letter ']")){
    var t = $("span[class*='t-used']").attr('class')
    var o = $("span[class*='o-used']").attr('class')
    var r = $("span[class*='r-used']").attr('class')
    var n = $("span[class*='n-used']").attr('class')
    var count = -1
    var end = 0

    function eat(){
        $("span[class*='t-used']").attr('class', 'letter t-used-'+count);
        $("span[class*='o-used']").attr('class', 'letter o-used-'+count);
        $("span[class*='r-used']").attr('class', 'letter r-used-'+count);
        $("span[class*='n-used']").attr('class', 'letter n-used-'+count);
    }

    if(setting == 0 || setting == 1){
        var interval = setInterval(function(){
            if(end == 0 && count < 10){
                count += 1
                eat()
            }
            else if(count == 10){
                if(setting == 1){
                    clearInterval(interval)
                    count = 0
                    end = 1
                    eat()
                }
                else if(setting == 0){
                    clearInterval(interval)
                    $("span[class*='t-used']").attr('class', t);
                    $("span[class*='o-used']").attr('class', o);
                    $("span[class*='r-used']").attr('class', r);
                    $("span[class*='n-used']").attr('class', n);
                }
            }
        }, timetoeat);
    }else if(setting == 2){
        count = 0
        eat()
    }
}