From 578deeb6e9001b53e0d9f3ddc5b604e69c31bcc1 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sun, 3 Jul 2022 16:17:18 -0400 Subject: [PATCH] okay, now with the imgs --- hoot.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hoot.go b/hoot.go index a9701e3..27b3e00 100644 --- a/hoot.go +++ b/hoot.go @@ -31,7 +31,7 @@ import ( var tweetsel = cascadia.MustCompile("div[itemProp=articleBody]") var linksel = cascadia.MustCompile("a time") var replyingto = cascadia.MustCompile(".ReplyingToContextBelowAuthor") -var imgsel = cascadia.MustCompile("div.js-adaptive-photo img") +var imgsel = cascadia.MustCompile("div[data-testid=tweetPhoto] img") var authorregex = regexp.MustCompile("twitter.com/([^/]+)") var re_hoots = regexp.MustCompile(`hoot: ?https://\S+`) @@ -84,9 +84,16 @@ func hootextractor(r io.Reader, url string, seen map[string]bool) string { continue } author := authormatch[1] + if wanted == "" { + wanted = author + } if author != wanted { continue } + for _, img := range imgsel.MatchAll(twp) { + img.Parent.RemoveChild(img) + div.AppendChild(img) + } text := htf.NodeText(div) text = strings.Replace(text, "\n", " ", -1) fmt.Fprintf(&buf, "> @%s: %s\n", author, text)