Skip to content

Commit 678bc71

Browse files
authored
publish: 增加发布移除弹窗的操作 (#201)
* publish: 增加发布移除弹窗的操作 * 随机点击操作 * 更新点击的随机坐标
1 parent 223d9e1 commit 678bc71

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

xiaohongshu/publish.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package xiaohongshu
33
import (
44
"context"
55
"log/slog"
6+
"math/rand"
67
"os"
78
"strings"
89
"time"
@@ -66,15 +67,24 @@ func (p *PublishAction) Publish(ctx context.Context, content PublishImageContent
6667

6768
func removePopCover(page *rod.Page) {
6869

70+
// 先移除弹窗封面
6971
has, elem, err := page.Has("div.d-popover")
7072
if err != nil {
7173
return
7274
}
73-
7475
if has {
7576
elem.MustRemove()
7677
}
7778

79+
// 兜底:点击一下空位置吧
80+
clickEmptyPosition(page) // 点击空位置
81+
}
82+
83+
func clickEmptyPosition(page *rod.Page) {
84+
x := 380 + rand.Intn(100)
85+
y := 20 + rand.Intn(60)
86+
page.Mouse.MustMoveTo(float64(x), float64(y)).MustClick(proto.InputMouseButtonLeft)
87+
logrus.Infof("点击空位置: x=%d, y=%d", x, y)
7888
}
7989

8090
func mustClickPublishTab(page *rod.Page, tabname string) error {

0 commit comments

Comments
 (0)