diff --git a/Sources/AppDelegate.swift b/Sources/AppDelegate.swift index 1a3355b..3cf93b8 100644 --- a/Sources/AppDelegate.swift +++ b/Sources/AppDelegate.swift @@ -530,11 +530,27 @@ class AppDelegate: NSObject, NSApplicationDelegate { do { let doc: Document = try SwiftSoup.parse(html) let rects: Elements = try doc.getElementsByTag(ParseKeys.rect) + let tooltips: Elements = try doc.getElementsByTag(ParseKeys.tooltip) let days: [Element] = rects.array().filter { $0.hasAttr(ParseKeys.date) } let sortedDays = sortDaysByDate(days, with: isoDateFormatter) - let weekend = sortedDays.suffix(Consts.fetchCount) - let contributeDataList = weekend.map(mapFunction) + + var tooltipsTextById = [String: String]() + for tooltip in tooltips.array() { + let id = try tooltip.attr("for") + let text = try tooltip.text() + tooltipsTextById[id] = text + } + + let updatedWeekend = weekend.map { element -> Element in + let id = element.id() + if let tooltipText = tooltipsTextById[id] { + try? element.text(tooltipText) + } + return element + } + + let contributeDataList = updatedWeekend.map(mapFunction) return contributeDataList } catch { diff --git a/Sources/Consts/ParseKeys.swift b/Sources/Consts/ParseKeys.swift index 715b5c3..5ec409c 100644 --- a/Sources/Consts/ParseKeys.swift +++ b/Sources/Consts/ParseKeys.swift @@ -10,4 +10,5 @@ import Foundation enum ParseKeys { static let date = "data-date" static let rect = "td" + static let tooltip = "tool-tip" }