@iflyrpa/actions 1.2.5 → 1.2.6-beta.1
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/actions/weixinPublish/index.d.ts +21 -1
- package/dist/actions/xiaohongshuPublish/index.d.ts +1 -0
- package/dist/bundle.js +537 -18
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +537 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +537 -18
- package/dist/index.mjs.map +1 -1
- package/dist/utils/index.d.ts +12 -0
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -13061,6 +13061,24 @@ var __webpack_exports__ = {};
|
|
|
13061
13061
|
}, html);
|
|
13062
13062
|
}
|
|
13063
13063
|
}
|
|
13064
|
+
function PopupListener(page, popupSelector, popKey, buttonSelector, options = {}) {
|
|
13065
|
+
const { checkInterval = 1000, stopAfterClick = false } = options;
|
|
13066
|
+
const popup = page.locator(popupSelector);
|
|
13067
|
+
const button = page.locator(buttonSelector);
|
|
13068
|
+
const intervalId = setInterval(async ()=>{
|
|
13069
|
+
try {
|
|
13070
|
+
if (await popup.count() > 0 && await popup.isVisible() && (await popup.textContent() || "").includes(popKey)) {
|
|
13071
|
+
await button.click({
|
|
13072
|
+
force: true
|
|
13073
|
+
});
|
|
13074
|
+
if (stopAfterClick) clearInterval(intervalId);
|
|
13075
|
+
}
|
|
13076
|
+
} catch (err) {}
|
|
13077
|
+
}, checkInterval);
|
|
13078
|
+
return ()=>{
|
|
13079
|
+
clearInterval(intervalId);
|
|
13080
|
+
};
|
|
13081
|
+
}
|
|
13064
13082
|
const parseUrlQueryString = (url)=>{
|
|
13065
13083
|
const queryStringObject = {};
|
|
13066
13084
|
if (!url || !url.includes("?")) return queryStringObject;
|
|
@@ -14036,13 +14054,28 @@ var __webpack_exports__ = {};
|
|
|
14036
14054
|
Normal: "kQuotaTypeMassSendNormal",
|
|
14037
14055
|
ProductActivity: "kQuotaTypeMassSendProductActivity"
|
|
14038
14056
|
};
|
|
14039
|
-
const GET_QRCODE_DEFAULT_ERROR = "
|
|
14057
|
+
const GET_QRCODE_DEFAULT_ERROR = "二维码获取异常,请稍后重试。";
|
|
14040
14058
|
const weixinPublish_mock_errnoMap = {
|
|
14041
|
-
200003: "微信公众号号登录状态失效,请重新绑定账号后重试。"
|
|
14059
|
+
200003: "微信公众号号登录状态失效,请重新绑定账号后重试。",
|
|
14060
|
+
420001: "封面图不支持GIF,请更换后重试。",
|
|
14061
|
+
200002: "上传图片参数错误,请检查后重试。",
|
|
14062
|
+
200039: "上传图片高度(像素)与宽度(像素)的乘积不能超过600万,请更换后重试。",
|
|
14063
|
+
153201: "不支持发布审核中或转码中的视频",
|
|
14064
|
+
200007: "登陆失败,请重新登陆账户后重试。",
|
|
14065
|
+
64703: "摘要超出120字长度限制,请修改摘要后重试。",
|
|
14066
|
+
"-4": "不支持发布审核中或转码中的视频",
|
|
14067
|
+
"-2": "不支持发布审核中或转码中的视频",
|
|
14068
|
+
770001: "不支持发布审核中或转码中的视频",
|
|
14069
|
+
200074: "系统繁忙,请稍后重试!"
|
|
14042
14070
|
};
|
|
14043
14071
|
const ignoreErrno = [
|
|
14044
14072
|
154019
|
|
14045
14073
|
];
|
|
14074
|
+
const userTypeMap = {
|
|
14075
|
+
所有用户: 1,
|
|
14076
|
+
已关注的用户: 2,
|
|
14077
|
+
已关注7天及以上的用户: 3
|
|
14078
|
+
};
|
|
14046
14079
|
const generatorFormData = (data)=>{
|
|
14047
14080
|
const formData = new URLSearchParams();
|
|
14048
14081
|
for (const [key, value] of Object.entries(data))formData.append(key, String(value));
|
|
@@ -14150,6 +14183,223 @@ var __webpack_exports__ = {};
|
|
|
14150
14183
|
const coverRes = await uploadImages([
|
|
14151
14184
|
params.settingInfo.wxCover
|
|
14152
14185
|
]);
|
|
14186
|
+
let oriWhitelist = null;
|
|
14187
|
+
if (params.settingInfo?.wxCopyright && params.settingInfo?.wxWhitelist) {
|
|
14188
|
+
const _oriWhitelist = params.settingInfo.wxWhitelist;
|
|
14189
|
+
if (_oriWhitelist && _oriWhitelist.length > 0) {
|
|
14190
|
+
const white_list = [];
|
|
14191
|
+
const white_list_user = {
|
|
14192
|
+
nickname: "",
|
|
14193
|
+
title: "可修改文章",
|
|
14194
|
+
openid: "",
|
|
14195
|
+
wx_name: "",
|
|
14196
|
+
username: "",
|
|
14197
|
+
avatar: "",
|
|
14198
|
+
can_modify: "1",
|
|
14199
|
+
can_hide_source: "0",
|
|
14200
|
+
can_reward: "0"
|
|
14201
|
+
};
|
|
14202
|
+
for (const _user of _oriWhitelist){
|
|
14203
|
+
const userInfo_res = await http.api({
|
|
14204
|
+
method: "post",
|
|
14205
|
+
url: "https://mp.weixin.qq.com/cgi-bin/appmsgcopyright?action=searchacct",
|
|
14206
|
+
params: {
|
|
14207
|
+
action: "searchacct"
|
|
14208
|
+
},
|
|
14209
|
+
data: generatorFormData({
|
|
14210
|
+
lang: "zh_CN",
|
|
14211
|
+
f: "json",
|
|
14212
|
+
ajax: 1,
|
|
14213
|
+
token: params.token,
|
|
14214
|
+
random: Math.random().toString(),
|
|
14215
|
+
username: _user
|
|
14216
|
+
}),
|
|
14217
|
+
defaultErrorMsg: "搜索用户信息失败"
|
|
14218
|
+
});
|
|
14219
|
+
if (!(userInfo_res.search_list.length > 0)) return {
|
|
14220
|
+
code: 200,
|
|
14221
|
+
message: `白名单用户:${_user} 未搜索到,请确定输入是否正确!`,
|
|
14222
|
+
data: ''
|
|
14223
|
+
};
|
|
14224
|
+
{
|
|
14225
|
+
let userInfo_resJson = userInfo_res.search_list[0];
|
|
14226
|
+
white_list_user.nickname = userInfo_resJson.nickname;
|
|
14227
|
+
white_list_user.openid = userInfo_resJson.openid;
|
|
14228
|
+
white_list_user.avatar = userInfo_resJson.pic_url;
|
|
14229
|
+
white_list_user.username = userInfo_resJson.username;
|
|
14230
|
+
white_list_user.wx_name = userInfo_resJson.wx_name;
|
|
14231
|
+
white_list.push({
|
|
14232
|
+
...white_list_user
|
|
14233
|
+
});
|
|
14234
|
+
}
|
|
14235
|
+
}
|
|
14236
|
+
oriWhitelist = white_list.length > 0 ? JSON.stringify({
|
|
14237
|
+
white_list: white_list
|
|
14238
|
+
}) : "";
|
|
14239
|
+
}
|
|
14240
|
+
}
|
|
14241
|
+
let writerid = null;
|
|
14242
|
+
let reply_id = null;
|
|
14243
|
+
if (params.settingInfo.wxCopyright && params.settingInfo.wxRewardTarget) {
|
|
14244
|
+
async function getWriterList() {
|
|
14245
|
+
const res = await http.api({
|
|
14246
|
+
method: "get",
|
|
14247
|
+
url: 'https://mp.weixin.qq.com/acct/writermgr',
|
|
14248
|
+
params: {
|
|
14249
|
+
action: 'get_writer_list',
|
|
14250
|
+
fingerprint,
|
|
14251
|
+
token: params.token,
|
|
14252
|
+
lang: "zh_CN",
|
|
14253
|
+
f: "json",
|
|
14254
|
+
ajax: 1
|
|
14255
|
+
}
|
|
14256
|
+
});
|
|
14257
|
+
return res.pageinfo.writerlist || [];
|
|
14258
|
+
}
|
|
14259
|
+
async function getRewardText() {
|
|
14260
|
+
const res = await http.api({
|
|
14261
|
+
method: "get",
|
|
14262
|
+
url: 'https://mp.weixin.qq.com/merchant/reward',
|
|
14263
|
+
params: {
|
|
14264
|
+
action: 'getautoreply',
|
|
14265
|
+
fingerprint,
|
|
14266
|
+
token: params.token,
|
|
14267
|
+
lang: "zh_CN",
|
|
14268
|
+
f: "json",
|
|
14269
|
+
ajax: 1
|
|
14270
|
+
}
|
|
14271
|
+
});
|
|
14272
|
+
return res.reply_infos;
|
|
14273
|
+
}
|
|
14274
|
+
for(var _type in params.settingInfo.wxRewardTarget)if ("author" === _type) {
|
|
14275
|
+
if (0 == (await getWriterList()).length) {
|
|
14276
|
+
const rewardbind = await http.api({
|
|
14277
|
+
method: "get",
|
|
14278
|
+
url: "https://mp.weixin.qq.com/acct/writermgr",
|
|
14279
|
+
params: {
|
|
14280
|
+
action: "get_rewardbind_qrcode",
|
|
14281
|
+
random: Math.random().toString(),
|
|
14282
|
+
fingerprint,
|
|
14283
|
+
token: params.token,
|
|
14284
|
+
lang: "zh_CN",
|
|
14285
|
+
f: "json",
|
|
14286
|
+
ajax: 1
|
|
14287
|
+
},
|
|
14288
|
+
defaultErrorMsg: GET_QRCODE_DEFAULT_ERROR
|
|
14289
|
+
});
|
|
14290
|
+
const rewardBuffer = Buffer.from(rewardbind.qrcode_base64, 'base64');
|
|
14291
|
+
const rewardFilePath = external_node_path_default().join(tmpCachePath, "weixin_reward.jpg");
|
|
14292
|
+
external_node_fs_default().writeFileSync(rewardFilePath, new Uint8Array(rewardBuffer));
|
|
14293
|
+
params.safeQrcodeCallback?.(rewardFilePath);
|
|
14294
|
+
const task_id = rewardbind.task_id;
|
|
14295
|
+
let code = null;
|
|
14296
|
+
for(let i = 0; i < scanRetryMaxCount; i++){
|
|
14297
|
+
await sleep(2000);
|
|
14298
|
+
const checkScanResult = await http.api({
|
|
14299
|
+
method: "get",
|
|
14300
|
+
url: "https://mp.weixin.qq.com/acct/writermgr",
|
|
14301
|
+
params: {
|
|
14302
|
+
action: "query_rewardbind_qrcode_status",
|
|
14303
|
+
task_id: task_id,
|
|
14304
|
+
fingerprint,
|
|
14305
|
+
lang: "zh_CN",
|
|
14306
|
+
f: "json",
|
|
14307
|
+
ajax: 1,
|
|
14308
|
+
token: params.token,
|
|
14309
|
+
timespam: Date.now()
|
|
14310
|
+
}
|
|
14311
|
+
});
|
|
14312
|
+
code = checkScanResult.qrcode_status;
|
|
14313
|
+
if (2 == code && (await getWriterList()).length > 0) break;
|
|
14314
|
+
if (i === scanRetryMaxCount - 1) return {
|
|
14315
|
+
code: 200,
|
|
14316
|
+
message: "二维码已过期,请重试绑定。",
|
|
14317
|
+
data: ""
|
|
14318
|
+
};
|
|
14319
|
+
}
|
|
14320
|
+
}
|
|
14321
|
+
let _writer = await getWriterList();
|
|
14322
|
+
for (var _writer_item of _writer)if (_writer_item.nickname === params.settingInfo.wxRewardTarget[_type]) writerid = _writer_item.writerid;
|
|
14323
|
+
if (!writerid) return {
|
|
14324
|
+
code: 200,
|
|
14325
|
+
message: "未匹配到赞赏绑定用户,请确认用户名与绑定是否正常!",
|
|
14326
|
+
data: ""
|
|
14327
|
+
};
|
|
14328
|
+
if (params.settingInfo?.wxRewardText) {
|
|
14329
|
+
let rewardList = await getRewardText();
|
|
14330
|
+
let matchdID = rewardList.find((reward)=>reward.text === params.settingInfo.wxRewardText)?.reply_id ?? null;
|
|
14331
|
+
if (0 != rewardList.length && matchdID) reply_id = matchdID;
|
|
14332
|
+
else await http.api({
|
|
14333
|
+
method: "post",
|
|
14334
|
+
url: 'https://mp.weixin.qq.com/merchant/reward',
|
|
14335
|
+
params: {
|
|
14336
|
+
action: 'addautoreply'
|
|
14337
|
+
},
|
|
14338
|
+
data: generatorFormData({
|
|
14339
|
+
type: 1,
|
|
14340
|
+
fingerprint,
|
|
14341
|
+
token: params.token,
|
|
14342
|
+
lang: "zh_CN",
|
|
14343
|
+
f: "json",
|
|
14344
|
+
ajax: 1,
|
|
14345
|
+
text: params.settingInfo.wxRewardText
|
|
14346
|
+
})
|
|
14347
|
+
});
|
|
14348
|
+
if (!matchdID) {
|
|
14349
|
+
for (var _reply_item of (await getRewardText()))reply_id = (await getRewardText()).find((reward)=>reward.text === params.settingInfo.wxRewardText)?.reply_id;
|
|
14350
|
+
if (!reply_id) return {
|
|
14351
|
+
code: 200,
|
|
14352
|
+
message: "赞赏文案添加失败,请重新检查",
|
|
14353
|
+
data: ""
|
|
14354
|
+
};
|
|
14355
|
+
}
|
|
14356
|
+
}
|
|
14357
|
+
}
|
|
14358
|
+
}
|
|
14359
|
+
const wxInteractionInfo = (()=>{
|
|
14360
|
+
const _wxInteraction = {
|
|
14361
|
+
need_open_comment0: 0,
|
|
14362
|
+
only_fans_can_comment0: 0,
|
|
14363
|
+
only_fans_days_can_comment0: 0,
|
|
14364
|
+
reply_flag0: 2,
|
|
14365
|
+
auto_elect_comment0: 0,
|
|
14366
|
+
auto_elect_reply0: 1,
|
|
14367
|
+
open_fansmsg0: 0
|
|
14368
|
+
};
|
|
14369
|
+
const type = params?.settingInfo?.wxInteraction?.Type ?? "";
|
|
14370
|
+
if ("public" === type) {
|
|
14371
|
+
const _opt = params?.settingInfo?.wxInteraction?.Option;
|
|
14372
|
+
if (!_opt || !_opt.Comment || !_opt.reply || null == _opt.elect_comment || null == _opt.elect_reply) return null;
|
|
14373
|
+
const commentType = userTypeMap[_opt.Comment];
|
|
14374
|
+
const replyType = userTypeMap[_opt.reply] + 1;
|
|
14375
|
+
_wxInteraction.need_open_comment0 = 1;
|
|
14376
|
+
switch(commentType){
|
|
14377
|
+
case 1:
|
|
14378
|
+
_wxInteraction.only_fans_can_comment0 = 0;
|
|
14379
|
+
_wxInteraction.only_fans_days_can_comment0 = 0;
|
|
14380
|
+
break;
|
|
14381
|
+
case 2:
|
|
14382
|
+
_wxInteraction.only_fans_can_comment0 = 1;
|
|
14383
|
+
_wxInteraction.only_fans_days_can_comment0 = 0;
|
|
14384
|
+
break;
|
|
14385
|
+
case 3:
|
|
14386
|
+
_wxInteraction.only_fans_can_comment0 = 0;
|
|
14387
|
+
_wxInteraction.only_fans_days_can_comment0 = 1;
|
|
14388
|
+
break;
|
|
14389
|
+
}
|
|
14390
|
+
_wxInteraction.reply_flag0 = replyType;
|
|
14391
|
+
_wxInteraction.auto_elect_comment0 = _opt.elect_comment ? userTypeMap[_opt.Comment] : 0;
|
|
14392
|
+
_wxInteraction.auto_elect_reply0 = _opt.elect_reply ? userTypeMap[_opt.reply] : 1;
|
|
14393
|
+
return _wxInteraction;
|
|
14394
|
+
}
|
|
14395
|
+
if ("private" === type) _wxInteraction.open_fansmsg0 = 1;
|
|
14396
|
+
return _wxInteraction;
|
|
14397
|
+
})();
|
|
14398
|
+
if (!wxInteractionInfo) return {
|
|
14399
|
+
code: 200,
|
|
14400
|
+
message: "互动参数设置错误,请检查参数设置!",
|
|
14401
|
+
data: ""
|
|
14402
|
+
};
|
|
14153
14403
|
const draftData = {
|
|
14154
14404
|
lang: "zh_CN",
|
|
14155
14405
|
f: "json",
|
|
@@ -14162,16 +14412,19 @@ var __webpack_exports__ = {};
|
|
|
14162
14412
|
is_finder_video0: 0,
|
|
14163
14413
|
finder_draft_id0: 0,
|
|
14164
14414
|
applyori0: 0,
|
|
14165
|
-
can_reward0: 0,
|
|
14415
|
+
can_reward0: writerid ? 1 : 0,
|
|
14166
14416
|
pay_gifts_count0: 0,
|
|
14167
14417
|
is_video_recommend0: -1,
|
|
14168
|
-
writerid0: 0,
|
|
14418
|
+
writerid0: writerid ? writerid : 0,
|
|
14169
14419
|
auto_gen_digest0: 0,
|
|
14170
14420
|
last_choose_cover_from0: 0,
|
|
14171
|
-
need_open_comment0:
|
|
14172
|
-
only_fans_can_comment0:
|
|
14173
|
-
only_fans_days_can_comment0:
|
|
14174
|
-
reply_flag0:
|
|
14421
|
+
need_open_comment0: wxInteractionInfo.need_open_comment0,
|
|
14422
|
+
only_fans_can_comment0: wxInteractionInfo.only_fans_can_comment0,
|
|
14423
|
+
only_fans_days_can_comment0: wxInteractionInfo.only_fans_days_can_comment0,
|
|
14424
|
+
reply_flag0: wxInteractionInfo.reply_flag0,
|
|
14425
|
+
auto_elect_comment0: wxInteractionInfo.auto_elect_comment0,
|
|
14426
|
+
auto_elect_reply0: wxInteractionInfo.auto_elect_reply0,
|
|
14427
|
+
reward_reply_id0: params.settingInfo?.wxRewardText ? reply_id ? reply_id : 0 : 0,
|
|
14175
14428
|
not_pay_can_comment0: 0,
|
|
14176
14429
|
data_seq: 0,
|
|
14177
14430
|
msg_index_id0: "",
|
|
@@ -14183,7 +14436,11 @@ var __webpack_exports__ = {};
|
|
|
14183
14436
|
content0: content || "",
|
|
14184
14437
|
sourceurl0: params?.settingInfo?.wxOriginalText || "",
|
|
14185
14438
|
cdn_url0: coverRes[0].cdn_url || "",
|
|
14186
|
-
|
|
14439
|
+
copyright_type0: params?.settingInfo?.wxCopyright ? 1 : 0,
|
|
14440
|
+
allow_reprint0: params?.settingInfo?.wxCopyright ? 0 : '',
|
|
14441
|
+
allow_reprint_modify0: params?.settingInfo?.wxCopyright ? 0 : '',
|
|
14442
|
+
ori_white_list0: params?.settingInfo?.wxCopyright ? oriWhitelist : '',
|
|
14443
|
+
open_fansmsg0: wxInteractionInfo.open_fansmsg0,
|
|
14187
14444
|
allow_fast_reprint0: params?.settingInfo?.wxQuickReprint ? 1 : 0,
|
|
14188
14445
|
disable_recommend0: params?.settingInfo?.wxNotAllowRecommend ? 1 : 0,
|
|
14189
14446
|
claim_source_type0: params?.settingInfo?.wxCreationSource?.[0] || "",
|
|
@@ -14534,6 +14791,81 @@ var __webpack_exports__ = {};
|
|
|
14534
14791
|
timestamp: Date.now(),
|
|
14535
14792
|
appmsgid: params.appMsgId
|
|
14536
14793
|
};
|
|
14794
|
+
if (params.settingInfo?.wxRewardTarget) {
|
|
14795
|
+
const urlRewardParams = {
|
|
14796
|
+
action: "inviteauthor",
|
|
14797
|
+
token: params.token,
|
|
14798
|
+
lang: "zh_CN"
|
|
14799
|
+
};
|
|
14800
|
+
const wxRewardPage = await task.createPage({
|
|
14801
|
+
show: task.debug,
|
|
14802
|
+
url: params.url || `https://mp.weixin.qq.com/cgi-bin/safecenterstatus?${Object.entries(urlRewardParams).map((it)=>it.join("=")).join("&")}`,
|
|
14803
|
+
cookies: params.cookies?.map((it)=>({
|
|
14804
|
+
...commonCookies,
|
|
14805
|
+
...it
|
|
14806
|
+
})) || []
|
|
14807
|
+
});
|
|
14808
|
+
const reward_page = wxRewardPage.locator("#app");
|
|
14809
|
+
const isAddRewarder = reward_page.locator('.author_card_bd.weui-desktop-vm_primary').filter({
|
|
14810
|
+
hasText: params.settingInfo.wxRewardTarget.author
|
|
14811
|
+
}).count();
|
|
14812
|
+
if (await isAddRewarder == 0) {
|
|
14813
|
+
await reward_page.locator('.weui-desktop-panel__hd-right').click();
|
|
14814
|
+
try {
|
|
14815
|
+
try {
|
|
14816
|
+
await wxRewardPage.waitForSelector('.invite-qrcode', {
|
|
14817
|
+
state: 'visible',
|
|
14818
|
+
timeout: 20000
|
|
14819
|
+
});
|
|
14820
|
+
const qrcodeSrc = await reward_page.locator(".invite-qrcode").getAttribute('src');
|
|
14821
|
+
if (qrcodeSrc) {
|
|
14822
|
+
const rewardBuffer = Buffer.from(qrcodeSrc.replace(/^data:image\/\w+;base64,/, ''), 'base64');
|
|
14823
|
+
const rewardFilePath = external_node_path_default().join(tmpCachePath, "weixin_reward.jpg");
|
|
14824
|
+
external_node_fs_default().writeFileSync(rewardFilePath, new Uint8Array(rewardBuffer));
|
|
14825
|
+
params.safeQrcodeCallback?.(rewardFilePath);
|
|
14826
|
+
}
|
|
14827
|
+
} catch (error) {
|
|
14828
|
+
throw new Error("二维码已过期,请重试绑定。");
|
|
14829
|
+
}
|
|
14830
|
+
for(let i = 0; i < scanRetryMaxCount; i++){
|
|
14831
|
+
await Promise.all([
|
|
14832
|
+
wxRewardPage.reload(),
|
|
14833
|
+
wxRewardPage.waitForLoadState('domcontentloaded')
|
|
14834
|
+
]);
|
|
14835
|
+
try {
|
|
14836
|
+
await wxRewardPage.waitForSelector(`.author_card_bd.weui-desktop-vm_primary:has-text("${params.settingInfo.wxRewardTarget?.author}")`, {
|
|
14837
|
+
timeout: 1000
|
|
14838
|
+
});
|
|
14839
|
+
break;
|
|
14840
|
+
} catch (error) {}
|
|
14841
|
+
if (i === scanRetryMaxCount - 1) throw new Error("未确认绑定账户,请在手机端确认绑定并重试");
|
|
14842
|
+
}
|
|
14843
|
+
} catch (error) {
|
|
14844
|
+
let errorMessage = "发生未知错误";
|
|
14845
|
+
if (error instanceof Error) errorMessage = error.message;
|
|
14846
|
+
else if ("string" == typeof error) errorMessage = error;
|
|
14847
|
+
await wxRewardPage.close();
|
|
14848
|
+
return {
|
|
14849
|
+
code: 200,
|
|
14850
|
+
message: errorMessage,
|
|
14851
|
+
data: ""
|
|
14852
|
+
};
|
|
14853
|
+
}
|
|
14854
|
+
}
|
|
14855
|
+
if (params.settingInfo.wxRewardText) {
|
|
14856
|
+
await wxRewardPage.locator('[href="/merchant/reward?action=getautoreply"]').click();
|
|
14857
|
+
await wxRewardPage.waitForLoadState('networkidle');
|
|
14858
|
+
const isAddWord = reward_page.locator(".auto-reply__list.edit .auto-reply__hd .auto-reply__text").filter({
|
|
14859
|
+
hasText: new RegExp(`^${params.settingInfo.wxRewardText}$`)
|
|
14860
|
+
}).count();
|
|
14861
|
+
if (await isAddWord == 0) {
|
|
14862
|
+
await reward_page.locator(".emotion_editor .edit_area").fill(params.settingInfo.wxRewardText);
|
|
14863
|
+
await reward_page.locator(".emotion_editor .edit_area").click();
|
|
14864
|
+
await reward_page.locator(".editor_toolbar .weui-desktop-btn.weui-desktop-btn_primary").click();
|
|
14865
|
+
}
|
|
14866
|
+
}
|
|
14867
|
+
await wxRewardPage.close();
|
|
14868
|
+
}
|
|
14537
14869
|
const page = await task.createPage({
|
|
14538
14870
|
show: task.debug,
|
|
14539
14871
|
url: params.url || `https://mp.weixin.qq.com/cgi-bin/appmsg?${Object.entries(urlParams).map((it)=>it.join("=")).join("&")}`,
|
|
@@ -14556,6 +14888,10 @@ var __webpack_exports__ = {};
|
|
|
14556
14888
|
await page.waitForSelector("#editor_pannel", {
|
|
14557
14889
|
state: "visible"
|
|
14558
14890
|
});
|
|
14891
|
+
PopupListener(page, '[v-transfer-dom="#vue_app"] .weui-desktop-dialog', "更新", '[v-transfer-dom="#vue_app"] .weui-desktop-icon-btn.weui-desktop-dialog__close-btn', {
|
|
14892
|
+
checkInterval: 1000,
|
|
14893
|
+
stopAfterClick: false
|
|
14894
|
+
});
|
|
14559
14895
|
const titleInstance = page.locator("#js_title_main textarea#title");
|
|
14560
14896
|
await titleInstance.click();
|
|
14561
14897
|
await titleInstance.fill(params.title);
|
|
@@ -14597,7 +14933,15 @@ var __webpack_exports__ = {};
|
|
|
14597
14933
|
await page.waitForSelector(".weui-desktop-img-picker__list .weui-desktop-img-picker__item.selected", {
|
|
14598
14934
|
state: "visible"
|
|
14599
14935
|
});
|
|
14600
|
-
await page.
|
|
14936
|
+
await page.waitForSelector('.weui-desktop-upload__file__progress', {
|
|
14937
|
+
state: 'detached'
|
|
14938
|
+
});
|
|
14939
|
+
const pic_msg = page.locator('.weui-desktop-img-picker__list .weui-desktop-img-picker__item.selected .weui-desktop-upload__file__msg');
|
|
14940
|
+
if (await pic_msg.count() > 0) return {
|
|
14941
|
+
code: 200,
|
|
14942
|
+
message: "图片上传错误:" + (await pic_msg.textContent() || "未知错误,请重试!"),
|
|
14943
|
+
data: ""
|
|
14944
|
+
};
|
|
14601
14945
|
await dialog.locator(".weui-desktop-dialog__ft .weui-desktop-btn:not(.weui-desktop-btn_disabled)").filter({
|
|
14602
14946
|
hasText: "下一步"
|
|
14603
14947
|
}).click();
|
|
@@ -14610,6 +14954,124 @@ var __webpack_exports__ = {};
|
|
|
14610
14954
|
hasText: "确认"
|
|
14611
14955
|
}).click();
|
|
14612
14956
|
}
|
|
14957
|
+
if (params.settingInfo.wxCopyright) {
|
|
14958
|
+
await page.locator('#js_original').click();
|
|
14959
|
+
const ori_dialog = page.locator('.claim__original-dialog.original_dialog');
|
|
14960
|
+
const ori_dialog_bd = ori_dialog.locator('.weui-desktop-dialog__bd');
|
|
14961
|
+
const ori_dialog_ft = ori_dialog.locator('.weui-desktop-dialog__ft');
|
|
14962
|
+
await ori_dialog_bd.locator('.weui-desktop-form__check-content').filter({
|
|
14963
|
+
hasText: "文字原创"
|
|
14964
|
+
}).click();
|
|
14965
|
+
if (params.settingInfo?.wxWhitelist) for (var _target of params.settingInfo.wxWhitelist){
|
|
14966
|
+
await ori_dialog_bd.locator('#js_article_whitelist_search').fill(_target);
|
|
14967
|
+
await ori_dialog_bd.locator('.js_search').click();
|
|
14968
|
+
const search_res = ori_dialog_bd.locator('#js_article_whitelist_search_result > div');
|
|
14969
|
+
await page.waitForTimeout(1000);
|
|
14970
|
+
if (await search_res.getAttribute('class') === 'search-result-title search-result-empty') return {
|
|
14971
|
+
code: 200,
|
|
14972
|
+
message: `白名单用户:${_target} 未搜索到,请确定输入是否正确!`,
|
|
14973
|
+
data: ''
|
|
14974
|
+
};
|
|
14975
|
+
{
|
|
14976
|
+
const search_res_name = await search_res.locator('.search-result-name-left').textContent() || void 0;
|
|
14977
|
+
await search_res.click();
|
|
14978
|
+
const whrite_list = ori_dialog_bd.locator('#js_article_whitelist_added tbody');
|
|
14979
|
+
const white_td_isadd = await whrite_list.locator('.table-td-name').filter({
|
|
14980
|
+
hasText: search_res_name
|
|
14981
|
+
}).count();
|
|
14982
|
+
if (!white_td_isadd) return {
|
|
14983
|
+
code: 200,
|
|
14984
|
+
message: '白名单添加失败,请重试!',
|
|
14985
|
+
data: ''
|
|
14986
|
+
};
|
|
14987
|
+
}
|
|
14988
|
+
}
|
|
14989
|
+
if (params.settingInfo?.wxQuickReprint) {
|
|
14990
|
+
const btn_isChecked = await ori_dialog_bd.locator('//span[@class="frm_tips"]').filter({
|
|
14991
|
+
hasText: '已开启'
|
|
14992
|
+
}).count() == 1;
|
|
14993
|
+
if (!btn_isChecked) await ori_dialog_bd.locator('.weui-desktop-switch_loading .weui-desktop-switch__box').click();
|
|
14994
|
+
}
|
|
14995
|
+
const checkbox = ori_dialog_ft.locator('.weui-desktop-icon-checkbox');
|
|
14996
|
+
if (!await checkbox.isChecked()) await checkbox.check();
|
|
14997
|
+
await ori_dialog_ft.locator('.weui-desktop-btn.weui-desktop-btn_primary').click();
|
|
14998
|
+
if (params.settingInfo?.wxRewardTarget) {
|
|
14999
|
+
await page.locator('#js_reward_setting_area').click();
|
|
15000
|
+
const reward_setting = page.locator('.reward-setting-dialog');
|
|
15001
|
+
const reward_setting_bd = reward_setting.locator('.weui-desktop-dialog__bd');
|
|
15002
|
+
const reward_setting_ft = reward_setting.locator('.weui-desktop-dialog__ft');
|
|
15003
|
+
for(var _type in params.settingInfo.wxRewardTarget)if ("author" === _type) {
|
|
15004
|
+
let userName = params.settingInfo.wxRewardTarget[_type];
|
|
15005
|
+
await reward_setting_bd.locator('.weui-desktop-form__check-label', {
|
|
15006
|
+
hasText: '赞赏作者'
|
|
15007
|
+
}).click();
|
|
15008
|
+
await reward_setting_bd.locator('.weui-desktop-form__input').fill(userName);
|
|
15009
|
+
if (params.settingInfo.wxRewardText) {
|
|
15010
|
+
const reward_setting_replay = page.locator('.reward-reply-setting');
|
|
15011
|
+
const switchAuto = reward_setting_replay.locator('.weui-desktop-switch__box');
|
|
15012
|
+
const maxAttempts = 5;
|
|
15013
|
+
const delayMs = 500;
|
|
15014
|
+
let nowCheckTime = 0;
|
|
15015
|
+
for(let attempt = 0; attempt < maxAttempts; attempt++){
|
|
15016
|
+
const isDisabled = await switchAuto.isDisabled();
|
|
15017
|
+
if (!isDisabled) {
|
|
15018
|
+
await switchAuto.isChecked() && nowCheckTime++;
|
|
15019
|
+
if (2 == nowCheckTime) break;
|
|
15020
|
+
}
|
|
15021
|
+
if (attempt === maxAttempts - 1) throw new Error('Checkbox did not become enabled within the timeout.');
|
|
15022
|
+
await new Promise((resolve)=>setTimeout(resolve, delayMs));
|
|
15023
|
+
}
|
|
15024
|
+
const isOneReplay = await reward_setting_replay.locator('.reward-reply-select__wrp >.reward-reply-select__tips').textContent() == "添加新的回复";
|
|
15025
|
+
const isCurrentReplay = await reward_setting_replay.locator('.reward-reply-select__wrp >.reward-reply-select__display .wording').filter({
|
|
15026
|
+
hasText: new RegExp(`^${[
|
|
15027
|
+
params.settingInfo.wxRewardText
|
|
15028
|
+
]}$`)
|
|
15029
|
+
}).count() == 1;
|
|
15030
|
+
if (!isOneReplay && !isCurrentReplay) {
|
|
15031
|
+
await reward_setting_replay.locator('.reward-reply-select__wrp >.reward-reply-select__tips').click();
|
|
15032
|
+
await reward_setting_replay.locator('.reward-reply-select__display.can-select .wording').filter({
|
|
15033
|
+
hasText: new RegExp(`^${[
|
|
15034
|
+
params.settingInfo.wxRewardText
|
|
15035
|
+
]}$`)
|
|
15036
|
+
}).click();
|
|
15037
|
+
}
|
|
15038
|
+
} 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();
|
|
15039
|
+
}
|
|
15040
|
+
const checkbox = reward_setting_ft.locator('.weui-desktop-icon-checkbox');
|
|
15041
|
+
if (!await checkbox.isChecked()) await checkbox.check();
|
|
15042
|
+
await reward_setting_ft.locator('.weui-desktop-btn.weui-desktop-btn_primary').click();
|
|
15043
|
+
}
|
|
15044
|
+
}
|
|
15045
|
+
if (params.settingInfo?.wxInteraction) {
|
|
15046
|
+
await page.locator('.appmsg-editor__setting-group.js_interaction_cell').click();
|
|
15047
|
+
const wxInteraction_setting = page.locator('.interaction-dialog');
|
|
15048
|
+
const wxInteraction_bd = wxInteraction_setting.locator('.weui-desktop-dialog__bd');
|
|
15049
|
+
const wxInteraction_ft = wxInteraction_setting.locator('.weui-desktop-dialog__ft');
|
|
15050
|
+
if ("public" == params.settingInfo.wxInteraction.Type) {
|
|
15051
|
+
await wxInteraction_bd.locator('.weui-desktop-form__check-label', {
|
|
15052
|
+
hasText: '留言'
|
|
15053
|
+
}).click();
|
|
15054
|
+
const comment_area = wxInteraction_bd.locator('.comment-options-block.pt0');
|
|
15055
|
+
const reply_area = wxInteraction_bd.locator('.comment-options-block.bb0.pb0');
|
|
15056
|
+
const commont_rply_opt = page.locator('.weui-desktop-popper.options-popover[x-placement="bottom"]');
|
|
15057
|
+
await comment_area.locator('.comment-options__selector-btn').click();
|
|
15058
|
+
await commont_rply_opt.locator('.weui-desktop-form__check-label', {
|
|
15059
|
+
hasText: params.settingInfo.wxInteraction.Option?.Comment
|
|
15060
|
+
}).click();
|
|
15061
|
+
if (params.settingInfo.wxInteraction.Option?.elect_comment) await comment_area.locator('.weui-desktop-switch__box').check();
|
|
15062
|
+
else await comment_area.locator('.weui-desktop-switch__input').isChecked() && comment_area.locator('.weui-desktop-switch__box').uncheck();
|
|
15063
|
+
await page.waitForTimeout(1000);
|
|
15064
|
+
await reply_area.locator('.comment-options__selector-btn').click();
|
|
15065
|
+
await commont_rply_opt.locator('.weui-desktop-form__check-label', {
|
|
15066
|
+
hasText: params.settingInfo.wxInteraction.Option?.reply
|
|
15067
|
+
}).click();
|
|
15068
|
+
if (params.settingInfo.wxInteraction.Option?.elect_reply) await reply_area.locator('.weui-desktop-switch__box').check();
|
|
15069
|
+
else await reply_area.locator('.weui-desktop-switch__input').isChecked() && reply_area.locator('.weui-desktop-switch__box').uncheck();
|
|
15070
|
+
} else if ("private" == params.settingInfo.wxInteraction.Type) await wxInteraction_bd.locator('.weui-desktop-form__check-label', {
|
|
15071
|
+
hasText: '快捷私信'
|
|
15072
|
+
}).click();
|
|
15073
|
+
await wxInteraction_ft.locator('.weui-desktop-btn.weui-desktop-btn_primary').click();
|
|
15074
|
+
}
|
|
14613
15075
|
if (params.settingInfo.wxOriginalText) {
|
|
14614
15076
|
await page.locator("#js_article_url_area .allow_click_opr").click();
|
|
14615
15077
|
await page.waitForTimeout(200);
|
|
@@ -14971,7 +15433,8 @@ var __webpack_exports__ = {};
|
|
|
14971
15433
|
}
|
|
14972
15434
|
}
|
|
14973
15435
|
const xiaohongshuPublish_mock_errnoMap = {
|
|
14974
|
-
903: "账户已登出,需重新登陆重试!"
|
|
15436
|
+
903: "账户已登出,需重新登陆重试!",
|
|
15437
|
+
902: "登录已过期,请重新登录!"
|
|
14975
15438
|
};
|
|
14976
15439
|
const xsEncrypt = new XsEncrypt();
|
|
14977
15440
|
const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
@@ -15041,13 +15504,62 @@ var __webpack_exports__ = {};
|
|
|
15041
15504
|
};
|
|
15042
15505
|
};
|
|
15043
15506
|
const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
|
|
15507
|
+
const searchTopic = async (topic)=>await http.api({
|
|
15508
|
+
method: "post",
|
|
15509
|
+
url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
|
|
15510
|
+
data: {
|
|
15511
|
+
keyword: topic,
|
|
15512
|
+
suggest_topic_request: {
|
|
15513
|
+
title: "",
|
|
15514
|
+
desc: `#${topic}`
|
|
15515
|
+
},
|
|
15516
|
+
page: {
|
|
15517
|
+
page_size: 20,
|
|
15518
|
+
page: 1
|
|
15519
|
+
}
|
|
15520
|
+
},
|
|
15521
|
+
defaultErrorMsg: "话题搜索异常,请稍后重试。"
|
|
15522
|
+
});
|
|
15523
|
+
let topicDesc = [];
|
|
15524
|
+
params.topic && params.topic.length > 0 && await Promise.all(params.topic.map(async (topic)=>{
|
|
15525
|
+
let topicInfo = {
|
|
15526
|
+
id: null,
|
|
15527
|
+
name: null,
|
|
15528
|
+
type: "topic"
|
|
15529
|
+
};
|
|
15530
|
+
const _topicInfo = await searchTopic(topic);
|
|
15531
|
+
if (0 === _topicInfo.data.topic_info_dtos.length || _topicInfo.data.topic_info_dtos[0].name !== topic) {
|
|
15532
|
+
const topicData = {
|
|
15533
|
+
topic_names: topic
|
|
15534
|
+
};
|
|
15535
|
+
const topicDataStr = xsEncrypt.dumps(topicData);
|
|
15536
|
+
const publishXt = Date.now().toString();
|
|
15537
|
+
const publishXs = await xsEncrypt.encryptXs(`/web_api/sns/capa/postgw/topic/batch_customized${topicDataStr}`, a1Cookie, publishXt);
|
|
15538
|
+
let createTopic = await http.api({
|
|
15539
|
+
method: "POST",
|
|
15540
|
+
url: "https://edith.xiaohongshu.com/web_api/sns/capa/postgw/topic/batch_customized",
|
|
15541
|
+
headers: {
|
|
15542
|
+
"x-s": publishXs,
|
|
15543
|
+
"x-t": publishXt
|
|
15544
|
+
},
|
|
15545
|
+
data: topicData,
|
|
15546
|
+
defaultErrorMsg: "话题创建异常,请稍后重试。"
|
|
15547
|
+
});
|
|
15548
|
+
Object.assign(topicInfo, createTopic.data.topic_infos[0]);
|
|
15549
|
+
} else {
|
|
15550
|
+
topicInfo.id = _topicInfo.data.topic_info_dtos[0].id;
|
|
15551
|
+
topicInfo.name = _topicInfo.data.topic_info_dtos[0].name;
|
|
15552
|
+
topicInfo.link = _topicInfo.data.topic_info_dtos[0].link;
|
|
15553
|
+
}
|
|
15554
|
+
topicDesc.push(topicInfo);
|
|
15555
|
+
}));
|
|
15044
15556
|
const publishData = {
|
|
15045
15557
|
common: {
|
|
15046
15558
|
ats: [],
|
|
15047
15559
|
biz_relations: [],
|
|
15048
|
-
desc: params?.content,
|
|
15560
|
+
desc: params?.content + (params?.topic?.map((it)=>`#${it}[话题]#`).join("") || ""),
|
|
15049
15561
|
goods_info: {},
|
|
15050
|
-
hash_tag:
|
|
15562
|
+
hash_tag: topicDesc,
|
|
15051
15563
|
note_id: "",
|
|
15052
15564
|
source: JSON.stringify({
|
|
15053
15565
|
type: "web",
|
|
@@ -15165,6 +15677,7 @@ var __webpack_exports__ = {};
|
|
|
15165
15677
|
'/api/galaxy/v2/creator/activity_center/list',
|
|
15166
15678
|
'/web_api/sns/v5/creator/topic/template/list',
|
|
15167
15679
|
'/web_api/sns/v5/creator/file/encryption',
|
|
15680
|
+
'/web_api/sns/capa/postgw/topic/batch_customized',
|
|
15168
15681
|
'/web_api/sns/v2/note'
|
|
15169
15682
|
];
|
|
15170
15683
|
await page.route('**', async (route, request)=>{
|
|
@@ -15244,7 +15757,7 @@ var __webpack_exports__ = {};
|
|
|
15244
15757
|
data: page.url()
|
|
15245
15758
|
};
|
|
15246
15759
|
}
|
|
15247
|
-
await page.locator("#content-area .menu-container .publish-video
|
|
15760
|
+
await page.locator("#content-area .menu-container .publish-video .btn").click();
|
|
15248
15761
|
await page.locator('.creator-container .header .creator-tab:not([style*="-9999px"]) .title').filter({
|
|
15249
15762
|
hasText: /^上传图文$/
|
|
15250
15763
|
}).click();
|
|
@@ -15261,7 +15774,15 @@ var __webpack_exports__ = {};
|
|
|
15261
15774
|
await titleInstance.fill(params.title);
|
|
15262
15775
|
const descInstance = page.locator(".editor-container #quillEditor .ql-editor");
|
|
15263
15776
|
await descInstance.click();
|
|
15264
|
-
await descInstance.
|
|
15777
|
+
await descInstance.pressSequentially(params.content);
|
|
15778
|
+
if (params.topic && params.topic.length > 0) for (const it of params.topic){
|
|
15779
|
+
await descInstance.pressSequentially(`#${it}`);
|
|
15780
|
+
await page.locator('.ql-mention-loading').waitFor({
|
|
15781
|
+
state: 'detached'
|
|
15782
|
+
});
|
|
15783
|
+
await page.waitForTimeout(1000);
|
|
15784
|
+
await page.locator('#quill-mention-item-0 .item-view-num').click();
|
|
15785
|
+
}
|
|
15265
15786
|
const container = page.locator(".creator-container .content .scroll-content");
|
|
15266
15787
|
await container.focus();
|
|
15267
15788
|
await page.mouse.wheel(0, 500);
|
|
@@ -15347,9 +15868,7 @@ var __webpack_exports__ = {};
|
|
|
15347
15868
|
if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
|
|
15348
15869
|
return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
|
|
15349
15870
|
};
|
|
15350
|
-
var package_namespaceObject = {
|
|
15351
|
-
i8: "1.2.4"
|
|
15352
|
-
};
|
|
15871
|
+
var package_namespaceObject = JSON.parse('{"i8":"1.2.6-beta.0"}');
|
|
15353
15872
|
class Action {
|
|
15354
15873
|
constructor(task){
|
|
15355
15874
|
this.task = task;
|