PHP код:
	
local MIN_SCALE = 0.5
local ICON_SIZE = 36 
local FONT_SIZE = 20 
local MIN_SCALE = 0.5
local MIN_DURATION = .1 --минимальное время для вывод таймера
local UI = CreateFrame("frame")
local floor = math.floor
local min = math.min
local GetTime = GetTime
local TimeColors = {
    [0] = '|cfffefefe',
    [1] = '|cfffefefe',
    [2] = '|cfffefefe',
    [3] = '|cfffefefe',
    [4] = '|cfffe0000',
}
UI.TimeFormats = {
    [0] = { '%dd', '%dd' },
    [1] = { '%dh', '%dh' },
    [2] = { '%dm', '%dm' },
    [3] = { '%ds', '%d' },
    [4] = { '%.1fs', '%.1f' },
}
local function Cooldown_OnUpdate(cd, elapsed)
    if cd.nextUpdate > 0 then
        cd.nextUpdate = cd.nextUpdate - elapsed
        return
    end
    local remain = cd.duration - (GetTime() - cd.start)
    if remain > 0.05 then
        if (cd.fontScale * cd:GetEffectiveScale() / UIParent:GetScale()) < MIN_SCALE then
            cd.text:SetText('')
            cd.nextUpdate = 500
        else
            local timervalue, formatid
            timervalue, formatid, cd.nextUpdate = UI:GetTimeInfo(remain, 2)        
            cd.text:SetFormattedText(("%s%s|r"):format(TimeColors[formatid], UI.TimeFormats[formatid][2]), timervalue)
        end
    else
        UI:Cooldown_StopTimer(cd)
    end
end
function UI:Cooldown_OnSizeChanged(cd, width, height)
    local fontScale = UIParent:GetScale()
    local override = cd:GetParent():GetParent().SizeOverride
    if override then 
        fontScale = override / FONT_SIZE
    end
    
    if fontScale == cd.fontScale then
        return
    end
    cd.fontScale = fontScale
    if fontScale < MIN_SCALE and not override then
        cd:Hide()
    else
        cd:Show()
        cd.text:FontTemplate(nil, fontScale * FONT_SIZE, 'OUTLINE')
        if cd.enabled then
            self:Cooldown_ForceUpdate(cd)
        end
    end
end
function UI:Cooldown_ForceUpdate(cd)
    cd.nextUpdate = 0
    cd:Show()
end
function UI:Cooldown_StopTimer(cd)
    cd.enabled = nil
    cd:Hide()
end
function UI:CreateCooldownTimer(parent)
    local scaler = CreateFrame('Frame', nil, parent)
    scaler:SetAllPoints()
    local timer = CreateFrame('Frame', nil, scaler); timer:Hide()
    timer:SetAllPoints()
    timer:SetScript('OnUpdate', Cooldown_OnUpdate)
    local text = timer:CreateFontString(nil, 'OVERLAY', "ChatFontNormal")
    text:SetPoint('CENTER', 1, 1)
    text:SetJustifyH("CENTER")
    timer.text = text
    self:Cooldown_OnSizeChanged(timer, parent:GetSize())
    parent:SetScript('OnSizeChanged', function(_, ...) self:Cooldown_OnSizeChanged(timer, ...) end)
    parent.timer = timer
    return timer
end
function UI:OnSetCooldown(start, duration, charges, maxCharges)
    if(self.noOCC) then return end
    local button = self:GetParent()
    
    if start > 0 and duration > MIN_DURATION then
        local timer = self.timer or UI:CreateCooldownTimer(self)
        timer.start = start
        timer.duration = duration
        timer.enabled = true
        timer.nextUpdate = 0
        if timer.fontScale >= MIN_SCALE then timer:Show() end
    else
        local timer = self.timer
        if timer then
            UI:Cooldown_StopTimer(timer)
            return
        end
    end
    
    if self.timer then
        if charges and charges > 0 then
            self.timer:SetAlpha(0)
        else
            self.timer:SetAlpha(1)    
        end
    end
end
function UI:RegisterCooldown(cooldown)
    if(cooldown.isHooked) then return end
    hooksecurefunc(cooldown, "SetCooldown", UI.OnSetCooldown)
    cooldown.isHooked = true
end