@iflyrpa/actions 1.2.11-beta.1 → 1.2.11-beta.3

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
@@ -1269,9 +1269,14 @@ var __webpack_exports__ = {};
1269
1269
  dd: String(date.getDate()).padStart(2, '0'),
1270
1270
  hh: String(date.getHours()).padStart(2, '0'),
1271
1271
  mm: String(date.getMinutes()).padStart(2, '0'),
1272
- ss: String(date.getSeconds()).padStart(2, '0')
1272
+ ss: String(date.getSeconds()).padStart(2, '0'),
1273
+ M: String(date.getMonth() + 1),
1274
+ d: String(date.getDate()),
1275
+ h: String(date.getHours()),
1276
+ m: String(date.getMinutes()),
1277
+ s: String(date.getSeconds())
1273
1278
  };
1274
- return formatStr.replace(/yyyy|yy|MM|dd|hh|mm|ss/g, (key)=>map[key]);
1279
+ return formatStr.replace(/yyyy|yy|MM|dd|hh|mm|ss|M|d|h|m|s/g, (key)=>map[key]);
1275
1280
  }
1276
1281
  }
1277
1282
  const replaceImgSrc = (html, callback)=>{
@@ -1518,13 +1523,15 @@ var __webpack_exports__ = {};
1518
1523
  is_checked: 1
1519
1524
  }
1520
1525
  ] : [],
1521
- ...isAi ? [
1522
- {
1523
- id: "aigc_bjh_status",
1524
- is_checked: 1
1525
- }
1526
- ] : []
1526
+ ...params.settingInfo.baijiahaoPublishConf?.map((item)=>({
1527
+ id: item.confName,
1528
+ is_checked: item.isChecked ? 1 : 0
1529
+ })) || []
1527
1530
  ];
1531
+ if (isAi && !activity_list.some((item)=>'aigc_bjh_status' in item)) activity_list.push({
1532
+ id: 'aigc_bjh_status',
1533
+ is_checked: 1
1534
+ });
1528
1535
  const publishData = {
1529
1536
  title: params.settingInfo.baijiahaoTitle,
1530
1537
  content,
@@ -1540,8 +1547,10 @@ var __webpack_exports__ = {};
1540
1547
  usingImgFilter: "false",
1541
1548
  source: "upload",
1542
1549
  cover_source: "upload",
1550
+ event2news: params.settingInfo?.baijiahaoEvent2News ? 2 : 0,
1543
1551
  activity_list
1544
1552
  };
1553
+ params.settingInfo.timer && (publishData['timer_time'] = params.settingInfo.timer);
1545
1554
  const isDraft = "draft" === params.saveType;
1546
1555
  const saveUrl = isDraft ? "https://baijiahao.baidu.com/pcui/article/save?callback=bjhdraft" : "https://baijiahao.baidu.com/pcui/article/publish?callback=bjhpublish";
