Fix inaccurate verified check

This commit is contained in:
Zed 2019-06-24 09:30:34 +02:00
parent e81865e144
commit d5214e2f77
1 changed files with 9 additions and 2 deletions

View File

@ -19,11 +19,18 @@ proc selectText*(node: XmlNode; selector: string): string =
let res = node.querySelector(selector) let res = node.querySelector(selector)
result = if res == nil: "" else: res.innerText() result = if res == nil: "" else: res.innerText()
proc getHeader(profile: XmlNode): XmlNode =
result = profile.querySelector(".permalink-header")
if result.isNil:
result = profile.querySelector(".stream-item-header")
if result.isNil:
result = profile.querySelector(".ProfileCard-userFields")
proc isVerified*(profile: XmlNode): bool = proc isVerified*(profile: XmlNode): bool =
profile.selectText(".Icon.Icon--verified").len > 0 getHeader(profile).selectText(".Icon.Icon--verified").len > 0
proc isProtected*(profile: XmlNode): bool = proc isProtected*(profile: XmlNode): bool =
profile.selectText(".Icon.Icon--protected").len > 0 getHeader(profile).selectText(".Icon.Icon--protected").len > 0
proc getName*(profile: XmlNode; selector: string): string = proc getName*(profile: XmlNode; selector: string): string =
profile.selectText(selector).strip() profile.selectText(selector).strip()