@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/bundle.js CHANGED
@@ -14075,9 +14075,14 @@ var __webpack_exports__ = {};
14075
14075
  dd: String(date.getDate()).padStart(2, '0'),
14076
14076
  hh: String(date.getHours()).padStart(2, '0'),
14077
14077
  mm: String(date.getMinutes()).padStart(2, '0'),
14078
- ss: String(date.getSeconds()).padStart(2, '0')
14078
+ ss: String(date.getSeconds()).padStart(2, '0'),
14079
+ M: String(date.getMonth() + 1),
14080
+ d: String(date.getDate()),
14081
+ h: String(date.getHours()),
14082
+ m: String(date.getMinutes()),
14083
+ s: String(date.getSeconds())
14079
14084
  };
14080
- return formatStr.replace(/yyyy|yy|MM|dd|hh|mm|ss/g, (key)=>map[key]);
14085
+ return formatStr.replace(/yyyy|yy|MM|dd|hh|mm|ss|M|d|h|m|s/g, (key)=>map[key]);
14081
14086
  }
14082
14087
  }
14083
14088
  const replaceImgSrc = (html, callback)=>{
@@ -14393,13 +14398,15 @@ var __webpack_exports__ = {};
14393
14398
  is_checked: 1
14394
14399
  }
14395
14400
  ] : [],
14396
- ...isAi ? [
14397
- {
14398
- id: "aigc_bjh_status",
14399
- is_checked: 1
14400
- }
14401
- ] : []
14401
+ ...params.settingInfo.baijiahaoPublishConf?.map((item)=>({
14402
+ id: item.confName,
14403
+ is_checked: item.isChecked ? 1 : 0
14404
+ })) || []
14402
14405
  ];
14406
+ if (isAi && !activity_list.some((item)=>'aigc_bjh_status' in item)) activity_list.push({
14407
+ id: 'aigc_bjh_status',
14408
+ is_checked: 1
14409
+ });
14403
14410
  const publishData = {
14404
14411
  title: params.settingInfo.baijiahaoTitle,
14405
14412
  content,
@@ -14415,8 +14422,10 @@ var __webpack_exports__ = {};
14415
14422
  usingImgFilter: "false",
14416
14423
  source: "upload",
14417
14424
  cover_source: "upload",
14425
+ event2news: params.settingInfo?.baijiahaoEvent2News ? 2 : 0,
14418
14426
  activity_list
14419
14427
  };
14428
+ params.settingInfo.timer && (publishData['timer_time'] = params.settingInfo.timer);
14420
14429
  const isDraft = "draft" === params.saveType;
14421
14430
  const saveUrl = isDraft ? "https://baijiahao.baidu.com/pcui/article/save?callback=bjhdraft" : "https://baijiahao.baidu.com/pcui/article/publish?callback=bjhpublish";
