@iflyrpa/actions 1.2.5 → 1.2.6-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -243,6 +243,24 @@ async function copyHtmlToClipboard(page, html, options = {
243
243
  }, html);
244
244
  }
245
245
  }
246
+ function PopupListener(page, popupSelector, popKey, buttonSelector, options = {}) {
247
+ const { checkInterval = 1000, stopAfterClick = false } = options;
248
+ const popup = page.locator(popupSelector);
249
+ const button = page.locator(buttonSelector);
250
+ const intervalId = setInterval(async ()=>{
251
+ try {
252
+ if (await popup.count() > 0 && await popup.isVisible() && (await popup.textContent() || "").includes(popKey)) {
253
+ await button.click({
254
+ force: true
255
+ });
256
+ if (stopAfterClick) clearInterval(intervalId);
257
+ }
258
+ } catch (err) {}
259
+ }, checkInterval);
260
+ return ()=>{
261
+ clearInterval(intervalId);
262
+ };
263
+ }
246
264
  const parseUrlQueryString = (url)=>{
247
265
  const queryStringObject = {};
248
266
  if (!url || !url.includes("?")) return queryStringObject;
@@ -1149,13 +1167,25 @@ const QuotaType = {
1149
1167
  Normal: "kQuotaTypeMassSendNormal",
1150
1168
  ProductActivity: "kQuotaTypeMassSendProductActivity"
1151
1169
  };
1152
- const GET_QRCODE_DEFAULT_ERROR = "二维码获取异常,请稍后重试发布。";
1170
+ const GET_QRCODE_DEFAULT_ERROR = "二维码获取异常,请稍后重试。";
1153
1171
  const weixinPublish_mock_errnoMap = {
1154
- 200003: "微信公众号号登录状态失效,请重新绑定账号后重试。"
1172
+ 200003: "微信公众号号登录状态失效,请重新绑定账号后重试。",
1173
+ 420001: "封面图不支持GIF,请更换后重试。",
1174
+ 200002: "上传图片参数错误,请检查后重试。",
1175
+ 200039: "上传图片高度(像素)与宽度(像素)的乘积不能超过600万,请更换后重试。",
1176
+ 153201: "不支持发布审核中或转码中的视频",
1177
+ 200007: "登陆失败,请重新登陆账户后重试。",
1178
+ 64703: "摘要超出120字长度限制,请修改摘要后重试。",
1179
+ "-4": "不支持发布审核中或转码中的视频"
1155
1180
  };
1156
1181
  const ignoreErrno = [
1157
1182
  154019
1158
1183
  ];
1184
+ const userTypeMap = {
1185
+ 所有用户: 1,
1186
+ 已关注的用户: 2,
1187
+ 已关注7天及以上的用户: 3
1188
+ };
1159
1189
  const generatorFormData = (data)=>{
1160
1190
  const formData = new URLSearchParams();
1161
1191
  for (const [key, value] of Object.entries(data))formData.append(key, String(value));
@@ -1263,6 +1293,223 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
1263
1293
  const coverRes = await uploadImages([
1264
1294
  params.settingInfo.wxCover
1265
1295
  ]);
1296
+ let oriWhitelist = null;
1297
+ if (params.settingInfo?.wxCopyright && params.settingInfo?.wxWhitelist) {
1298
+ const _oriWhitelist = params.settingInfo.wxWhitelist;
1299
+ if (_oriWhitelist && _oriWhitelist.length > 0) {
1300
+ const white_list = [];
1301
+ const white_list_user = {
1302
+ nickname: "",
1303
+ title: "可修改文章",
1304
+ openid: "",
1305
+ wx_name: "",
1306
+ username: "",
1307
+ avatar: "",
1308
+ can_modify: "1",
1309
+ can_hide_source: "0",
1310
+ can_reward: "0"
1311
+ };
1312
+ for (const _user of _oriWhitelist){
1313
+ const userInfo_res = await http.api({
1314
+ method: "post",
1315
+ url: "https://mp.weixin.qq.com/cgi-bin/appmsgcopyright?action=searchacct",
1316
+ params: {
1317
+ action: "searchacct"
1318
+ },
1319
+ data: generatorFormData({
1320
+ lang: "zh_CN",
1321
+ f: "json",
1322
+ ajax: 1,
1323
+ token: params.token,
1324
+ random: Math.random().toString(),
1325
+ username: _user
1326
+ }),
1327
+ defaultErrorMsg: "搜索用户信息失败"
1328
+ });
1329
+ if (!(userInfo_res.search_list.length > 0)) return {
1330
+ code: 200,
1331
+ message: `白名单用户:${_user} 未搜索到,请确定输入是否正确!`,
1332
+ data: ''
1333
+ };
1334
+ {
1335
+ let userInfo_resJson = userInfo_res.search_list[0];
1336
+ white_list_user.nickname = userInfo_resJson.nickname;
1337
+ white_list_user.openid = userInfo_resJson.openid;
1338
+ white_list_user.avatar = userInfo_resJson.pic_url;
1339
+ white_list_user.username = userInfo_resJson.username;
1340
+ white_list_user.wx_name = userInfo_resJson.wx_name;
1341
+ white_list.push({
1342
+ ...white_list_user
1343
+ });
1344
+ }
1345
+ }
1346
+ oriWhitelist = white_list.length > 0 ? JSON.stringify({
1347
+ white_list: white_list
1348
+ }) : "";
1349
+ }
1350
+ }
1351
+ let writerid = null;
1352
+ let reply_id = null;
1353
+ if (params.settingInfo.wxCopyright && params.settingInfo.wxRewardTarget) {
1354
+ async function getWriterList() {
1355
+ const res = await http.api({
1356
+ method: "get",
1357
+ url: 'https://mp.weixin.qq.com/acct/writermgr',
1358
+ params: {
1359
+ action: 'get_writer_list',
1360
+ fingerprint,
1361
+ token: params.token,
1362
+ lang: "zh_CN",
1363
+ f: "json",
1364
+ ajax: 1
1365
+ }
1366
+ });
1367
+ return res.pageinfo.writerlist || [];
1368
+ }
1369
+ async function getRewardText() {
1370
+ const res = await http.api({
1371
+ method: "get",
1372
+ url: 'https://mp.weixin.qq.com/merchant/reward',
1373
+ params: {
1374
+ action: 'getautoreply',
1375
+ fingerprint,
1376
+ token: params.token,
1377
+ lang: "zh_CN",
1378
+ f: "json",
1379
+ ajax: 1
1380
+ }
1381
+ });
1382
+ return res.reply_infos;
1383
+ }
1384
+ for(var _type in params.settingInfo.wxRewardTarget)if ("author" === _type) {
1385
+ if (0 == (await getWriterList()).length) {
1386
+ const rewardbind = await http.api({
1387
+ method: "get",
1388
+ url: "https://mp.weixin.qq.com/acct/writermgr",
1389
+ params: {
1390
+ action: "get_rewardbind_qrcode",
1391
+ random: Math.random().toString(),
1392
+ fingerprint,
1393
+ token: params.token,
1394
+ lang: "zh_CN",
1395
+ f: "json",
1396
+ ajax: 1
1397
+ },
1398
+ defaultErrorMsg: GET_QRCODE_DEFAULT_ERROR
1399
+ });
1400
+ const rewardBuffer = Buffer.from(rewardbind.qrcode_base64, 'base64');
1401
+ const rewardFilePath = external_node_path_default().join(tmpCachePath, "weixin_reward.jpg");
1402
+ external_node_fs_default().writeFileSync(rewardFilePath, new Uint8Array(rewardBuffer));
1403
+ params.safeQrcodeCallback?.(rewardFilePath);
1404
+ const task_id = rewardbind.task_id;
1405
+ let code = null;
1406
+ for(let i = 0; i < scanRetryMaxCount; i++){
1407
+ await (0, share_namespaceObject.sleep)(2000);
1408
+ const checkScanResult = await http.api({
1409
+ method: "get",
1410
+ url: "https://mp.weixin.qq.com/acct/writermgr",
1411
+ params: {
1412
+ action: "query_rewardbind_qrcode_status",
1413
+ task_id: task_id,
1414
+ fingerprint,
1415
+ lang: "zh_CN",
1416
+ f: "json",
1417
+ ajax: 1,
1418
+ token: params.token,
1419
+ timespam: Date.now()
1420
+ }
1421
+ });
1422
+ code = checkScanResult.qrcode_status;
1423
+ if (2 == code && (await getWriterList()).length > 0) break;
1424
+ if (i === scanRetryMaxCount - 1) return {
1425
+ code: 200,
1426
+ message: "二维码已过期,请重试绑定。",
1427
+ data: ""
1428
+ };
1429
+ }
1430
+ }
1431
+ let _writer = await getWriterList();
1432
+ for (var _writer_item of _writer)if (_writer_item.nickname === params.settingInfo.wxRewardTarget[_type]) writerid = _writer_item.writerid;
1433
+ if (!writerid) return {
1434
+ code: 200,
1435
+ message: "未匹配到赞赏绑定用户,请确认用户名与绑定是否正常!",
1436
+ data: ""
1437
+ };
1438
+ if (params.settingInfo?.wxRewardText) {
1439
+ let rewardList = await getRewardText();
1440
+ let matchdID = rewardList.find((reward)=>reward.text === params.settingInfo.wxRewardText)?.reply_id ?? null;
1441
+ if (0 != rewardList.length && matchdID) reply_id = matchdID;
1442
+ else await http.api({
1443
+ method: "post",
1444
+ url: 'https://mp.weixin.qq.com/merchant/reward',
1445
+ params: {
1446
+ action: 'addautoreply'
1447
+ },
1448
+ data: generatorFormData({
1449
+ type: 1,
1450
+ fingerprint,
1451
+ token: params.token,
1452
+ lang: "zh_CN",
1453
+ f: "json",
1454
+ ajax: 1,
1455
+ text: params.settingInfo.wxRewardText
1456
+ })
1457
+ });
1458
+ if (!matchdID) {
1459
+ for (var _reply_item of (await getRewardText()))reply_id = (await getRewardText()).find((reward)=>reward.text === params.settingInfo.wxRewardText)?.reply_id;
1460
+ if (!reply_id) return {
1461
+ code: 200,
1462
+ message: "赞赏文案添加失败,请重新检查",
1463
+ data: ""
1464
+ };
1465
+ }
1466
+ }
1467
+ }
1468
+ }
1469
+ const wxInteractionInfo = (()=>{
1470
+ const _wxInteraction = {
1471
+ need_open_comment0: 0,
1472
+ only_fans_can_comment0: 0,
1473
+ only_fans_days_can_comment0: 0,
1474
+ reply_flag0: 2,
1475
+ auto_elect_comment0: 0,
1476
+ auto_elect_reply0: 1,
1477
+ open_fansmsg0: 0
1478
+ };
1479
+ const type = params?.settingInfo?.wxInteraction?.Type ?? "";
1480
+ if ("public" === type) {
1481
+ const _opt = params?.settingInfo?.wxInteraction?.Option;
1482
+ if (!_opt || !_opt.Comment || !_opt.reply || null == _opt.elect_comment || null == _opt.elect_reply) return null;
1483
+ const commentType = userTypeMap[_opt.Comment];
1484
+ const replyType = userTypeMap[_opt.reply] + 1;
1485
+ _wxInteraction.need_open_comment0 = 1;
1486
+ switch(commentType){
1487
+ case 1:
1488
+ _wxInteraction.only_fans_can_comment0 = 0;
1489
+ _wxInteraction.only_fans_days_can_comment0 = 0;
1490
+ break;
1491
+ case 2:
1492
+ _wxInteraction.only_fans_can_comment0 = 1;
1493
+ _wxInteraction.only_fans_days_can_comment0 = 0;
1494
+ break;
1495
+ case 3:
1496
+ _wxInteraction.only_fans_can_comment0 = 0;
1497
+ _wxInteraction.only_fans_days_can_comment0 = 1;
1498
+ break;
1499
+ }
1500
+ _wxInteraction.reply_flag0 = replyType;
1501
+ _wxInteraction.auto_elect_comment0 = _opt.elect_comment ? userTypeMap[_opt.Comment] : 0;
1502
+ _wxInteraction.auto_elect_reply0 = _opt.elect_reply ? userTypeMap[_opt.reply] : 1;
1503
+ return _wxInteraction;
1504
+ }
1505
+ if ("private" === type) _wxInteraction.open_fansmsg0 = 1;
1506
+ return _wxInteraction;
1507
+ })();
1508
+ if (!wxInteractionInfo) return {
1509
+ code: 200,
1510
+ message: "互动参数设置错误,请检查参数设置!",
1511
+ data: ""
1512
+ };
1266
1513
  const draftData = {
1267
1514
  lang: "zh_CN",
1268
1515
  f: "json",
@@ -1275,16 +1522,19 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
1275
1522
  is_finder_video0: 0,
1276
1523
  finder_draft_id0: 0,
1277
1524
  applyori0: 0,
1278
- can_reward0: 0,
1525
+ can_reward0: writerid ? 1 : 0,
1279
1526
  pay_gifts_count0: 0,
1280
1527
  is_video_recommend0: -1,
1281
- writerid0: 0,
1528
+ writerid0: writerid ? writerid : 0,
1282
1529
  auto_gen_digest0: 0,
1283
1530
  last_choose_cover_from0: 0,
1284
- need_open_comment0: 0,
1285
- only_fans_can_comment0: 0,
1286
- only_fans_days_can_comment0: 0,
1287
- reply_flag0: 0,
1531
+ need_open_comment0: wxInteractionInfo.need_open_comment0,
1532
+ only_fans_can_comment0: wxInteractionInfo.only_fans_can_comment0,
1533
+ only_fans_days_can_comment0: wxInteractionInfo.only_fans_days_can_comment0,
1534
+ reply_flag0: wxInteractionInfo.reply_flag0,
1535
+ auto_elect_comment0: wxInteractionInfo.auto_elect_comment0,
1536
+ auto_elect_reply0: wxInteractionInfo.auto_elect_reply0,
1537
+ reward_reply_id0: params.settingInfo?.wxRewardText ? reply_id ? reply_id : 0 : 0,
1288
1538
  not_pay_can_comment0: 0,
1289
1539
  data_seq: 0,
1290
1540
  msg_index_id0: "",
@@ -1296,7 +1546,11 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
1296
1546
  content0: content || "",
1297
1547
  sourceurl0: params?.settingInfo?.wxOriginalText || "",
1298
1548
  cdn_url0: coverRes[0].cdn_url || "",
1299
- open_fansmsg0: params?.settingInfo?.wxFansMsg ? 1 : 0,
1549
+ copyright_type0: params?.settingInfo?.wxCopyright ? 1 : 0,
1550
+ allow_reprint0: params?.settingInfo?.wxCopyright ? 0 : '',
1551
+ allow_reprint_modify0: params?.settingInfo?.wxCopyright ? 0 : '',
1552
+ ori_white_list0: params?.settingInfo?.wxCopyright ? oriWhitelist : '',
1553
+ open_fansmsg0: wxInteractionInfo.open_fansmsg0,
1300
1554
  allow_fast_reprint0: params?.settingInfo?.wxQuickReprint ? 1 : 0,
1301
1555
  disable_recommend0: params?.settingInfo?.wxNotAllowRecommend ? 1 : 0,
1302
1556
  claim_source_type0: params?.settingInfo?.wxCreationSource?.[0] || "",
@@ -1647,6 +1901,81 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
1647
1901
  timestamp: Date.now(),
1648
1902
  appmsgid: params.appMsgId
1649
1903
  };
1904
+ if (params.settingInfo?.wxRewardTarget) {
1905
+ const urlRewardParams = {
1906
+ action: "inviteauthor",
1907
+ token: params.token,
1908
+ lang: "zh_CN"
1909
+ };
1910
+ const wxRewardPage = await task.createPage({
1911
+ show: task.debug,
1912
+ url: params.url || `https://mp.weixin.qq.com/cgi-bin/safecenterstatus?${Object.entries(urlRewardParams).map((it)=>it.join("=")).join("&")}`,
1913
+ cookies: params.cookies?.map((it)=>({
1914
+ ...commonCookies,
1915
+ ...it
1916
+ })) || []
1917
+ });
1918
+ const reward_page = wxRewardPage.locator("#app");
1919
+ const isAddRewarder = reward_page.locator('.author_card_bd.weui-desktop-vm_primary').filter({
1920
+ hasText: params.settingInfo.wxRewardTarget.author
1921
+ }).count();
1922
+ if (await isAddRewarder == 0) {
1923
+ await reward_page.locator('.weui-desktop-panel__hd-right').click();
1924
+ try {
1925
+ try {
1926
+ await wxRewardPage.waitForSelector('.invite-qrcode', {
1927
+ state: 'visible',
1928
+ timeout: 20000
1929
+ });
1930
+ const qrcodeSrc = await reward_page.locator(".invite-qrcode").getAttribute('src');
1931
+ if (qrcodeSrc) {
1932
+ const rewardBuffer = Buffer.from(qrcodeSrc.replace(/^data:image\/\w+;base64,/, ''), 'base64');
1933
+ const rewardFilePath = external_node_path_default().join(tmpCachePath, "weixin_reward.jpg");
1934
+ external_node_fs_default().writeFileSync(rewardFilePath, new Uint8Array(rewardBuffer));
1935
+ params.safeQrcodeCallback?.(rewardFilePath);
1936
+ }
1937
+ } catch (error) {
1938
+ throw new Error("二维码已过期,请重试绑定。");
1939
+ }
1940
+ for(let i = 0; i < scanRetryMaxCount; i++){
1941
+ await Promise.all([
1942
+ wxRewardPage.reload(),
1943
+ wxRewardPage.waitForLoadState('domcontentloaded')
1944
+ ]);
1945
+ try {
1946
+ await wxRewardPage.waitForSelector(`.author_card_bd.weui-desktop-vm_primary:has-text("${params.settingInfo.wxRewardTarget?.author}")`, {
1947
+ timeout: 1000
1948
+ });
1949
+ break;
1950
+ } catch (error) {}
1951
+ if (i === scanRetryMaxCount - 1) throw new Error("未确认绑定账户,请在手机端确认绑定并重试");
1952
+ }
1953
+ } catch (error) {
1954
+ let errorMessage = "发生未知错误";
1955
+ if (error instanceof Error) errorMessage = error.message;
1956
+ else if ("string" == typeof error) errorMessage = error;
1957
+ await wxRewardPage.close();
1958
+ return {
1959
+ code: 200,
1960
+ message: errorMessage,
1961
+ data: ""
1962
+ };
1963
+ }
1964
+ }
1965
+ if (params.settingInfo.wxRewardText) {
1966
+ await wxRewardPage.locator('[href="/merchant/reward?action=getautoreply"]').click();
1967
+ await wxRewardPage.waitForLoadState('networkidle');
1968
+ const isAddWord = reward_page.locator(".auto-reply__list.edit .auto-reply__hd .auto-reply__text").filter({
1969
+ hasText: new RegExp(`^${params.settingInfo.wxRewardText}$`)
1970
+ }).count();
1971
+ if (await isAddWord == 0) {
1972
+ await reward_page.locator(".emotion_editor .edit_area").fill(params.settingInfo.wxRewardText);
1973
+ await reward_page.locator(".emotion_editor .edit_area").click();
1974
+ await reward_page.locator(".editor_toolbar .weui-desktop-btn.weui-desktop-btn_primary").click();
1975
+ }
1976
+ }
1977
+ await wxRewardPage.close();
1978
+ }
1650
1979
  const page = await task.createPage({
1651
1980
  show: task.debug,
1652
1981
  url: params.url || `https://mp.weixin.qq.com/cgi-bin/appmsg?${Object.entries(urlParams).map((it)=>it.join("=")).join("&")}`,
@@ -1669,6 +1998,10 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
1669
1998
  await page.waitForSelector("#editor_pannel", {
1670
1999
  state: "visible"
1671
2000
  });
2001
+ PopupListener(page, '[v-transfer-dom="#vue_app"] .weui-desktop-dialog', "更新", '[v-transfer-dom="#vue_app"] .weui-desktop-icon-btn.weui-desktop-dialog__close-btn', {
2002
+ checkInterval: 1000,
2003
+ stopAfterClick: false
2004
+ });
1672
2005
  const titleInstance = page.locator("#js_title_main textarea#title");
1673
2006
  await titleInstance.click();
1674
2007
  await titleInstance.fill(params.title);
@@ -1710,7 +2043,15 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
1710
2043
  await page.waitForSelector(".weui-desktop-img-picker__list .weui-desktop-img-picker__item.selected", {
1711
2044
  state: "visible"
1712
2045
  });
1713
- await page.waitForTimeout(1000);
2046
+ await page.waitForSelector('.weui-desktop-upload__file__progress', {
2047
+ state: 'detached'
2048
+ });
2049
+ const pic_msg = page.locator('.weui-desktop-img-picker__list .weui-desktop-img-picker__item.selected .weui-desktop-upload__file__msg');
2050
+ if (await pic_msg.count() > 0) return {
2051
+ code: 200,
2052
+ message: "图片上传错误:" + (await pic_msg.textContent() || "未知错误,请重试!"),
2053
+ data: ""
2054
+ };
1714
2055
  await dialog.locator(".weui-desktop-dialog__ft .weui-desktop-btn:not(.weui-desktop-btn_disabled)").filter({
1715
2056
  hasText: "下一步"
1716
2057
  }).click();
@@ -1723,6 +2064,124 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
1723
2064
  hasText: "确认"
1724
2065
  }).click();
1725
2066
  }
2067
+ if (params.settingInfo.wxCopyright) {
2068
+ await page.locator('#js_original').click();
2069
+ const ori_dialog = page.locator('.claim__original-dialog.original_dialog');
2070
+ const ori_dialog_bd = ori_dialog.locator('.weui-desktop-dialog__bd');
2071
+ const ori_dialog_ft = ori_dialog.locator('.weui-desktop-dialog__ft');
2072
+ await ori_dialog_bd.locator('.weui-desktop-form__check-content').filter({
2073
+ hasText: "文字原创"
2074
+ }).click();
2075
+ if (params.settingInfo?.wxWhitelist) for (var _target of params.settingInfo.wxWhitelist){
2076
+ await ori_dialog_bd.locator('#js_article_whitelist_search').fill(_target);
2077
+ await ori_dialog_bd.locator('.js_search').click();
2078
+ const search_res = ori_dialog_bd.locator('#js_article_whitelist_search_result > div');
2079
+ await page.waitForTimeout(1000);
2080
+ if (await search_res.getAttribute('class') === 'search-result-title search-result-empty') return {
2081
+ code: 200,
2082
+ message: `白名单用户:${_target} 未搜索到,请确定输入是否正确!`,
2083
+ data: ''
2084
+ };
2085
+ {
2086
+ const search_res_name = await search_res.locator('.search-result-name-left').textContent() || void 0;
2087
+ await search_res.click();
2088
+ const whrite_list = ori_dialog_bd.locator('#js_article_whitelist_added tbody');
2089
+ const white_td_isadd = await whrite_list.locator('.table-td-name').filter({
2090
+ hasText: search_res_name
2091
+ }).count();
2092
+ if (!white_td_isadd) return {
2093
+ code: 200,
2094
+ message: '白名单添加失败,请重试!',
2095
+ data: ''
2096
+ };
2097
+ }
2098
+ }
2099
+ if (params.settingInfo?.wxQuickReprint) {
2100
+ const btn_isChecked = await ori_dialog_bd.locator('//span[@class="frm_tips"]').filter({
2101
+ hasText: '已开启'
2102
+ }).count() == 1;
2103
+ if (!btn_isChecked) await ori_dialog_bd.locator('.weui-desktop-switch_loading .weui-desktop-switch__box').click();
2104
+ }
2105
+ const checkbox = ori_dialog_ft.locator('.weui-desktop-icon-checkbox');
2106
+ if (!await checkbox.isChecked()) await checkbox.check();
2107
+ await ori_dialog_ft.locator('.weui-desktop-btn.weui-desktop-btn_primary').click();
2108
+ if (params.settingInfo?.wxRewardTarget) {
2109
+ await page.locator('#js_reward_setting_area').click();
2110
+ const reward_setting = page.locator('.reward-setting-dialog');
2111
+ const reward_setting_bd = reward_setting.locator('.weui-desktop-dialog__bd');
2112
+ const reward_setting_ft = reward_setting.locator('.weui-desktop-dialog__ft');
2113
+ for(var _type in params.settingInfo.wxRewardTarget)if ("author" === _type) {
2114
+ let userName = params.settingInfo.wxRewardTarget[_type];
2115
+ await reward_setting_bd.locator('.weui-desktop-form__check-label', {
2116
+ hasText: '赞赏作者'
2117
+ }).click();
2118
+ await reward_setting_bd.locator('.weui-desktop-form__input').fill(userName);
2119
+ if (params.settingInfo.wxRewardText) {
2120
+ const reward_setting_replay = page.locator('.reward-reply-setting');
2121
+ const switchAuto = reward_setting_replay.locator('.weui-desktop-switch__box');
2122
+ const maxAttempts = 5;
2123
+ const delayMs = 500;
2124
+ let nowCheckTime = 0;
2125
+ for(let attempt = 0; attempt < maxAttempts; attempt++){
2126
+ const isDisabled = await switchAuto.isDisabled();
2127
+ if (!isDisabled) {
2128
+ await switchAuto.isChecked() && nowCheckTime++;
2129
+ if (2 == nowCheckTime) break;
2130
+ }
2131
+ if (attempt === maxAttempts - 1) throw new Error('Checkbox did not become enabled within the timeout.');
2132
+ await new Promise((resolve)=>setTimeout(resolve, delayMs));
2133
+ }
2134
+ const isOneReplay = await reward_setting_replay.locator('.reward-reply-select__wrp >.reward-reply-select__tips').textContent() == "添加新的回复";
2135
+ const isCurrentReplay = await reward_setting_replay.locator('.reward-reply-select__wrp >.reward-reply-select__display .wording').filter({
2136
+ hasText: new RegExp(`^${[
2137
+ params.settingInfo.wxRewardText
2138
+ ]}$`)
2139
+ }).count() == 1;
2140
+ if (!isOneReplay && !isCurrentReplay) {
2141
+ await reward_setting_replay.locator('.reward-reply-select__wrp >.reward-reply-select__tips').click();
2142
+ await reward_setting_replay.locator('.reward-reply-select__display.can-select .wording').filter({
2143
+ hasText: new RegExp(`^${[
2144
+ params.settingInfo.wxRewardText
2145
+ ]}$`)
2146
+ }).click();
2147
+ }
2148
+ } else await reward_setting_bd.locator('.reward-reply-setting .weui-desktop-switch__input').isChecked() && reward_setting_bd.locator('.reward-reply-setting .weui-desktop-switch__box').uncheck();
2149
+ }
2150
+ const checkbox = reward_setting_ft.locator('.weui-desktop-icon-checkbox');
2151
+ if (!await checkbox.isChecked()) await checkbox.check();
2152
+ await reward_setting_ft.locator('.weui-desktop-btn.weui-desktop-btn_primary').click();
2153
+ }
2154
+ }
2155
+ if (params.settingInfo?.wxInteraction) {
2156
+ await page.locator('.appmsg-editor__setting-group.js_interaction_cell').click();
2157
+ const wxInteraction_setting = page.locator('.interaction-dialog');
2158
+ const wxInteraction_bd = wxInteraction_setting.locator('.weui-desktop-dialog__bd');
2159
+ const wxInteraction_ft = wxInteraction_setting.locator('.weui-desktop-dialog__ft');
2160
+ if ("public" == params.settingInfo.wxInteraction.Type) {
2161
+ await wxInteraction_bd.locator('.weui-desktop-form__check-label', {
2162
+ hasText: '留言'
2163
+ }).click();
2164
+ const comment_area = wxInteraction_bd.locator('.comment-options-block.pt0');
2165
+ const reply_area = wxInteraction_bd.locator('.comment-options-block.bb0.pb0');
2166
+ const commont_rply_opt = page.locator('.weui-desktop-popper.options-popover[x-placement="bottom"]');
2167
+ await comment_area.locator('.comment-options__selector-btn').click();
2168
+ await commont_rply_opt.locator('.weui-desktop-form__check-label', {
2169
+ hasText: params.settingInfo.wxInteraction.Option?.Comment
2170
+ }).click();
2171
+ if (params.settingInfo.wxInteraction.Option?.elect_comment) await comment_area.locator('.weui-desktop-switch__box').check();
2172
+ else await comment_area.locator('.weui-desktop-switch__input').isChecked() && comment_area.locator('.weui-desktop-switch__box').uncheck();
2173
+ await page.waitForTimeout(1000);
2174
+ await reply_area.locator('.comment-options__selector-btn').click();
2175
+ await commont_rply_opt.locator('.weui-desktop-form__check-label', {
2176
+ hasText: params.settingInfo.wxInteraction.Option?.reply
2177
+ }).click();
2178
+ if (params.settingInfo.wxInteraction.Option?.elect_reply) await reply_area.locator('.weui-desktop-switch__box').check();
2179
+ else await reply_area.locator('.weui-desktop-switch__input').isChecked() && reply_area.locator('.weui-desktop-switch__box').uncheck();
2180
+ } else if ("private" == params.settingInfo.wxInteraction.Type) await wxInteraction_bd.locator('.weui-desktop-form__check-label', {
2181
+ hasText: '快捷私信'
2182
+ }).click();
2183
+ await wxInteraction_ft.locator('.weui-desktop-btn.weui-desktop-btn_primary').click();
2184
+ }
1726
2185
  if (params.settingInfo.wxOriginalText) {
1727
2186
  await page.locator("#js_article_url_area .allow_click_opr").click();
1728
2187
  await page.waitForTimeout(200);
@@ -2461,7 +2920,7 @@ const xiaohongshuPublish = async (task, params)=>{
2461
2920
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
2462
2921
  };
2463
2922
  var package_namespaceObject = {
2464
- i8: "1.2.4"
2923
+ i8: "1.2.5"
2465
2924
  };
2466
2925
  class Action {
2467
2926
  constructor(task){