1547
1556
  const res = await http.api({
@@ -1646,12 +1655,17 @@ var __webpack_exports__ = {};
1646
1655
  await abstractFormItem.click();
1647
1656
  await abstractFormItem.fill(params.settingInfo.baijiahaoAbstract);
1648
1657
  const isAi = params.settingInfo.baijiahaoIsAi.includes("isAi");
1649
- if (isAi) {
1650
- const settingFormItem = page.locator(".bjh-edit-wrap-set .cheetah-form-item").nth(5);
1651
- await settingFormItem.locator("label.cheetah-checkbox-wrapper").filter({
1652
- hasText: "AI创作声明"
1653
- }).click();
1658
+ const settingFormItem = page.locator(".bjh-edit-wrap-set .cheetah-form-item").nth(5);
1659
+ if (isAi) await settingFormItem.locator("label.cheetah-checkbox-wrapper").filter({
1660
+ hasText: "AI创作声明"
1661
+ }).click();
1662
+ if (params.settingInfo.baijiahaoPublishConf) for (const item of params.settingInfo.baijiahaoPublishConf){
1663
+ const _settingFormItem = settingFormItem.locator("label.cheetah-checkbox-wrapper").locator(`span.${item.confName}`);
1664
+ if (await _settingFormItem.isChecked() !== item.isChecked) await _settingFormItem.click();
1665
+ await page.waitForTimeout(200);
1654
1666
  }
1667
+ const enent2NewsBtn = page.locator("input#event2news");
1668
+ if (await enent2NewsBtn.isVisible() && params.settingInfo.baijiahaoEvent2News) await enent2NewsBtn.click();
1655
1669
  if (params.settingInfo.baijiahaoActivity.length > 0 && params.settingInfo.baijiahaoSelectActivityCache.length > 0) {
1656
1670
  const activity = params.settingInfo.baijiahaoActivity.filter((it)=>params.settingInfo.baijiahaoSelectActivityCache.includes(it.id));
1657
1671
  if (activity.length > 0) {
@@ -1663,13 +1677,16 @@ var __webpack_exports__ = {};
1663
1677
  if (await findActivity.count() > 0) findActivity.first().locator("..").click();
1664
1678
  }
1665
1679
  }
1666
- const articleId = await new Promise((resolve)=>{
1680
+ const { articleId, message } = await new Promise(async (resolve)=>{
1667
1681
  const handleResponse = async (response)=>{
1668
1682
  const url = response.url();
1669
1683
  if (url.includes("/pcui/article/save") || url.includes("/pcui/article/publish")) {
1670
1684
  const jsonResponse = await response.json();
1671
1685
  page.off("response", handleResponse);
1672
- resolve(jsonResponse?.ret?.article_id);
1686
+ resolve({
1687
+ articleId: jsonResponse?.ret?.article_id,
1688
+ message: jsonResponse?.errmsg
1689
+ });
1673
1690
  }
1674
1691
  };
1675
1692
  page.on("response", handleResponse);
@@ -1677,12 +1694,75 @@ var __webpack_exports__ = {};
1677
1694
  if ("draft" === params.saveType) operatorContainer.locator(".op-btn-outter-content").filter({
1678
1695
  hasText: "存草稿"
1679
1696
  }).locator("button").click();
1680
- else operatorContainer.locator(".op-btn-outter-content").filter({
1681
- hasText: "发布"
1697
+ else if (params.settingInfo.timer) {
1698
+ await operatorContainer.locator(".op-btn-outter-content").filter({
1699
+ hasText: "定时发布"
1700
+ }).locator("button").click();
1701
+ await page.locator(".timepublish-wrap-select .select-wrap", {
1702
+ hasText: "日"
1703
+ }).click();
1704
+ await page.locator('#select-date_list + * .cheetah-select-item-option', {
1705
+ hasText: TimeFormatter.format(params.settingInfo.timer, "M月dd日")
1706
+ }).click();
1707
+ await page.waitForTimeout(200);
1708
+ await page.locator(".timepublish-wrap-select .select-wrap", {
1709
+ hasText: "点"
1710
+ }).click();
1711
+ await page.locator('#select-hour_list +div.rc-virtual-list').hover();
1712
+ const scrollHourInfo = await page.evaluate(()=>{
1713
+ const hourInner = document.querySelector('#select-hour_list + * .rc-virtual-list-holder-inner');
1714
+ const hourElementHeight = hourInner?.children[0].clientHeight || 36;
1715
+ const hourMapsElem = Array.from(document.querySelectorAll('#select-hour_list + * .cheetah-select-item-option .cheetah-select-item-option-content'));
1716
+ const hourMap = hourMapsElem.map((item)=>item.textContent?.trim());
1717
+ return {
1718
+ elementHeight: hourElementHeight,
1719
+ elementItem: hourMap
1720
+ };
1721
+ });
1722
+ const fistHourElem = scrollHourInfo.elementItem[0];
1723
+ let fistHourElemH = Number(fistHourElem?.split("点")[0]);
1724
+ const lastHourElem = scrollHourInfo.elementItem[scrollHourInfo.elementItem.length - 1];
1725
+ let lastHourElemH = Number(lastHourElem?.split("点")[0]);
1726
+ let targetTimeH = Number(TimeFormatter.format(params.settingInfo.timer, 'h'));
1727
+ await page.mouse.wheel(0, targetTimeH > lastHourElemH ? (targetTimeH - lastHourElemH) * scrollHourInfo.elementHeight : targetTimeH < fistHourElemH ? -(fistHourElemH - targetTimeH) * scrollHourInfo.elementHeight : 0);
1728
+ await page.locator("#select-hour_list + * .cheetah-select-item-option ", {
1729
+ hasText: targetTimeH + "点"
1730
+ }).click();
1731
+ await page.waitForTimeout(200);
1732
+ await page.locator(".timepublish-wrap-select .select-wrap", {
1733
+ hasText: "分"
1734
+ }).click();
1735
+ await page.locator('#select-minute_list +div.rc-virtual-list').hover();
1736
+ const scrollMinuteInfo = await page.evaluate(()=>{
1737
+ const hourInner = document.querySelector('#select-minute_list + * .rc-virtual-list-holder-inner');
1738
+ const hourElementHeight = hourInner?.children[0].clientHeight || 36;
1739
+ const hourMapsElem = Array.from(document.querySelectorAll('#select-minute_list + * .cheetah-select-item-option .cheetah-select-item-option-content'));
1740
+ const hourMap = hourMapsElem.map((item)=>item.textContent?.trim());
1741
+ return {
1742
+ elementHeight: hourElementHeight,
1743
+ elementItem: hourMap
1744
+ };
1745
+ });
1746
+ const fistMinuteElem = scrollMinuteInfo.elementItem[0];
1747
+ let fistMinuteElemH = Number(fistMinuteElem?.split("分")[0]);
1748
+ const lastMinuteElem = scrollMinuteInfo.elementItem[scrollMinuteInfo.elementItem.length - 1];
1749
+ let lastMinuteElemH = Number(lastMinuteElem?.split("分")[0]);
1750
+ let targetTimeM = Number(TimeFormatter.format(params.settingInfo.timer, 'm'));
1751
+ await page.mouse.wheel(0, targetTimeM > lastMinuteElemH ? (targetTimeM - lastMinuteElemH) * scrollMinuteInfo.elementHeight : targetTimeM < fistMinuteElemH ? -(fistMinuteElemH - targetTimeM) * scrollMinuteInfo.elementHeight : 0);
1752
+ await page.locator("#select-minute_list + * .cheetah-select-item-option ", {
1753
+ hasText: targetTimeM + "分"
1754
+ }).click();
1755
+ await page.waitForTimeout(200);
1756
+ await page.locator(".cheetah-modal-confirm-btns button").filter({
1757
+ hasText: "定时发布"
1758
+ }).click();
1759
+ } else operatorContainer.locator(".op-btn-outter-content").filter({
1760
+ hasText: /^发布/
1682
1761
  }).locator("button").click();
1683
1762
  });
1763
+ await page.waitForTimeout(200000);
1684
1764
  await page.close();
1685
- return (0, share_namespaceObject.success)(articleId);
1765
+ return (0, share_namespaceObject.success)(articleId, articleId ? "发布成功" : message);
1686
1766
  };
1687
1767
  const baijiahaoPublish = async (task, params)=>{
1688
1768
  if ("rpa" === params.actionType) return rpaAction(task, params);
@@ -1767,6 +1847,28 @@ var __webpack_exports__ = {};
1767
1847
  userRights
1768
1848
  });
1769
1849
  };
1850
+ const getBaijiahaoConfig = async (_task, params)=>{
1851
+ const cookies = params.cookies ?? [];
1852
+ const http = new Http({
1853
+ headers: {
1854
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
1855
+ token: params.token
1856
+ }
1857
+ });
1858
+ const res = await http.api({
1859
+ method: "get",
1860
+ url: "https://baijiahao.baidu.com/pcui/article/edit",
1861
+ params: {
1862
+ type: "news"
1863
+ }
1864
+ });
1865
+ return (0, share_namespaceObject.success)(res?.data?.article.activity_list.map((_item)=>({
1866
+ id: _item.id,
1867
+ name: _item.name,
1868
+ detail: _item.detail,
1869
+ is_enable: _item.is_enable
1870
+ })) ?? [], "获取头条发布配置项成功");
1871
+ };
1770
1872
  const searchToutiaoTopicList = async (_task, params)=>{
1771
1873
  const http = new Http({
1772
1874
  headers: {
@@ -1789,6 +1891,72 @@ var __webpack_exports__ = {};
1789
1891
  return (0, share_namespaceObject.success)([]);
1790
1892
  }
1791
1893
  };
1894
+ const searchToutiaoLocation = async (_task, params)=>{
1895
+ const http = new Http({
1896
+ headers: {
1897
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
1898
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish",
1899
+ biz: 1231
1900
+ }
1901
+ });
1902
+ try {
1903
+ const res = await http.api({
1904
+ method: "post",
1905
+ url: "https://mp.toutiao.com/poi/api/searchplace",
1906
+ data: {
1907
+ appid: 1231,
1908
+ device: 2,
1909
+ keywords: params.placeName,
1910
+ language: "zh-CN",
1911
+ location: "-1,-1",
1912
+ offset: 20,
1913
+ page: 1,
1914
+ region: "CN",
1915
+ scenario: "TIPS",
1916
+ timestamp: Math.floor(Date.now() / 1000)
1917
+ }
1918
+ });
1919
+ if (200 === res.code) return (0, share_namespaceObject.success)(res.data.poi.map((item)=>({
1920
+ position: item.name,
1921
+ city: item.city,
1922
+ longitude: item.longitude,
1923
+ latitude: item.latitude,
1924
+ type_code: item.type_code,
1925
+ poi_id: item.id
1926
+ })));
1927
+ return (0, share_namespaceObject.success)([]);
1928
+ } catch (error) {
1929
+ return (0, share_namespaceObject.success)([]);
1930
+ }
1931
+ };
1932
+ const searchToutiaoUserInfo = async (_task, params)=>{
1933
+ const http = new Http({
1934
+ headers: {
1935
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
1936
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
1937
+ }
1938
+ });
1939
+ try {
1940
+ const res = await http.api({
1941
+ method: "get",
1942
+ url: "https://mp.toutiao.com/ugc/publish/post/v1/suggest/",
1943
+ params: {
1944
+ words: params.UserName,
1945
+ language: "zh",
1946
+ app_name: "toutiao_mp"
1947
+ }
1948
+ });
1949
+ if (0 === res.err_no) return (0, share_namespaceObject.success)(res.data.suggest.map((item)=>({
1950
+ user_id: item.user.info.user_id,
1951
+ name: item.user.info.name,
1952
+ avatar_url: item.user.info.avatar_url,
1953
+ followers_count: item.user.relation_count.followers_count
1954
+ })), '搜索成功');
1955
+ return (0, share_namespaceObject.success)([]);
1956
+ } catch (error) {
1957
+ return (0, share_namespaceObject.success)([]);
1958
+ }
1959
+ };
1792
1960
  const searchXiaohongshuLocation = async (_task, params)=>{
1793
1961
  const http = new Http({
1794
1962
  headers: {
@@ -1863,7 +2031,7 @@ var __webpack_exports__ = {};
1863
2031
  2005: "账号无【申明原创】权限,请关闭申明后重试。",
1864
2032
  100004: "用户未登录或登陆已过期,请重新登陆后重试。"
1865
2033
  };
1866
- const generatorFormData = (data)=>Object.entries(data).map(([key, value])=>{
2034
+ const mock_generatorFormData = (data)=>Object.entries(data).map(([key, value])=>{
1867
2035
  const encodedKey = encodeURIComponent(key);
1868
2036
  const encodedValue = encodeURIComponent(String(value));
1869
2037
  return `${encodedKey}=${encodedValue}`;
@@ -1876,7 +2044,7 @@ var __webpack_exports__ = {};
1876
2044
  return error || ("draft" === saveType ? "文章同步异常,请稍后重试。" : "文章发布异常,请稍后重试。");
1877
2045
  };
1878
2046
  const mock_mockAction = async (task, params)=>{
1879
- const { toutiaoSingleCover, toutiaoMultCover, toutiaoCoverType, toutiaoOriginal } = params.settingInfo;
2047
+ const { toutiaoSingleCover, toutiaoMultCover, toutiaoCoverType, toutiaoOriginal, toutiaoExclusive, toutiaoClaim } = params.settingInfo;
1880
2048
  const tmpCachePath = task.getTmpPath();
1881
2049
  const http = new Http({
1882
2050
  headers: {
@@ -1932,23 +2100,27 @@ var __webpack_exports__ = {};
1932
2100
  toutiaoSingleCover
1933
2101
  ] : "multiple" === toutiaoCoverType ? toutiaoMultCover : [];
1934
2102
  const coverRes = await uploadImages(coverUrl);
1935
- const isSingleTitle = "single" === params.settingInfo.toutiaoTitleType;
1936
2103
  const location = params.settingInfo.toutiaoLocation;
1937
2104
  const topics = params.settingInfo.toutiaoTopic || [];
1938
- const multiTitleData = params.settingInfo.subTitles.map((title)=>({
1939
- id: "0",
1940
- visibility_level: 0,
1941
- source: "author",
1942
- old_source: "author",
1943
- text: title,
1944
- version: "author",
1945
- ai_title: ""
1946
- }));
1947
2105
  const topicContent = topics.map((topic)=>`<p><a class="tteditor-forum" data-name="${topic.word}" data-id="${topic.id}" data-concern-id="${topic.id}">#${topic.word}#</a ></p >`).join("");
2106
+ let sourceData = {
2107
+ source_type: toutiaoClaim ? toutiaoClaim.type : 5
2108
+ };
2109
+ if (toutiaoClaim && 1 === toutiaoClaim.type) {
2110
+ if (!toutiaoClaim?.source_author_uid) return {
2111
+ code: 500,
2112
+ message: "请填写作者ID",
2113
+ data: ""
2114
+ };
2115
+ sourceData = {
2116
+ ...sourceData,
2117
+ source_author_uid: toutiaoClaim.source_author_uid,
2118
+ time_format: toutiaoClaim.time_format,
2119
+ position: toutiaoClaim.position
2120
+ };
2121
+ }
1948
2122
  const extraData = {
1949
2123
  content_word_cnt: params.settingInfo.cntWord,
1950
- is_multi_title: isSingleTitle ? 0 : 1,
1951
- sub_titles: isSingleTitle ? [] : multiTitleData,
1952
2124
  gd_ext: {
1953
2125
  entrance: "",
1954
2126
  from_page: "publisher_mp",
@@ -1957,12 +2129,7 @@ var __webpack_exports__ = {};
1957
2129
  is_message: 0
1958
2130
  },
1959
2131
  tuwen_wtt_trans_flag: "0",
1960
- info_source: {
1961
- source_type: 5,
1962
- source_link: "",
1963
- time_format: "",
1964
- position: {}
1965
- },
2132
+ info_source: sourceData,
1966
2133
  ...location ? {
1967
2134
  city: location.label,
1968
2135
  city_code: location.value
@@ -2009,20 +2176,19 @@ var __webpack_exports__ = {};
2009
2176
  }
2010
2177
  }))),
2011
2178
  article_ad_type: getAddTypeValue(params.settingInfo.toutiaoAd),
2012
- claim_origin: toutiaoOriginal.includes("original") ? 1 : 0,
2013
- claim_exclusive: toutiaoOriginal.includes("exclusive") ? 1 : 0
2179
+ claim_exclusive: toutiaoExclusive ? toutiaoExclusive : toutiaoOriginal.includes("exclusive") ? 1 : 0
2014
2180
  };
2015
2181
  const msToken = params.cookies.find((it)=>"msToken" === it.name)?.value;
2016
2182
  let publishOption = {};
2017
2183
  if (msToken) {
2018
- const postHeaders = generatorFormData({
2184
+ const postHeaders = mock_generatorFormData({
2019
2185
  source: "mp",
2020
2186
  type: "article",
2021
2187
  aid: 1231,
2022
2188
  mp_publish_ab_val: 0,
2023
2189
  msToken: msToken
2024
2190
  });
2025
- const postData = generatorFormData(publishData);
2191
+ const postData = mock_generatorFormData(publishData);
2026
2192
  let a_bogus = GenAB(postHeaders, postData);
2027
2193
  publishOption = {
2028
2194
  method: "post",
@@ -2046,6 +2212,7 @@ var __webpack_exports__ = {};
2046
2212
  const publishResult = await http.api(publishOption);
2047
2213
  return (0, share_namespaceObject.success)(publishResult.data.pgc_id);
2048
2214
  };
2215
+ const rpa_GenAB = __webpack_require__("./src/utils/ttABEncrypt.js");
2049
2216
  const rpa_rpaAction = async (task, params)=>{
2050
2217
  const tmpCachePath = task.getTmpPath();
2051
2218
  const commonCookies = {
@@ -2080,9 +2247,30 @@ var __webpack_exports__ = {};
2080
2247
  await page.route('**', async (route, request)=>{
2081
2248
  const url = new URL(request.url());
2082
2249
  if (interceptUrls.some((pattern)=>url.pathname.includes(pattern))) {
2083
- url.searchParams.set('aid', '1');
2250
+ const headers = {
2251
+ ...request.headers(),
2252
+ "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"
2253
+ };
2254
+ const generatorFormData = (data)=>Object.entries(data).map(([key, value])=>{
2255
+ const encodedKey = encodeURIComponent(key);
2256
+ const encodedValue = encodeURIComponent(String(value));
2257
+ return `${encodedKey}=${encodedValue}`;
2258
+ }).join('&');
2259
+ const postHeaders = generatorFormData({
2260
+ source: "mp",
2261
+ type: "article",
2262
+ aid: 1231,
2263
+ mp_publish_ab_val: 0,
2264
+ msToken: url.searchParams.get('msToken')
2265
+ });
2266
+ const postData = request.postData() || "";
2267
+ let a_bogus = rpa_GenAB(postHeaders, postData);
2268
+ url.searchParams.set('aid', "1231");
2269
+ url.searchParams.set('mp_publish_ab_val', "0");
2270
+ url.searchParams.set('a_bogus', a_bogus);
2084
2271
  await route.continue({
2085
- url: url.toString()
2272
+ url: url.toString(),
2273
+ headers: headers
2086
2274
  });
2087
2275
  } else await route.continue();
2088
2276
  });
@@ -2157,13 +2345,40 @@ var __webpack_exports__ = {};
2157
2345
  }).locator("xpath=..");
2158
2346
  const isAdOptionVisible = await adContainer.isVisible();
2159
2347
  if (isAdOptionVisible) await adContainer.locator(`label.byte-radio:has(input[value="${getAddTypeValue(params.settingInfo.toutiaoAd)}"])`).click();
2160
- if (params.settingInfo.toutiaoOriginal.includes("exclusive")) {
2161
- const exclusiveContainer = page.locator(".form-container .edit-cell .edit-label").filter({
2162
- hasText: "声明首发"
2163
- }).locator("xpath=..");
2164
- exclusiveContainer.locator(".exclusive .exclusive-checkbox-wraper .byte-checkbox").click();
2348
+ const exclusiveContainer = page.locator(".form-container .edit-cell .edit-label").filter({
2349
+ hasText: "声明首发"
2350
+ }).locator("xpath=..");
2351
+ if (params.settingInfo.toutiaoOriginal.includes("exclusive") || params.settingInfo.toutiaoExclusive) exclusiveContainer.locator(".exclusive .exclusive-checkbox-wraper .byte-checkbox").check();
2352
+ else exclusiveContainer.locator(".exclusive .exclusive-checkbox-wraper .byte-checkbox").uncheck();
2353
+ let claim = params.settingInfo.toutiaoClaim ? params.settingInfo.toutiaoClaim.type : 5;
2354
+ switch(claim){
2355
+ case 3:
2356
+ await page.locator(".source-wrap .byte-checkbox", {
2357
+ hasText: "引用AI"
2358
+ }).locator(".byte-checkbox-mask").check();
2359
+ break;
2360
+ case 4:
2361
+ await page.locator(".source-wrap .byte-checkbox", {
2362
+ hasText: "取材网络"
2363
+ }).locator(".byte-checkbox-mask").check();
2364
+ break;
2365
+ case 5:
2366
+ await page.locator(".source-wrap .byte-checkbox", {
2367
+ hasText: "个人观点,仅供参考"
2368
+ }).locator(".byte-checkbox-mask").check();
2369
+ break;
2370
+ case 6:
2371
+ await page.locator(".source-wrap .byte-checkbox", {
2372
+ hasText: "虚构演绎,故事经历"
2373
+ }).locator(".byte-checkbox-mask").check();
2374
+ break;
2375
+ default:
2376
+ await page.locator(".source-wrap .byte-checkbox", {
2377
+ hasText: "个人观点,仅供参考"
2378
+ }).locator(".byte-checkbox-mask").check();
2379
+ break;
2165
2380
  }
2166
- const articleId = await new Promise((resolve)=>{
2381
+ const articleId = await new Promise(async (resolve)=>{
2167
2382
  const handleResponse = async (response)=>{
2168
2383
  const url = response.url();
2169
2384
  if (url.includes("/mp/agw/article/publish")) {
@@ -2173,7 +2388,32 @@ var __webpack_exports__ = {};
2173
2388
  }
2174
2389
  };
2175
2390
  page.on("response", handleResponse);
2176
- page.locator(".publish-footer button").filter({
2391
+ if (params.settingInfo.timer && "publish" == params.saveType) {
2392
+ await page.locator(".publish-footer button").filter({
2393
+ hasText: "定时发布"
2394
+ }).click();
2395
+ await page.waitForSelector('button.publish-btn:not(.byte-btn-loading) >> nth=1', {
2396
+ state: 'attached'
2397
+ });
2398
+ await page.locator(".byte-modal-content .day-select .byte-select-view-value").click();
2399
+ await page.locator('li.byte-select-option', {
2400
+ hasText: TimeFormatter.format(params.settingInfo.timer, "MM月dd日")
2401
+ }).click();
2402
+ await page.waitForTimeout(200);
2403
+ await page.locator(".byte-modal-content .hour-select .byte-select-view-value").click();
2404
+ await page.locator('li.byte-select-option', {
2405
+ hasText: TimeFormatter.format(params.settingInfo.timer, "h")
2406
+ }).click();
2407
+ await page.waitForTimeout(200);
2408
+ await page.locator(".byte-modal-content .minute-select .byte-select-view-value").click();
2409
+ await page.locator('li.byte-select-option', {
2410
+ hasText: TimeFormatter.format(params.settingInfo.timer, "m")
2411
+ }).click();
2412
+ await page.waitForTimeout(200);
2413
+ await page.locator(".byte-modal-footer button").filter({
2414
+ hasText: "预览并定时发布"
2415
+ }).click();
2416
+ } else await page.locator(".publish-footer button").filter({
2177
2417
  hasText: "预览并发布"
2178
2418
  }).click();
2179
2419
  });
@@ -2184,17 +2424,17 @@ var __webpack_exports__ = {};
2184
2424
  }
2185
2425
  if ("publish" === params.saveType) {
2186
2426
  await page.locator(".publish-footer button").filter({
2187
- hasText: "确认发布"
2427
+ hasText: params.settingInfo.timer ? "定时发布" : "确认发布"
2188
2428
  }).waitFor({
2189
2429
  state: "visible"
2190
2430
  });
2191
2431
  await page.waitForTimeout(200);
2192
2432
  await page.locator(".publish-footer button").filter({
2193
- hasText: "确认发布"
2433
+ hasText: params.settingInfo.timer ? "定时发布" : "确认发布"
2194
2434
  }).click();
2195
2435
  }
2196
2436
  await page.close();
2197
- return (0, share_namespaceObject.success)(articleId);
2437
+ return (0, share_namespaceObject.success)(articleId, "publish" === params.saveType ? "发布成功" : "保存草稿成功");
2198
2438
  };
2199
2439
  const COVER_TYPE = {
2200
2440
  no: 1,
@@ -2465,7 +2705,8 @@ var __webpack_exports__ = {};
2465
2705
  "-4": "不支持发布审核中或转码中的视频",
2466
2706
  "-2": "不支持发布审核中或转码中的视频",
2467
2707
  770001: "不支持发布审核中或转码中的视频",
2468
- 200074: "系统繁忙,请稍后重试!"
2708
+ 200074: "系统繁忙,请稍后重试!",
2709
+ 64702: "标题超出64字长度限制,请修改标题后重试。"
2469
2710
  };
2470
2711
  const ignoreErrno = [
2471
2712
  154019
@@ -2475,7 +2716,7 @@ var __webpack_exports__ = {};
2475
2716
  已关注的用户: 2,
2476
2717
  已关注7天及以上的用户: 3
2477
2718
  };
2478
- const mock_generatorFormData = (data)=>{
2719
+ const weixinPublish_mock_generatorFormData = (data)=>{
2479
2720
  const formData = new URLSearchParams();
2480
2721
  for (const [key, value] of Object.entries(data))formData.append(key, String(value));
2481
2722
  return formData.toString();
@@ -2491,7 +2732,7 @@ var __webpack_exports__ = {};
2491
2732
  token: params.token,
2492
2733
  lang: "zh_CN"
2493
2734
  },
2494
- data: mock_generatorFormData(data)
2735
+ data: weixinPublish_mock_generatorFormData(data)
2495
2736
  });
2496
2737
  } catch (error) {
2497
2738
  resData = error?.data;
@@ -2605,7 +2846,7 @@ var __webpack_exports__ = {};
2605
2846
  params: {
2606
2847
  action: "searchacct"
2607
2848
  },
2608
- data: mock_generatorFormData({
2849
+ data: weixinPublish_mock_generatorFormData({
2609
2850
  lang: "zh_CN",
2610
2851
  f: "json",
2611
2852
  ajax: 1,
@@ -2734,7 +2975,7 @@ var __webpack_exports__ = {};
2734
2975
  params: {
2735
2976
  action: 'addautoreply'
2736
2977
  },
2737
- data: mock_generatorFormData({
2978
+ data: weixinPublish_mock_generatorFormData({
2738
2979
  type: 1,
2739
2980
  fingerprint,
2740
2981
  token: params.token,
@@ -2856,7 +3097,7 @@ var __webpack_exports__ = {};
2856
3097
  type: 77,
2857
3098
  lang: "zh_CN"
2858
3099
  },
2859
- data: mock_generatorFormData(draftData),
3100
+ data: weixinPublish_mock_generatorFormData(draftData),
2860
3101
  defaultErrorMsg: "创建草稿失败,请稍后重试发布。"
2861
3102
  });
2862
3103
  if ("draft" === params.saveType) return {
@@ -2889,7 +3130,7 @@ var __webpack_exports__ = {};
2889
3130
  lang: "zh_CN",
2890
3131
  token: params.token
2891
3132
  },
2892
- data: mock_generatorFormData({
3133
+ data: weixinPublish_mock_generatorFormData({
2893
3134
  token: params.token,
2894
3135
  lang: "zh_CN",
2895
3136
  f: "json",
@@ -2920,7 +3161,7 @@ var __webpack_exports__ = {};
2920
3161
  token: params.token,
2921
3162
  lang: "zh_CN"
2922
3163
  },
2923
- data: mock_generatorFormData({
3164
+ data: weixinPublish_mock_generatorFormData({
2924
3165
  appmsgid: appMsgId,
2925
3166
  fingerprint,
2926
3167
  token: params.token,
@@ -2932,7 +3173,7 @@ var __webpack_exports__ = {};
2932
3173
  await http.api({
2933
3174
  method: "post",
2934
3175
  url: "https://mp.weixin.qq.com/cgi-bin/masssend?action=check_same_material",
2935
- data: mock_generatorFormData({
3176
+ data: weixinPublish_mock_generatorFormData({
2936
3177
  msgid: appMsgId,
2937
3178
  fingerprint,
2938
3179
  token: params.token,
@@ -2971,7 +3212,7 @@ var __webpack_exports__ = {};
2971
3212
  token: params.token,
2972
3213
  lang: "zh_CN"
2973
3214
  },
2974
- data: mock_generatorFormData({
3215
+ data: weixinPublish_mock_generatorFormData({
2975
3216
  appmsg_id: appMsgId,
2976
3217
  fingerprint,
2977
3218
  token: params.token,
@@ -2979,7 +3220,7 @@ var __webpack_exports__ = {};
2979
3220
  f: "json",
2980
3221
  ajax: 1,
2981
3222
  is_release_publish_page: params.masssend ? 0 : 1,
2982
- send_time: 0,
3223
+ send_time: params.settingInfo.timer ? params.settingInfo.timer : 0,
2983
3224
  random: Math.random().toString()
2984
3225
  })
2985
3226
  });
@@ -2990,7 +3231,7 @@ var __webpack_exports__ = {};
2990
3231
  params: {
2991
3232
  action: "check_music"
2992
3233
  },
2993
- data: mock_generatorFormData({
3234
+ data: weixinPublish_mock_generatorFormData({
2994
3235
  appmsgid: appMsgId,
2995
3236
  masssend_check: 1,
2996
3237
  fingerprint,
@@ -3010,7 +3251,7 @@ var __webpack_exports__ = {};
3010
3251
  lang: "zh_CN",
3011
3252
  1: 1
3012
3253
  },
3013
- data: mock_generatorFormData({
3254
+ data: weixinPublish_mock_generatorFormData({
3014
3255
  token: params.token,
3015
3256
  lang: "zh_CN",
3016
3257
  f: "json",
@@ -3030,7 +3271,7 @@ var __webpack_exports__ = {};
3030
3271
  lang: "zh_CN",
3031
3272
  1: 1
3032
3273
  },
3033
- data: mock_generatorFormData({
3274
+ data: weixinPublish_mock_generatorFormData({
3034
3275
  token: params.token,
3035
3276
  lang: "zh_CN",
3036
3277
  f: "json",
@@ -3062,6 +3303,7 @@ var __webpack_exports__ = {};
3062
3303
  ticket: getTicketResult.ticket,
3063
3304
  uuid,
3064
3305
  msgid: operation_seq,
3306
+ open_email: !!params.settingInfo.timer,
3065
3307
  ...params.masssend ? {} : {
3066
3308
  publish_type: 1
3067
3309
  }
@@ -3084,7 +3326,7 @@ var __webpack_exports__ = {};
3084
3326
  lang: "zh_CN",
3085
3327
  timespam: Date.now()
3086
3328
  },
3087
- data: mock_generatorFormData({
3329
+ data: weixinPublish_mock_generatorFormData({
3088
3330
  token: params.token,
3089
3331
  lang: "zh_CN",
3090
3332
  f: "json",
@@ -3114,7 +3356,7 @@ var __webpack_exports__ = {};
3114
3356
  lang: "zh_CN",
3115
3357
  1: 1
3116
3358
  },
3117
- data: mock_generatorFormData({
3359
+ data: weixinPublish_mock_generatorFormData({
3118
3360
  token: params.token,
3119
3361
  lang: "zh_CN",
3120
3362
  f: "json",
@@ -3132,11 +3374,14 @@ var __webpack_exports__ = {};
3132
3374
  t: "ajax-response",
3133
3375
  token: params.token,
3134
3376
  lang: "zh_CN",
3377
+ ...params.settingInfo.timer ? {
3378
+ action: "time_send"
3379
+ } : {},
3135
3380
  ...params.masssend ? {} : {
3136
3381
  is_release_publish_page: 1
3137
3382
  }
3138
3383
  },
3139
- data: mock_generatorFormData({
3384
+ data: weixinPublish_mock_generatorFormData({
3140
3385
  token: params.token,
3141
3386
  lang: "zh_CN",
3142
3387
  f: "json",
@@ -3153,7 +3398,7 @@ var __webpack_exports__ = {};
3153
3398
  country: "",
3154
3399
  province: "",
3155
3400
  city: "",
3156
- send_time: "0",
3401
+ send_time: params.settingInfo.timer ? params.settingInfo.timer : "0",
3157
3402
  type: "10",
3158
3403
  share_page: "1",
3159
3404
  synctxweibo: "0",
@@ -3170,7 +3415,7 @@ var __webpack_exports__ = {};
3170
3415
  }),
3171
3416
  defaultErrorMsg: params.masssend ? "文章群发异常,请尝试关闭群发或稍后重试。" : "文章发布异常,请稍后重试。"
3172
3417
  });
3173
- return (0, share_namespaceObject.success)(appMsgId, "微信公众号发布完成。");
3418
+ return (0, share_namespaceObject.success)(appMsgId, params.settingInfo.timer ? "微信公众号文章定时发布成功。" : "微信公众号发布完成。");
3174
3419
  };
3175
3420
  const waitQrcodeResultMaxTime = 2000 * scanRetryMaxCount;
3176
3421
  const weixinPublish_rpa_rpaAction = async (task, params)=>{
@@ -3291,6 +3536,10 @@ var __webpack_exports__ = {};
3291
3536
  checkInterval: 1000,
3292
3537
  stopAfterClick: false
3293
3538
  });
3539
+ PopupListener(page, '[extclass="weui-desktop-dialog_simple"] .weui-desktop-dialog', "小店", '[extclass="weui-desktop-dialog_simple"] .weui-desktop-icon-btn.weui-desktop-dialog__close-btn', {
3540
+ checkInterval: 1000,
3541
+ stopAfterClick: true
3542
+ });
3294
3543
  const titleInstance = page.locator("#js_title_main textarea#title");
3295
3544
  await titleInstance.click();
3296
3545
  await titleInstance.fill(params.title);
@@ -3447,8 +3696,8 @@ var __webpack_exports__ = {};
3447
3696
  const wxInteraction_bd = wxInteraction_setting.locator('.weui-desktop-dialog__bd');
3448
3697
  const wxInteraction_ft = wxInteraction_setting.locator('.weui-desktop-dialog__ft');
3449
3698
  if ("public" == params.settingInfo.wxInteraction.Type) {
3450
- await wxInteraction_bd.locator('.weui-desktop-form__check-label', {
3451
- hasText: '留言'
3699
+ await wxInteraction_bd.locator('.weui-desktop-form__check-label span', {
3700
+ hasText: /^(开启|留言)$/
3452
3701
  }).click();
3453
3702
  const comment_area = wxInteraction_bd.locator('.comment-options-block.pt0');
3454
3703
  const reply_area = wxInteraction_bd.locator('.comment-options-block.bb0.pb0');
@@ -3466,8 +3715,8 @@ var __webpack_exports__ = {};
3466
3715
  }).click();
3467
3716
  if (params.settingInfo.wxInteraction.Option?.elect_reply) await reply_area.locator('.weui-desktop-switch__box').check();
3468
3717
  else await reply_area.locator('.weui-desktop-switch__input').isChecked() && reply_area.locator('.weui-desktop-switch__box').uncheck();
3469
- } else if ("private" == params.settingInfo.wxInteraction.Type) await wxInteraction_bd.locator('.weui-desktop-form__check-label', {
3470
- hasText: '快捷私信'
3718
+ } else if ("private" == params.settingInfo.wxInteraction.Type) await wxInteraction_bd.locator('.weui-desktop-form__check-label span', {
3719
+ hasText: /^(快捷私信|不开启)$/
3471
3720
  }).click();
3472
3721
  await wxInteraction_ft.locator('.weui-desktop-btn.weui-desktop-btn_primary').click();
3473
3722
  }
@@ -3493,7 +3742,7 @@ var __webpack_exports__ = {};
3493
3742
  await poperInstance.locator('.frm_radio_item label[for="not_recomment_0"]').click();
3494
3743
  }
3495
3744
  await page.waitForTimeout(1000);
3496
- const articleId = await new Promise((resolve)=>{
3745
+ const articleId = await new Promise(async (resolve)=>{
3497
3746
  const handleResponse = async (response)=>{
3498
3747
  const url = response.url();
3499
3748
  const query = parseUrlQueryString(url);
@@ -3505,7 +3754,34 @@ var __webpack_exports__ = {};
3505
3754
  };
3506
3755
  page.on("response", handleResponse);
3507
3756
  page.locator("#editor_pannel #bottom_main #js_button_area #js_send button").click();
3757
+ await page.waitForTimeout(200);
3758
+ if (params.settingInfo.timer) {
3759
+ await page.locator(".mass-send .mass-send__td-setting", {
3760
+ hasText: "定时发表"
3761
+ }).locator(".weui-desktop-switch__box").check();
3762
+ let dateD = Number(TimeFormatter.format(params.settingInfo.timer, "d"));
3763
+ let nowD = Number(TimeFormatter.format(Date.now(), "d"));
3764
+ await page.locator(".mass-send__timer .weui-desktop-form__dropdown__dt").click();
3765
+ const dropMenu = page.locator(".mass-send__timer .weui-desktop-dropdown-menu").locator(".weui-desktop-dropdown__list-ele");
3766
+ await dropMenu.filter({
3767
+ hasText: dateD == nowD ? "今天" : dateD == nowD + 1 ? "明天" : TimeFormatter.format(params.settingInfo.timer, "M月d日")
3768
+ }).click();
3769
+ const timeDropMenu = page.locator(".mass-send__timer .weui-desktop-picker__time:visible");
3770
+ await timeDropMenu.locator(".weui-desktop-form__input").fill(TimeFormatter.format(params.settingInfo.timer, "hh:mm"));
3771
+ await timeDropMenu.locator("i.weui-desktop-icon__time").click();
3772
+ }
3508
3773
  });
3774
+ await page.waitForTimeout(200);
3775
+ if (params.masssend) {
3776
+ const times = Number(await page.locator(".mass-send .multi-sent__notice_time").locator('div[style="display: none;"] div:not([style*="display: none"]) span').textContent());
3777
+ if (0 == times) return {
3778
+ code: 200,
3779
+ message: "今日群发次数用尽,请明天再试。",
3780
+ data: ""
3781
+ };
3782
+ await page.locator(".mass-send .mass_send__notify").locator(".weui-desktop-switch__box").check();
3783
+ } else await page.locator(".mass-send .mass_send__notify").locator(".weui-desktop-switch__box").uncheck();
3784
+ await page.waitForTimeout(200);
3509
3785
  await page.waitForSelector('.new_mass_send_dialog .weui-desktop-dialog__wrp:not([style*="display: none"])', {
3510
3786
  state: "visible"
3511
3787
  });
@@ -3514,6 +3790,19 @@ var __webpack_exports__ = {};
3514
3790
  state: "visible"
3515
3791
  });
3516
3792
  await page.locator(".double_check_dialog .weui-desktop-dialog .weui-desktop-dialog__ft button.weui-desktop-btn_primary").click();
3793
+ await page.waitForTimeout(2000);
3794
+ const originalCheckDialog = page.locator('div[data-transfer="true"][width\\.number="800"][height\\.number="800"] .weui-desktop-dialog__title');
3795
+ if (await originalCheckDialog.count() > 0) {
3796
+ if (await originalCheckDialog.textContent() === "原创校验") {
3797
+ const popMassend = page.locator('div[data-transfer="true"][width\\.number="800"][height\\.number="800"]');
3798
+ await popMassend.locator(".weui-desktop-btn_primary", {
3799
+ hasText: "下一步"
3800
+ }).click();
3801
+ await popMassend.locator(".weui-desktop-btn_primary", {
3802
+ hasText: "继续"
3803
+ }).click();
3804
+ }
3805
+ }
3517
3806
  try {
3518
3807
  const startTime = Date.now();
3519
3808
  await new Promise(async (resolve, reject)=>{
@@ -4240,7 +4529,7 @@ var __webpack_exports__ = {};
4240
4529
  if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
4241
4530
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
4242
4531
  };
4243
- var package_namespaceObject = JSON.parse('{"i8":"1.2.11-beta.0"}');
4532
+ var package_namespaceObject = JSON.parse('{"i8":"1.2.11-beta.2"}');
4244
4533
  class Action {
4245
4534
  constructor(task){
4246
4535
  this.task = task;
@@ -4276,9 +4565,18 @@ var __webpack_exports__ = {};
4276
4565
  BjhFansExport(params) {
4277
4566
  return this.bindTask(BjhFansExport, params);
4278
4567
  }
4568
+ searchToutiaoUserID(params) {
4569
+ return this.bindTask(searchToutiaoUserInfo, params);
4570
+ }
4571
+ searchToutiaoLocation(params) {
4572
+ return this.bindTask(searchToutiaoLocation, params);
4573
+ }
4279
4574
  getToutiaoConfig(params) {
4280
4575
  return this.bindTask(getToutiaoConfig, params);
4281
4576
  }
4577
+ getBaijiahaoConfig(params) {
4578
+ return this.bindTask(getBaijiahaoConfig, params);
4579
+ }
4282
4580
  baijiahaoPublish(params) {
4283
4581
  return this.bindTask(baijiahaoPublish, params);
4284
4582
  }