14422
14431
  const res = await http.api({
@@ -14521,12 +14530,17 @@ var __webpack_exports__ = {};
14521
14530
  await abstractFormItem.click();
14522
14531
  await abstractFormItem.fill(params.settingInfo.baijiahaoAbstract);
14523
14532
  const isAi = params.settingInfo.baijiahaoIsAi.includes("isAi");
14524
- if (isAi) {
14525
- const settingFormItem = page.locator(".bjh-edit-wrap-set .cheetah-form-item").nth(5);
14526
- await settingFormItem.locator("label.cheetah-checkbox-wrapper").filter({
14527
- hasText: "AI创作声明"
14528
- }).click();
14533
+ const settingFormItem = page.locator(".bjh-edit-wrap-set .cheetah-form-item").nth(5);
14534
+ if (isAi) await settingFormItem.locator("label.cheetah-checkbox-wrapper").filter({
14535
+ hasText: "AI创作声明"
14536
+ }).click();
14537
+ if (params.settingInfo.baijiahaoPublishConf) for (const item of params.settingInfo.baijiahaoPublishConf){
14538
+ const _settingFormItem = settingFormItem.locator("label.cheetah-checkbox-wrapper").locator(`span.${item.confName}`);
14539
+ if (await _settingFormItem.isChecked() !== item.isChecked) await _settingFormItem.click();
14540
+ await page.waitForTimeout(200);
14529
14541
  }
14542
+ const enent2NewsBtn = page.locator("input#event2news");
14543
+ if (await enent2NewsBtn.isVisible() && params.settingInfo.baijiahaoEvent2News) await enent2NewsBtn.click();
14530
14544
  if (params.settingInfo.baijiahaoActivity.length > 0 && params.settingInfo.baijiahaoSelectActivityCache.length > 0) {
14531
14545
  const activity = params.settingInfo.baijiahaoActivity.filter((it)=>params.settingInfo.baijiahaoSelectActivityCache.includes(it.id));
14532
14546
  if (activity.length > 0) {
@@ -14538,13 +14552,16 @@ var __webpack_exports__ = {};
14538
14552
  if (await findActivity.count() > 0) findActivity.first().locator("..").click();
14539
14553
  }
14540
14554
  }
14541
- const articleId = await new Promise((resolve)=>{
14555
+ const { articleId, message } = await new Promise(async (resolve)=>{
14542
14556
  const handleResponse = async (response)=>{
14543
14557
  const url = response.url();
14544
14558
  if (url.includes("/pcui/article/save") || url.includes("/pcui/article/publish")) {
14545
14559
  const jsonResponse = await response.json();
14546
14560
  page.off("response", handleResponse);
14547
- resolve(jsonResponse?.ret?.article_id);
14561
+ resolve({
14562
+ articleId: jsonResponse?.ret?.article_id,
14563
+ message: jsonResponse?.errmsg
14564
+ });
14548
14565
  }
14549
14566
  };
14550
14567
  page.on("response", handleResponse);
@@ -14552,12 +14569,75 @@ var __webpack_exports__ = {};
14552
14569
  if ("draft" === params.saveType) operatorContainer.locator(".op-btn-outter-content").filter({
14553
14570
  hasText: "存草稿"
14554
14571
  }).locator("button").click();
14555
- else operatorContainer.locator(".op-btn-outter-content").filter({
14556
- hasText: "发布"
14572
+ else if (params.settingInfo.timer) {
14573
+ await operatorContainer.locator(".op-btn-outter-content").filter({
14574
+ hasText: "定时发布"
14575
+ }).locator("button").click();
14576
+ await page.locator(".timepublish-wrap-select .select-wrap", {
14577
+ hasText: "日"
14578
+ }).click();
14579
+ await page.locator('#select-date_list + * .cheetah-select-item-option', {
14580
+ hasText: TimeFormatter.format(params.settingInfo.timer, "M月dd日")
14581
+ }).click();
14582
+ await page.waitForTimeout(200);
14583
+ await page.locator(".timepublish-wrap-select .select-wrap", {
14584
+ hasText: "点"
14585
+ }).click();
14586
+ await page.locator('#select-hour_list +div.rc-virtual-list').hover();
14587
+ const scrollHourInfo = await page.evaluate(()=>{
14588
+ const hourInner = document.querySelector('#select-hour_list + * .rc-virtual-list-holder-inner');
14589
+ const hourElementHeight = hourInner?.children[0].clientHeight || 36;
14590
+ const hourMapsElem = Array.from(document.querySelectorAll('#select-hour_list + * .cheetah-select-item-option .cheetah-select-item-option-content'));
14591
+ const hourMap = hourMapsElem.map((item)=>item.textContent?.trim());
14592
+ return {
14593
+ elementHeight: hourElementHeight,
14594
+ elementItem: hourMap
14595
+ };
14596
+ });
14597
+ const fistHourElem = scrollHourInfo.elementItem[0];
14598
+ let fistHourElemH = Number(fistHourElem?.split("点")[0]);
14599
+ const lastHourElem = scrollHourInfo.elementItem[scrollHourInfo.elementItem.length - 1];
14600
+ let lastHourElemH = Number(lastHourElem?.split("点")[0]);
14601
+ let targetTimeH = Number(TimeFormatter.format(params.settingInfo.timer, 'h'));
14602
+ await page.mouse.wheel(0, targetTimeH > lastHourElemH ? (targetTimeH - lastHourElemH) * scrollHourInfo.elementHeight : targetTimeH < fistHourElemH ? -(fistHourElemH - targetTimeH) * scrollHourInfo.elementHeight : 0);
14603
+ await page.locator("#select-hour_list + * .cheetah-select-item-option ", {
14604
+ hasText: targetTimeH + "点"
14605
+ }).click();
14606
+ await page.waitForTimeout(200);
14607
+ await page.locator(".timepublish-wrap-select .select-wrap", {
14608
+ hasText: "分"
14609
+ }).click();
14610
+ await page.locator('#select-minute_list +div.rc-virtual-list').hover();
14611
+ const scrollMinuteInfo = await page.evaluate(()=>{
14612
+ const hourInner = document.querySelector('#select-minute_list + * .rc-virtual-list-holder-inner');
14613
+ const hourElementHeight = hourInner?.children[0].clientHeight || 36;
14614
+ const hourMapsElem = Array.from(document.querySelectorAll('#select-minute_list + * .cheetah-select-item-option .cheetah-select-item-option-content'));
14615
+ const hourMap = hourMapsElem.map((item)=>item.textContent?.trim());
14616
+ return {
14617
+ elementHeight: hourElementHeight,
14618
+ elementItem: hourMap
14619
+ };
14620
+ });
14621
+ const fistMinuteElem = scrollMinuteInfo.elementItem[0];
14622
+ let fistMinuteElemH = Number(fistMinuteElem?.split("分")[0]);
14623
+ const lastMinuteElem = scrollMinuteInfo.elementItem[scrollMinuteInfo.elementItem.length - 1];
14624
+ let lastMinuteElemH = Number(lastMinuteElem?.split("分")[0]);
14625
+ let targetTimeM = Number(TimeFormatter.format(params.settingInfo.timer, 'm'));
14626
+ await page.mouse.wheel(0, targetTimeM > lastMinuteElemH ? (targetTimeM - lastMinuteElemH) * scrollMinuteInfo.elementHeight : targetTimeM < fistMinuteElemH ? -(fistMinuteElemH - targetTimeM) * scrollMinuteInfo.elementHeight : 0);
14627
+ await page.locator("#select-minute_list + * .cheetah-select-item-option ", {
14628
+ hasText: targetTimeM + "分"
14629
+ }).click();
14630
+ await page.waitForTimeout(200);
14631
+ await page.locator(".cheetah-modal-confirm-btns button").filter({
14632
+ hasText: "定时发布"
14633
+ }).click();
14634
+ } else operatorContainer.locator(".op-btn-outter-content").filter({
14635
+ hasText: /^发布/
14557
14636
  }).locator("button").click();
14558
14637
  });
14638
+ await page.waitForTimeout(200000);
14559
14639
  await page.close();
14560
- return success(articleId);
14640
+ return success(articleId, articleId ? "发布成功" : message);
14561
14641
  };
14562
14642
  const baijiahaoPublish = async (task, params)=>{
14563
14643
  if ("rpa" === params.actionType) return rpaAction(task, params);
@@ -14642,6 +14722,28 @@ var __webpack_exports__ = {};
14642
14722
  userRights
14643
14723
  });
14644
14724
  };
14725
+ const getBaijiahaoConfig = async (_task, params)=>{
14726
+ const cookies = params.cookies ?? [];
14727
+ const http = new Http({
14728
+ headers: {
14729
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
14730
+ token: params.token
14731
+ }
14732
+ });
14733
+ const res = await http.api({
14734
+ method: "get",
14735
+ url: "https://baijiahao.baidu.com/pcui/article/edit",
14736
+ params: {
14737
+ type: "news"
14738
+ }
14739
+ });
14740
+ return success(res?.data?.article.activity_list.map((_item)=>({
14741
+ id: _item.id,
14742
+ name: _item.name,
14743
+ detail: _item.detail,
14744
+ is_enable: _item.is_enable
14745
+ })) ?? [], "获取头条发布配置项成功");
14746
+ };
14645
14747
  const searchToutiaoTopicList = async (_task, params)=>{
14646
14748
  const http = new Http({
14647
14749
  headers: {
@@ -14664,6 +14766,72 @@ var __webpack_exports__ = {};
14664
14766
  return success([]);
14665
14767
  }
14666
14768
  };
14769
+ const searchToutiaoLocation = async (_task, params)=>{
14770
+ const http = new Http({
14771
+ headers: {
14772
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
14773
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish",
14774
+ biz: 1231
14775
+ }
14776
+ });
14777
+ try {
14778
+ const res = await http.api({
14779
+ method: "post",
14780
+ url: "https://mp.toutiao.com/poi/api/searchplace",
14781
+ data: {
14782
+ appid: 1231,
14783
+ device: 2,
14784
+ keywords: params.placeName,
14785
+ language: "zh-CN",
14786
+ location: "-1,-1",
14787
+ offset: 20,
14788
+ page: 1,
14789
+ region: "CN",
14790
+ scenario: "TIPS",
14791
+ timestamp: Math.floor(Date.now() / 1000)
14792
+ }
14793
+ });
14794
+ if (200 === res.code) return success(res.data.poi.map((item)=>({
14795
+ position: item.name,
14796
+ city: item.city,
14797
+ longitude: item.longitude,
14798
+ latitude: item.latitude,
14799
+ type_code: item.type_code,
14800
+ poi_id: item.id
14801
+ })));
14802
+ return success([]);
14803
+ } catch (error) {
14804
+ return success([]);
14805
+ }
14806
+ };
14807
+ const searchToutiaoUserInfo = async (_task, params)=>{
14808
+ const http = new Http({
14809
+ headers: {
14810
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
14811
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
14812
+ }
14813
+ });
14814
+ try {
14815
+ const res = await http.api({
14816
+ method: "get",
14817
+ url: "https://mp.toutiao.com/ugc/publish/post/v1/suggest/",
14818
+ params: {
14819
+ words: params.UserName,
14820
+ language: "zh",
14821
+ app_name: "toutiao_mp"
14822
+ }
14823
+ });
14824
+ if (0 === res.err_no) return success(res.data.suggest.map((item)=>({
14825
+ user_id: item.user.info.user_id,
14826
+ name: item.user.info.name,
14827
+ avatar_url: item.user.info.avatar_url,
14828
+ followers_count: item.user.relation_count.followers_count
14829
+ })), '搜索成功');
14830
+ return success([]);
14831
+ } catch (error) {
14832
+ return success([]);
14833
+ }
14834
+ };
14667
14835
  const searchXiaohongshuLocation = async (_task, params)=>{
14668
14836
  const http = new Http({
14669
14837
  headers: {
@@ -14738,7 +14906,7 @@ var __webpack_exports__ = {};
14738
14906
  2005: "账号无【申明原创】权限,请关闭申明后重试。",
14739
14907
  100004: "用户未登录或登陆已过期,请重新登陆后重试。"
14740
14908
  };
14741
- const generatorFormData = (data)=>Object.entries(data).map(([key, value])=>{
14909
+ const mock_generatorFormData = (data)=>Object.entries(data).map(([key, value])=>{
14742
14910
  const encodedKey = encodeURIComponent(key);
14743
14911
  const encodedValue = encodeURIComponent(String(value));
14744
14912
  return `${encodedKey}=${encodedValue}`;
@@ -14751,7 +14919,7 @@ var __webpack_exports__ = {};
14751
14919
  return error || ("draft" === saveType ? "文章同步异常,请稍后重试。" : "文章发布异常,请稍后重试。");
14752
14920
  };
14753
14921
  const mock_mockAction = async (task, params)=>{
14754
- const { toutiaoSingleCover, toutiaoMultCover, toutiaoCoverType, toutiaoOriginal } = params.settingInfo;
14922
+ const { toutiaoSingleCover, toutiaoMultCover, toutiaoCoverType, toutiaoOriginal, toutiaoExclusive, toutiaoClaim } = params.settingInfo;
14755
14923
  const tmpCachePath = task.getTmpPath();
14756
14924
  const http = new Http({
14757
14925
  headers: {
@@ -14807,23 +14975,27 @@ var __webpack_exports__ = {};
14807
14975
  toutiaoSingleCover
14808
14976
  ] : "multiple" === toutiaoCoverType ? toutiaoMultCover : [];
14809
14977
  const coverRes = await uploadImages(coverUrl);
14810
- const isSingleTitle = "single" === params.settingInfo.toutiaoTitleType;
14811
14978
  const location = params.settingInfo.toutiaoLocation;
14812
14979
  const topics = params.settingInfo.toutiaoTopic || [];
14813
- const multiTitleData = params.settingInfo.subTitles.map((title)=>({
14814
- id: "0",
14815
- visibility_level: 0,
14816
- source: "author",
14817
- old_source: "author",
14818
- text: title,
14819
- version: "author",
14820
- ai_title: ""
14821
- }));
14822
14980
  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("");
14981
+ let sourceData = {
14982
+ source_type: toutiaoClaim ? toutiaoClaim.type : 5
14983
+ };
14984
+ if (toutiaoClaim && 1 === toutiaoClaim.type) {
14985
+ if (!toutiaoClaim?.source_author_uid) return {
14986
+ code: 500,
14987
+ message: "请填写作者ID",
14988
+ data: ""
14989
+ };
14990
+ sourceData = {
14991
+ ...sourceData,
14992
+ source_author_uid: toutiaoClaim.source_author_uid,
14993
+ time_format: toutiaoClaim.time_format,
14994
+ position: toutiaoClaim.position
14995
+ };
14996
+ }
14823
14997
  const extraData = {
14824
14998
  content_word_cnt: params.settingInfo.cntWord,
14825
- is_multi_title: isSingleTitle ? 0 : 1,
14826
- sub_titles: isSingleTitle ? [] : multiTitleData,
14827
14999
  gd_ext: {
14828
15000
  entrance: "",
14829
15001
  from_page: "publisher_mp",
@@ -14832,12 +15004,7 @@ var __webpack_exports__ = {};
14832
15004
  is_message: 0
14833
15005
  },
14834
15006
  tuwen_wtt_trans_flag: "0",
14835
- info_source: {
14836
- source_type: 5,
14837
- source_link: "",
14838
- time_format: "",
14839
- position: {}
14840
- },
15007
+ info_source: sourceData,
14841
15008
  ...location ? {
14842
15009
  city: location.label,
14843
15010
  city_code: location.value
@@ -14884,20 +15051,19 @@ var __webpack_exports__ = {};
14884
15051
  }
14885
15052
  }))),
14886
15053
  article_ad_type: getAddTypeValue(params.settingInfo.toutiaoAd),
14887
- claim_origin: toutiaoOriginal.includes("original") ? 1 : 0,
14888
- claim_exclusive: toutiaoOriginal.includes("exclusive") ? 1 : 0
15054
+ claim_exclusive: toutiaoExclusive ? toutiaoExclusive : toutiaoOriginal.includes("exclusive") ? 1 : 0
14889
15055
  };
14890
15056
  const msToken = params.cookies.find((it)=>"msToken" === it.name)?.value;
14891
15057
  let publishOption = {};
14892
15058
  if (msToken) {
14893
- const postHeaders = generatorFormData({
15059
+ const postHeaders = mock_generatorFormData({
14894
15060
  source: "mp",
14895
15061
  type: "article",
14896
15062
  aid: 1231,
14897
15063
  mp_publish_ab_val: 0,
14898
15064
  msToken: msToken
14899
15065
  });
14900
- const postData = generatorFormData(publishData);
15066
+ const postData = mock_generatorFormData(publishData);
14901
15067
  let a_bogus = GenAB(postHeaders, postData);
14902
15068
  publishOption = {
14903
15069
  method: "post",
@@ -14921,6 +15087,7 @@ var __webpack_exports__ = {};
14921
15087
  const publishResult = await http.api(publishOption);
14922
15088
  return success(publishResult.data.pgc_id);
14923
15089
  };
15090
+ const rpa_GenAB = __webpack_require__("./src/utils/ttABEncrypt.js");
14924
15091
  const rpa_rpaAction = async (task, params)=>{
14925
15092
  const tmpCachePath = task.getTmpPath();
14926
15093
  const commonCookies = {
@@ -14955,9 +15122,30 @@ var __webpack_exports__ = {};
14955
15122
  await page.route('**', async (route, request)=>{
14956
15123
  const url = new URL(request.url());
14957
15124
  if (interceptUrls.some((pattern)=>url.pathname.includes(pattern))) {
14958
- url.searchParams.set('aid', '1');
15125
+ const headers = {
15126
+ ...request.headers(),
15127
+ "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"
15128
+ };
15129
+ const generatorFormData = (data)=>Object.entries(data).map(([key, value])=>{
15130
+ const encodedKey = encodeURIComponent(key);
15131
+ const encodedValue = encodeURIComponent(String(value));
15132
+ return `${encodedKey}=${encodedValue}`;
15133
+ }).join('&');
15134
+ const postHeaders = generatorFormData({
15135
+ source: "mp",
15136
+ type: "article",
15137
+ aid: 1231,
15138
+ mp_publish_ab_val: 0,
15139
+ msToken: url.searchParams.get('msToken')
15140
+ });
15141
+ const postData = request.postData() || "";
15142
+ let a_bogus = rpa_GenAB(postHeaders, postData);
15143
+ url.searchParams.set('aid', "1231");
15144
+ url.searchParams.set('mp_publish_ab_val', "0");
15145
+ url.searchParams.set('a_bogus', a_bogus);
14959
15146
  await route.continue({
14960
- url: url.toString()
15147
+ url: url.toString(),
15148
+ headers: headers
14961
15149
  });
14962
15150
  } else await route.continue();
14963
15151
  });
@@ -15032,13 +15220,40 @@ var __webpack_exports__ = {};
15032
15220
  }).locator("xpath=..");
15033
15221
  const isAdOptionVisible = await adContainer.isVisible();
15034
15222
  if (isAdOptionVisible) await adContainer.locator(`label.byte-radio:has(input[value="${getAddTypeValue(params.settingInfo.toutiaoAd)}"])`).click();
15035
- if (params.settingInfo.toutiaoOriginal.includes("exclusive")) {
15036
- const exclusiveContainer = page.locator(".form-container .edit-cell .edit-label").filter({
15037
- hasText: "声明首发"
15038
- }).locator("xpath=..");
15039
- exclusiveContainer.locator(".exclusive .exclusive-checkbox-wraper .byte-checkbox").click();
15223
+ const exclusiveContainer = page.locator(".form-container .edit-cell .edit-label").filter({
15224
+ hasText: "声明首发"
15225
+ }).locator("xpath=..");
15226
+ if (params.settingInfo.toutiaoOriginal.includes("exclusive") || params.settingInfo.toutiaoExclusive) exclusiveContainer.locator(".exclusive .exclusive-checkbox-wraper .byte-checkbox").check();
15227
+ else exclusiveContainer.locator(".exclusive .exclusive-checkbox-wraper .byte-checkbox").uncheck();
15228
+ let claim = params.settingInfo.toutiaoClaim ? params.settingInfo.toutiaoClaim.type : 5;
15229
+ switch(claim){
15230
+ case 3:
15231
+ await page.locator(".source-wrap .byte-checkbox", {
15232
+ hasText: "引用AI"
15233
+ }).locator(".byte-checkbox-mask").check();
15234
+ break;
15235
+ case 4:
15236
+ await page.locator(".source-wrap .byte-checkbox", {
15237
+ hasText: "取材网络"
15238
+ }).locator(".byte-checkbox-mask").check();
15239
+ break;
15240
+ case 5:
15241
+ await page.locator(".source-wrap .byte-checkbox", {
15242
+ hasText: "个人观点,仅供参考"
15243
+ }).locator(".byte-checkbox-mask").check();
15244
+ break;
15245
+ case 6:
15246
+ await page.locator(".source-wrap .byte-checkbox", {
15247
+ hasText: "虚构演绎,故事经历"
15248
+ }).locator(".byte-checkbox-mask").check();
15249
+ break;
15250
+ default:
15251
+ await page.locator(".source-wrap .byte-checkbox", {
15252
+ hasText: "个人观点,仅供参考"
15253
+ }).locator(".byte-checkbox-mask").check();
15254
+ break;
15040
15255
  }
15041
- const articleId = await new Promise((resolve)=>{
15256
+ const articleId = await new Promise(async (resolve)=>{
15042
15257
  const handleResponse = async (response)=>{
15043
15258
  const url = response.url();
15044
15259
  if (url.includes("/mp/agw/article/publish")) {
@@ -15048,7 +15263,32 @@ var __webpack_exports__ = {};
15048
15263
  }
15049
15264
  };
15050
15265
  page.on("response", handleResponse);
15051
- page.locator(".publish-footer button").filter({
15266
+ if (params.settingInfo.timer && "publish" == params.saveType) {
15267
+ await page.locator(".publish-footer button").filter({
15268
+ hasText: "定时发布"
15269
+ }).click();
15270
+ await page.waitForSelector('button.publish-btn:not(.byte-btn-loading) >> nth=1', {
15271
+ state: 'attached'
15272
+ });
15273
+ await page.locator(".byte-modal-content .day-select .byte-select-view-value").click();
15274
+ await page.locator('li.byte-select-option', {
15275
+ hasText: TimeFormatter.format(params.settingInfo.timer, "MM月dd日")
15276
+ }).click();
15277
+ await page.waitForTimeout(200);
15278
+ await page.locator(".byte-modal-content .hour-select .byte-select-view-value").click();
15279
+ await page.locator('li.byte-select-option', {
15280
+ hasText: TimeFormatter.format(params.settingInfo.timer, "h")
15281
+ }).click();
15282
+ await page.waitForTimeout(200);
15283
+ await page.locator(".byte-modal-content .minute-select .byte-select-view-value").click();
15284
+ await page.locator('li.byte-select-option', {
15285
+ hasText: TimeFormatter.format(params.settingInfo.timer, "m")
15286
+ }).click();
15287
+ await page.waitForTimeout(200);
15288
+ await page.locator(".byte-modal-footer button").filter({
15289
+ hasText: "预览并定时发布"
15290
+ }).click();
15291
+ } else await page.locator(".publish-footer button").filter({
15052
15292
  hasText: "预览并发布"
15053
15293
  }).click();
15054
15294
  });
@@ -15059,17 +15299,17 @@ var __webpack_exports__ = {};
15059
15299
  }
15060
15300
  if ("publish" === params.saveType) {
15061
15301
  await page.locator(".publish-footer button").filter({
15062
- hasText: "确认发布"
15302
+ hasText: params.settingInfo.timer ? "定时发布" : "确认发布"
15063
15303
  }).waitFor({
15064
15304
  state: "visible"
15065
15305
  });
15066
15306
  await page.waitForTimeout(200);
15067
15307
  await page.locator(".publish-footer button").filter({
15068
- hasText: "确认发布"
15308
+ hasText: params.settingInfo.timer ? "定时发布" : "确认发布"
15069
15309
  }).click();
15070
15310
  }
15071
15311
  await page.close();
15072
- return success(articleId);
15312
+ return success(articleId, "publish" === params.saveType ? "发布成功" : "保存草稿成功");
15073
15313
  };
15074
15314
  const COVER_TYPE = {
15075
15315
  no: 1,
@@ -15340,7 +15580,8 @@ var __webpack_exports__ = {};
15340
15580
  "-4": "不支持发布审核中或转码中的视频",
15341
15581
  "-2": "不支持发布审核中或转码中的视频",
15342
15582
  770001: "不支持发布审核中或转码中的视频",
15343
- 200074: "系统繁忙,请稍后重试!"
15583
+ 200074: "系统繁忙,请稍后重试!",
15584
+ 64702: "标题超出64字长度限制,请修改标题后重试。"
15344
15585
  };
15345
15586
  const ignoreErrno = [
15346
15587
  154019
@@ -15350,7 +15591,7 @@ var __webpack_exports__ = {};
15350
15591
  已关注的用户: 2,
15351
15592
  已关注7天及以上的用户: 3
15352
15593
  };
15353
- const mock_generatorFormData = (data)=>{
15594
+ const weixinPublish_mock_generatorFormData = (data)=>{
15354
15595
  const formData = new URLSearchParams();
15355
15596
  for (const [key, value] of Object.entries(data))formData.append(key, String(value));
15356
15597
  return formData.toString();
@@ -15366,7 +15607,7 @@ var __webpack_exports__ = {};
15366
15607
  token: params.token,
15367
15608
  lang: "zh_CN"
15368
15609
  },
15369
- data: mock_generatorFormData(data)
15610
+ data: weixinPublish_mock_generatorFormData(data)
15370
15611
  });
15371
15612
  } catch (error) {
15372
15613
  resData = error?.data;
@@ -15480,7 +15721,7 @@ var __webpack_exports__ = {};
15480
15721
  params: {
15481
15722
  action: "searchacct"
15482
15723
  },
15483
- data: mock_generatorFormData({
15724
+ data: weixinPublish_mock_generatorFormData({
15484
15725
  lang: "zh_CN",
15485
15726
  f: "json",
15486
15727
  ajax: 1,
@@ -15609,7 +15850,7 @@ var __webpack_exports__ = {};
15609
15850
  params: {
15610
15851
  action: 'addautoreply'
15611
15852
  },
15612
- data: mock_generatorFormData({
15853
+ data: weixinPublish_mock_generatorFormData({
15613
15854
  type: 1,
15614
15855
  fingerprint,
15615
15856
  token: params.token,
@@ -15731,7 +15972,7 @@ var __webpack_exports__ = {};
15731
15972
  type: 77,
15732
15973
  lang: "zh_CN"
15733
15974
  },
15734
- data: mock_generatorFormData(draftData),
15975
+ data: weixinPublish_mock_generatorFormData(draftData),
15735
15976
  defaultErrorMsg: "创建草稿失败,请稍后重试发布。"
15736
15977
  });
15737
15978
  if ("draft" === params.saveType) return {
@@ -15764,7 +16005,7 @@ var __webpack_exports__ = {};
15764
16005
  lang: "zh_CN",
15765
16006
  token: params.token
15766
16007
  },
15767
- data: mock_generatorFormData({
16008
+ data: weixinPublish_mock_generatorFormData({
15768
16009
  token: params.token,
15769
16010
  lang: "zh_CN",
15770
16011
  f: "json",
@@ -15795,7 +16036,7 @@ var __webpack_exports__ = {};
15795
16036
  token: params.token,
15796
16037
  lang: "zh_CN"
15797
16038
  },
15798
- data: mock_generatorFormData({
16039
+ data: weixinPublish_mock_generatorFormData({
15799
16040
  appmsgid: appMsgId,
15800
16041
  fingerprint,
15801
16042
  token: params.token,
@@ -15807,7 +16048,7 @@ var __webpack_exports__ = {};
15807
16048
  await http.api({
15808
16049
  method: "post",
15809
16050
  url: "https://mp.weixin.qq.com/cgi-bin/masssend?action=check_same_material",
15810
- data: mock_generatorFormData({
16051
+ data: weixinPublish_mock_generatorFormData({
15811
16052
  msgid: appMsgId,
15812
16053
  fingerprint,
15813
16054
  token: params.token,
@@ -15846,7 +16087,7 @@ var __webpack_exports__ = {};
15846
16087
  token: params.token,
15847
16088
  lang: "zh_CN"
15848
16089
  },
15849
- data: mock_generatorFormData({
16090
+ data: weixinPublish_mock_generatorFormData({
15850
16091
  appmsg_id: appMsgId,
15851
16092
  fingerprint,
15852
16093
  token: params.token,
@@ -15854,7 +16095,7 @@ var __webpack_exports__ = {};
15854
16095
  f: "json",
15855
16096
  ajax: 1,
15856
16097
  is_release_publish_page: params.masssend ? 0 : 1,
15857
- send_time: 0,
16098
+ send_time: params.settingInfo.timer ? params.settingInfo.timer : 0,
15858
16099
  random: Math.random().toString()
15859
16100
  })
15860
16101
  });
@@ -15865,7 +16106,7 @@ var __webpack_exports__ = {};
15865
16106
  params: {
15866
16107
  action: "check_music"
15867
16108
  },
15868
- data: mock_generatorFormData({
16109
+ data: weixinPublish_mock_generatorFormData({
15869
16110
  appmsgid: appMsgId,
15870
16111
  masssend_check: 1,
15871
16112
  fingerprint,
@@ -15885,7 +16126,7 @@ var __webpack_exports__ = {};
15885
16126
  lang: "zh_CN",
15886
16127
  1: 1
15887
16128
  },
15888
- data: mock_generatorFormData({
16129
+ data: weixinPublish_mock_generatorFormData({
15889
16130
  token: params.token,
15890
16131
  lang: "zh_CN",
15891
16132
  f: "json",
@@ -15905,7 +16146,7 @@ var __webpack_exports__ = {};
15905
16146
  lang: "zh_CN",
15906
16147
  1: 1
15907
16148
  },
15908
- data: mock_generatorFormData({
16149
+ data: weixinPublish_mock_generatorFormData({
15909
16150
  token: params.token,
15910
16151
  lang: "zh_CN",
15911
16152
  f: "json",
@@ -15937,6 +16178,7 @@ var __webpack_exports__ = {};
15937
16178
  ticket: getTicketResult.ticket,
15938
16179
  uuid,
15939
16180
  msgid: operation_seq,
16181
+ open_email: !!params.settingInfo.timer,
15940
16182
  ...params.masssend ? {} : {
15941
16183
  publish_type: 1
15942
16184
  }
@@ -15959,7 +16201,7 @@ var __webpack_exports__ = {};
15959
16201
  lang: "zh_CN",
15960
16202
  timespam: Date.now()
15961
16203
  },
15962
- data: mock_generatorFormData({
16204
+ data: weixinPublish_mock_generatorFormData({
15963
16205
  token: params.token,
15964
16206
  lang: "zh_CN",
15965
16207
  f: "json",
@@ -15989,7 +16231,7 @@ var __webpack_exports__ = {};
15989
16231
  lang: "zh_CN",
15990
16232
  1: 1
15991
16233
  },
15992
- data: mock_generatorFormData({
16234
+ data: weixinPublish_mock_generatorFormData({
15993
16235
  token: params.token,
15994
16236
  lang: "zh_CN",
15995
16237
  f: "json",
@@ -16007,11 +16249,14 @@ var __webpack_exports__ = {};
16007
16249
  t: "ajax-response",
16008
16250
  token: params.token,
16009
16251
  lang: "zh_CN",
16252
+ ...params.settingInfo.timer ? {
16253
+ action: "time_send"
16254
+ } : {},
16010
16255
  ...params.masssend ? {} : {
16011
16256
  is_release_publish_page: 1
16012
16257
  }
16013
16258
  },
16014
- data: mock_generatorFormData({
16259
+ data: weixinPublish_mock_generatorFormData({
16015
16260
  token: params.token,
16016
16261
  lang: "zh_CN",
16017
16262
  f: "json",
@@ -16028,7 +16273,7 @@ var __webpack_exports__ = {};
16028
16273
  country: "",
16029
16274
  province: "",
16030
16275
  city: "",
16031
- send_time: "0",
16276
+ send_time: params.settingInfo.timer ? params.settingInfo.timer : "0",
16032
16277
  type: "10",
16033
16278
  share_page: "1",
16034
16279
  synctxweibo: "0",
@@ -16045,7 +16290,7 @@ var __webpack_exports__ = {};
16045
16290
  }),
16046
16291
  defaultErrorMsg: params.masssend ? "文章群发异常,请尝试关闭群发或稍后重试。" : "文章发布异常,请稍后重试。"
16047
16292
  });
16048
- return success(appMsgId, "微信公众号发布完成。");
16293
+ return success(appMsgId, params.settingInfo.timer ? "微信公众号文章定时发布成功。" : "微信公众号发布完成。");
16049
16294
  };
16050
16295
  const waitQrcodeResultMaxTime = 2000 * scanRetryMaxCount;
16051
16296
  const weixinPublish_rpa_rpaAction = async (task, params)=>{
@@ -16166,6 +16411,10 @@ var __webpack_exports__ = {};
16166
16411
  checkInterval: 1000,
16167
16412
  stopAfterClick: false
16168
16413
  });
16414
+ PopupListener(page, '[extclass="weui-desktop-dialog_simple"] .weui-desktop-dialog', "小店", '[extclass="weui-desktop-dialog_simple"] .weui-desktop-icon-btn.weui-desktop-dialog__close-btn', {
16415
+ checkInterval: 1000,
16416
+ stopAfterClick: true
16417
+ });
16169
16418
  const titleInstance = page.locator("#js_title_main textarea#title");
16170
16419
  await titleInstance.click();
16171
16420
  await titleInstance.fill(params.title);
@@ -16322,8 +16571,8 @@ var __webpack_exports__ = {};
16322
16571
  const wxInteraction_bd = wxInteraction_setting.locator('.weui-desktop-dialog__bd');
16323
16572
  const wxInteraction_ft = wxInteraction_setting.locator('.weui-desktop-dialog__ft');
16324
16573
  if ("public" == params.settingInfo.wxInteraction.Type) {
16325
- await wxInteraction_bd.locator('.weui-desktop-form__check-label', {
16326
- hasText: '留言'
16574
+ await wxInteraction_bd.locator('.weui-desktop-form__check-label span', {
16575
+ hasText: /^(开启|留言)$/
16327
16576
  }).click();
16328
16577
  const comment_area = wxInteraction_bd.locator('.comment-options-block.pt0');
16329
16578
  const reply_area = wxInteraction_bd.locator('.comment-options-block.bb0.pb0');
@@ -16341,8 +16590,8 @@ var __webpack_exports__ = {};
16341
16590
  }).click();
16342
16591
  if (params.settingInfo.wxInteraction.Option?.elect_reply) await reply_area.locator('.weui-desktop-switch__box').check();
16343
16592
  else await reply_area.locator('.weui-desktop-switch__input').isChecked() && reply_area.locator('.weui-desktop-switch__box').uncheck();
16344
- } else if ("private" == params.settingInfo.wxInteraction.Type) await wxInteraction_bd.locator('.weui-desktop-form__check-label', {
16345
- hasText: '快捷私信'
16593
+ } else if ("private" == params.settingInfo.wxInteraction.Type) await wxInteraction_bd.locator('.weui-desktop-form__check-label span', {
16594
+ hasText: /^(快捷私信|不开启)$/
16346
16595
  }).click();
16347
16596
  await wxInteraction_ft.locator('.weui-desktop-btn.weui-desktop-btn_primary').click();
16348
16597
  }
@@ -16368,7 +16617,7 @@ var __webpack_exports__ = {};
16368
16617
  await poperInstance.locator('.frm_radio_item label[for="not_recomment_0"]').click();
16369
16618
  }
16370
16619
  await page.waitForTimeout(1000);
16371
- const articleId = await new Promise((resolve)=>{
16620
+ const articleId = await new Promise(async (resolve)=>{
16372
16621
  const handleResponse = async (response)=>{
16373
16622
  const url = response.url();
16374
16623
  const query = parseUrlQueryString(url);
@@ -16380,7 +16629,34 @@ var __webpack_exports__ = {};
16380
16629
  };
16381
16630
  page.on("response", handleResponse);
16382
16631
  page.locator("#editor_pannel #bottom_main #js_button_area #js_send button").click();
16632
+ await page.waitForTimeout(200);
16633
+ if (params.settingInfo.timer) {
16634
+ await page.locator(".mass-send .mass-send__td-setting", {
16635
+ hasText: "定时发表"
16636
+ }).locator(".weui-desktop-switch__box").check();
16637
+ let dateD = Number(TimeFormatter.format(params.settingInfo.timer, "d"));
16638
+ let nowD = Number(TimeFormatter.format(Date.now(), "d"));
16639
+ await page.locator(".mass-send__timer .weui-desktop-form__dropdown__dt").click();
16640
+ const dropMenu = page.locator(".mass-send__timer .weui-desktop-dropdown-menu").locator(".weui-desktop-dropdown__list-ele");
16641
+ await dropMenu.filter({
16642
+ hasText: dateD == nowD ? "今天" : dateD == nowD + 1 ? "明天" : TimeFormatter.format(params.settingInfo.timer, "M月d日")
16643
+ }).click();
16644
+ const timeDropMenu = page.locator(".mass-send__timer .weui-desktop-picker__time:visible");
16645
+ await timeDropMenu.locator(".weui-desktop-form__input").fill(TimeFormatter.format(params.settingInfo.timer, "hh:mm"));
16646
+ await timeDropMenu.locator("i.weui-desktop-icon__time").click();
16647
+ }
16383
16648
  });
16649
+ await page.waitForTimeout(200);
16650
+ if (params.masssend) {
16651
+ const times = Number(await page.locator(".mass-send .multi-sent__notice_time").locator('div[style="display: none;"] div:not([style*="display: none"]) span').textContent());
16652
+ if (0 == times) return {
16653
+ code: 200,
16654
+ message: "今日群发次数用尽,请明天再试。",
16655
+ data: ""
16656
+ };
16657
+ await page.locator(".mass-send .mass_send__notify").locator(".weui-desktop-switch__box").check();
16658
+ } else await page.locator(".mass-send .mass_send__notify").locator(".weui-desktop-switch__box").uncheck();
16659
+ await page.waitForTimeout(200);
16384
16660
  await page.waitForSelector('.new_mass_send_dialog .weui-desktop-dialog__wrp:not([style*="display: none"])', {
16385
16661
  state: "visible"
16386
16662
  });
@@ -16389,6 +16665,19 @@ var __webpack_exports__ = {};
16389
16665
  state: "visible"
16390
16666
  });
16391
16667
  await page.locator(".double_check_dialog .weui-desktop-dialog .weui-desktop-dialog__ft button.weui-desktop-btn_primary").click();
16668
+ await page.waitForTimeout(2000);
16669
+ const originalCheckDialog = page.locator('div[data-transfer="true"][width\\.number="800"][height\\.number="800"] .weui-desktop-dialog__title');
16670
+ if (await originalCheckDialog.count() > 0) {
16671
+ if (await originalCheckDialog.textContent() === "原创校验") {
16672
+ const popMassend = page.locator('div[data-transfer="true"][width\\.number="800"][height\\.number="800"]');
16673
+ await popMassend.locator(".weui-desktop-btn_primary", {
16674
+ hasText: "下一步"
16675
+ }).click();
16676
+ await popMassend.locator(".weui-desktop-btn_primary", {
16677
+ hasText: "继续"
16678
+ }).click();
16679
+ }
16680
+ }
16392
16681
  try {
16393
16682
  const startTime = Date.now();
16394
16683
  await new Promise(async (resolve, reject)=>{
@@ -17115,7 +17404,7 @@ var __webpack_exports__ = {};
17115
17404
  if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
17116
17405
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
17117
17406
  };
17118
- var package_namespaceObject = JSON.parse('{"i8":"1.2.11-beta.0"}');
17407
+ var package_namespaceObject = JSON.parse('{"i8":"1.2.11-beta.2"}');
17119
17408
  class Action {
17120
17409
  constructor(task){
17121
17410
  this.task = task;
@@ -17151,9 +17440,18 @@ var __webpack_exports__ = {};
17151
17440
  BjhFansExport(params) {
17152
17441
  return this.bindTask(BjhFansExport, params);
17153
17442
  }
17443
+ searchToutiaoUserID(params) {
17444
+ return this.bindTask(searchToutiaoUserInfo, params);
17445
+ }
17446
+ searchToutiaoLocation(params) {
17447
+ return this.bindTask(searchToutiaoLocation, params);
17448
+ }
17154
17449
  getToutiaoConfig(params) {
17155
17450
  return this.bindTask(getToutiaoConfig, params);
17156
17451
  }
17452
+ getBaijiahaoConfig(params) {
17453
+ return this.bindTask(getBaijiahaoConfig, params);
17454
+ }
17157
17455
  baijiahaoPublish(params) {
17158
17456
  return this.bindTask(baijiahaoPublish, params);
17159
17457
  }