LookinAtMe = {}

function LookinAtMe:Initialize()
	GameTooltip:HookScript("OnTooltipSetUnit", function (tooltip) if tooltip:IsUnit("mouseover") then LookinAtMe:AddTargetLine(tooltip) end end)
end

function LookinAtMe:AddTargetLine(pTooltip)
	local _, vUnitID = pTooltip:GetUnit()
	
	if not vUnitID then
		return
	end
	
	local vTargetID = vUnitID.."target"
	
	if not UnitExists(vTargetID) then
		return
	end
	
	local vTargetName = UnitName(vTargetID)
	local vTargetLevel = UnitLevel(vTargetID)
	local vClassName, vClassID = UnitClass(vTargetID)
	local vColor = RAID_CLASS_COLORS[vClassID] or NORMAL_FONT_COLOR
	local vExtraInfo
	local vColorCode = string.format("|cff%02x%02x%02x", vColor.r * 255 + 0.5, vColor.g * 255 + 0.5, vColor.b * 255 + 0.5)
	
	if vTargetLevel > 0 then
		if vClassName and vClassName ~= vTargetName then
			vExtraInfo = ", "..vColorCode.."Level "..vTargetLevel.." "..tostring(vClassName)
		else
			vExtraInfo = ", "..vColorCode.."Level "..vTargetLevel
		end
	else
		vExtraInfo = "Level ??"
	end
	
	pTooltip:AddLine("Target: "..vTargetName..vExtraInfo, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, true)
	
	pTooltip:Show() -- Do Show() to get the height to adjust for the new line
end

LookinAtMe:Initialize()