@iflyrpa/actions 1.2.13 → 1.2.14-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/common/FansTool/index.d.ts +3 -9
- package/dist/actions/common/sessionCheck/index.d.ts +16 -0
- package/dist/actions/getBaijiaohaoConfig/index.d.ts +1 -0
- package/dist/actions/getWeixinConfig/index.d.ts +16 -0
- package/dist/actions/searchAccountInfo/index.d.ts +46 -0
- package/dist/actions/searchPublishInfo/index.d.ts +56 -0
- package/dist/bundle.js +13163 -12429
- package/dist/bundle.js.map +1 -1
- package/dist/index.d.ts +15 -6
- package/dist/index.js +1176 -453
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1185 -457
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,517 @@
|
|
|
1
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
3
1
|
import * as __WEBPACK_EXTERNAL_MODULE_dom_serializer_aa70940b__ from "dom-serializer";
|
|
4
2
|
import * as __WEBPACK_EXTERNAL_MODULE_domhandler__ from "domhandler";
|
|
5
3
|
import * as __WEBPACK_EXTERNAL_MODULE_htmlparser2__ from "htmlparser2";
|
|
6
4
|
import * as __WEBPACK_EXTERNAL_MODULE_mime_types_eebf54a5__ from "mime-types";
|
|
7
|
-
import * as __WEBPACK_EXTERNAL_MODULE_axios__ from "axios";
|
|
8
|
-
import * as __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__ from "@iflyrpa/share";
|
|
9
|
-
import * as __WEBPACK_EXTERNAL_MODULE_form_data_cf000082__ from "form-data";
|
|
10
5
|
import * as __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__ from "node:buffer";
|
|
11
6
|
import * as __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__ from "node:crypto";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__ from "@iflyrpa/share";
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE_axios__ from "axios";
|
|
9
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
10
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
11
|
+
import * as __WEBPACK_EXTERNAL_MODULE_form_data_cf000082__ from "form-data";
|
|
12
12
|
var __webpack_modules__ = {
|
|
13
|
+
"./src/actions/searchAccountInfo/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
14
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
15
|
+
A: ()=>SearchAccountInfo
|
|
16
|
+
});
|
|
17
|
+
var _iflyrpa_share__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("@iflyrpa/share");
|
|
18
|
+
var _utils_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/utils/index.ts");
|
|
19
|
+
var _utils_http__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/utils/http.ts");
|
|
20
|
+
var _utils_xhsXsEncrypt__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/xhsXsEncrypt.ts");
|
|
21
|
+
const errorResponse = (message, code = 500)=>({
|
|
22
|
+
code,
|
|
23
|
+
message,
|
|
24
|
+
data: null
|
|
25
|
+
});
|
|
26
|
+
async function getToutiaoData(params) {
|
|
27
|
+
try {
|
|
28
|
+
const http = new _utils_http__WEBPACK_IMPORTED_MODULE_2__.e({
|
|
29
|
+
headers: {
|
|
30
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
31
|
+
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const [totalData, fansDataYesterday, contentDataYesterday] = await Promise.all([
|
|
35
|
+
http.api({
|
|
36
|
+
method: "get",
|
|
37
|
+
url: "https://mp.toutiao.com/mp/fe_api/home/merge_v2",
|
|
38
|
+
params: {
|
|
39
|
+
app_id: 1231
|
|
40
|
+
}
|
|
41
|
+
}),
|
|
42
|
+
http.api({
|
|
43
|
+
method: "get",
|
|
44
|
+
url: "https://mp.toutiao.com/mp/agw/statistic/v2/fans/latest_stat",
|
|
45
|
+
params: {
|
|
46
|
+
app_id: 1231
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
http.api({
|
|
50
|
+
method: "get",
|
|
51
|
+
url: "https://mp.toutiao.com/mp/agw/statistic/v2/content_stat",
|
|
52
|
+
params: {
|
|
53
|
+
type: 0,
|
|
54
|
+
app_id: 1231
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
]);
|
|
58
|
+
const ttData = {
|
|
59
|
+
fansNum: Number(totalData.data.statistic.data.total_subscribe_count),
|
|
60
|
+
fansNumYesterday: fansDataYesterday.fans_stat.change_count,
|
|
61
|
+
readNum: Number(totalData.data.statistic.data.total_read_play_count),
|
|
62
|
+
incomeNum: totalData.data.statistic.data.total_income,
|
|
63
|
+
incomeNumYesterday: totalData.data.statistic.data.yesterday_income,
|
|
64
|
+
showNumYesterday: contentDataYesterday.author_stat.consume_data.impression_count,
|
|
65
|
+
readNumYesterday: contentDataYesterday.author_stat.consume_data.go_detail_count,
|
|
66
|
+
likeNumYesterday: contentDataYesterday.author_stat.interaction_data.digg_count,
|
|
67
|
+
commentNumYesterday: contentDataYesterday.author_stat.interaction_data.comment_count
|
|
68
|
+
};
|
|
69
|
+
return (0, _iflyrpa_share__WEBPACK_IMPORTED_MODULE_0__.success)(ttData, "头条号粉丝数据获取成功!");
|
|
70
|
+
} catch (error) {
|
|
71
|
+
return errorResponse(error instanceof Error ? error.message : "头条号数据获取失败");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async function getXiaohongshuData(params) {
|
|
75
|
+
try {
|
|
76
|
+
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
77
|
+
if (!a1Cookie) return errorResponse("账号数据异常,请重新绑定账号后重试。", 200);
|
|
78
|
+
const http = new _utils_http__WEBPACK_IMPORTED_MODULE_2__.e({
|
|
79
|
+
headers: {
|
|
80
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
81
|
+
referer: "https://creator.xiaohongshu.com",
|
|
82
|
+
origin: "https://creator.xiaohongshu.com"
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
const xsEncrypt = new _utils_xhsXsEncrypt__WEBPACK_IMPORTED_MODULE_3__.H();
|
|
86
|
+
const xt = Date.now().toString();
|
|
87
|
+
const sevenDataUrl = "/api/galaxy/v2/creator/datacenter/account/base";
|
|
88
|
+
const xs = await xsEncrypt.encryptXs(sevenDataUrl, a1Cookie, xt);
|
|
89
|
+
const [overAllData, sevenData] = await Promise.all([
|
|
90
|
+
http.api({
|
|
91
|
+
method: "get",
|
|
92
|
+
url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
|
|
93
|
+
}),
|
|
94
|
+
http.api({
|
|
95
|
+
method: "get",
|
|
96
|
+
baseURL: "https://creator.xiaohongshu.com",
|
|
97
|
+
url: sevenDataUrl,
|
|
98
|
+
headers: {
|
|
99
|
+
"x-s": xs,
|
|
100
|
+
"x-t": xt
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
]);
|
|
104
|
+
const xhsData = {
|
|
105
|
+
fansNum: overAllData.data.fans_count,
|
|
106
|
+
favedNum: overAllData.data.faved_count,
|
|
107
|
+
watchNumLastWeek: sevenData.data.seven.view_count,
|
|
108
|
+
likeNumLastWeek: sevenData.data.seven.like_count,
|
|
109
|
+
collectNumLastWeek: sevenData.data.seven.collect_count,
|
|
110
|
+
commentNumLastWeek: sevenData.data.seven.comment_count,
|
|
111
|
+
fansNumLastWeek: sevenData.data.seven.rise_fans_count,
|
|
112
|
+
fansNumYesterday: sevenData.data.seven.rise_fans_list[0].count
|
|
113
|
+
};
|
|
114
|
+
return (0, _iflyrpa_share__WEBPACK_IMPORTED_MODULE_0__.success)(xhsData, "小红书粉丝数据获取成功!");
|
|
115
|
+
} catch (error) {
|
|
116
|
+
return errorResponse(error instanceof Error ? error.message : "小红书数据获取失败");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function getWeixinData(params) {
|
|
120
|
+
try {
|
|
121
|
+
const { token } = params;
|
|
122
|
+
if (!token) return errorResponse("缺少token", 200);
|
|
123
|
+
const http = new _utils_http__WEBPACK_IMPORTED_MODULE_2__.e({
|
|
124
|
+
headers: {
|
|
125
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
const massRandomIDHtml = await http.api({
|
|
129
|
+
method: "get",
|
|
130
|
+
url: "https://mp.weixin.qq.com/misc/appmsganalysis?action=report&token=1900237878&lang=zh_CN",
|
|
131
|
+
params: {
|
|
132
|
+
token,
|
|
133
|
+
lang: "zh_CN",
|
|
134
|
+
action: "report"
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
const massRandomIDReg = massRandomIDHtml.match(/mass_all\.([a-z0-9]+)\.js/);
|
|
138
|
+
const massRandomID = massRandomIDReg ? massRandomIDReg[1] : "";
|
|
139
|
+
const [readInfo, fansInfoHtml] = await Promise.all([
|
|
140
|
+
http.api({
|
|
141
|
+
method: "get",
|
|
142
|
+
url: `https://res.wx.qq.com/mpres/zh_CN/htmledition/pages/statistics/mass_all/mass_all.${massRandomID}.js`
|
|
143
|
+
}),
|
|
144
|
+
http.api({
|
|
145
|
+
method: "get",
|
|
146
|
+
url: "https://mp.weixin.qq.com/misc/useranalysis",
|
|
147
|
+
params: {
|
|
148
|
+
token,
|
|
149
|
+
lang: "zh_CN"
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
]);
|
|
153
|
+
const regex = /(readAllList|shareAllList|completeAllList):\s*(\[[^\]]+\])/g;
|
|
154
|
+
let match;
|
|
155
|
+
const arrays = {};
|
|
156
|
+
while(null !== (match = regex.exec(readInfo)))arrays[match[1]] = JSON.parse(match[2]);
|
|
157
|
+
const readAllList = arrays.readAllList || [];
|
|
158
|
+
const shareAllList = arrays.shareAllList || [];
|
|
159
|
+
const fansInfoReg = fansInfoHtml.match(/window\.CGI_DATA\['pages\/statistics\/user_statistics'\]\s*=\s*(\{[\s\S]*?\});/);
|
|
160
|
+
if (!fansInfoReg) return errorResponse("未找到粉丝信息", 200);
|
|
161
|
+
const fansInfo = eval("(" + fansInfoReg[1] + ")");
|
|
162
|
+
const yesterday = _utils_index__WEBPACK_IMPORTED_MODULE_1__.Tx.format(new Date().setDate(new Date().getDate() - 1), "yyyy-MM-dd");
|
|
163
|
+
const yesterdayFansInfo = fansInfo.list[0]?.list.find((item)=>item.date === yesterday);
|
|
164
|
+
if (!yesterdayFansInfo) return errorResponse("未找到粉丝数", 200);
|
|
165
|
+
const wxData = {
|
|
166
|
+
fansNum: yesterdayFansInfo.cumulate_user,
|
|
167
|
+
fansNumYesterday: yesterdayFansInfo.new_user - yesterdayFansInfo.cancel_user,
|
|
168
|
+
readNumYesterday: readAllList[0] || 0,
|
|
169
|
+
shareNumYesterday: shareAllList[0] || 0
|
|
170
|
+
};
|
|
171
|
+
return (0, _iflyrpa_share__WEBPACK_IMPORTED_MODULE_0__.success)(wxData, "微信粉丝数据获取成功!");
|
|
172
|
+
} catch (error) {
|
|
173
|
+
return errorResponse(error instanceof Error ? error.message : "微信数据获取失败");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async function getBaijiahaoData(params) {
|
|
177
|
+
try {
|
|
178
|
+
const { token } = params;
|
|
179
|
+
if (!token) return errorResponse("缺少token", 200);
|
|
180
|
+
const http = new _utils_http__WEBPACK_IMPORTED_MODULE_2__.e({
|
|
181
|
+
headers: {
|
|
182
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
183
|
+
token: String(token),
|
|
184
|
+
Referer: "https://baijiahao.baidu.com/builder/rc/home"
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
const yesterday = _utils_index__WEBPACK_IMPORTED_MODULE_1__.Tx.format(new Date().setDate(new Date().getDate() - 1), "yyyyMMdd");
|
|
188
|
+
const [fansData, readData, incomeData, yesterdayData] = await Promise.all([
|
|
189
|
+
http.api({
|
|
190
|
+
method: "get",
|
|
191
|
+
url: "https://baijiahao.baidu.com/pcui/home/index"
|
|
192
|
+
}),
|
|
193
|
+
http.api({
|
|
194
|
+
method: "get",
|
|
195
|
+
url: "https://baijiahao.baidu.com/author/eco/statistic/getauthorhistory"
|
|
196
|
+
}),
|
|
197
|
+
http.api({
|
|
198
|
+
method: "get",
|
|
199
|
+
url: "https://baijiahao.baidu.com/author/eco/income4/homepageincome"
|
|
200
|
+
}),
|
|
201
|
+
http.api({
|
|
202
|
+
method: "get",
|
|
203
|
+
url: `https://baijiahao.baidu.com/author/eco/statistics/appStatistic?type=all&is_yesterday=false&start_day=${yesterday}&end_day=${yesterday}&stat=0`
|
|
204
|
+
})
|
|
205
|
+
]);
|
|
206
|
+
const bjhData = {
|
|
207
|
+
fansNum: fansData.data.coreData.fansCount,
|
|
208
|
+
fansNumYesterday: yesterdayData.data.data.fans_increase,
|
|
209
|
+
readNum: readData.data.total.view_count,
|
|
210
|
+
incomeNum: incomeData.data.all_income.total_income,
|
|
211
|
+
incomeNumYesterday: incomeData.data.all_income.yesterday_income,
|
|
212
|
+
recommendNumYesterday: yesterdayData.data.data.recommend_count,
|
|
213
|
+
readNumYesterday: yesterdayData.data.data.view_count,
|
|
214
|
+
likeNumYesterday: yesterdayData.data.data.likes_count,
|
|
215
|
+
commentNumYesterday: yesterdayData.data.data.comment_count
|
|
216
|
+
};
|
|
217
|
+
return (0, _iflyrpa_share__WEBPACK_IMPORTED_MODULE_0__.success)(bjhData, "百家号粉丝数据获取成功!");
|
|
218
|
+
} catch (error) {
|
|
219
|
+
return errorResponse(error instanceof Error ? error.message : "百家号数据获取失败");
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
const SearchAccountInfo = async (_task, params)=>{
|
|
223
|
+
const { platform } = params;
|
|
224
|
+
switch(platform){
|
|
225
|
+
case "toutiao":
|
|
226
|
+
return getToutiaoData(params);
|
|
227
|
+
case "xiaohongshu":
|
|
228
|
+
return getXiaohongshuData(params);
|
|
229
|
+
case "weixin":
|
|
230
|
+
return getWeixinData(params);
|
|
231
|
+
case "baijiahao":
|
|
232
|
+
return getBaijiahaoData(params);
|
|
233
|
+
default:
|
|
234
|
+
return (0, _iflyrpa_share__WEBPACK_IMPORTED_MODULE_0__.success)(null, "暂不支持该平台");
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
},
|
|
238
|
+
"./src/utils/http.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
239
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
240
|
+
e: ()=>Http
|
|
241
|
+
});
|
|
242
|
+
var external_axios_ = __webpack_require__("axios");
|
|
243
|
+
class Http {
|
|
244
|
+
static handleApiError(error) {
|
|
245
|
+
if (error && "object" == typeof error && "code" in error && "message" in error) return error;
|
|
246
|
+
return {
|
|
247
|
+
code: 500,
|
|
248
|
+
message: "",
|
|
249
|
+
data: error
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
constructor(config){
|
|
253
|
+
this.apiClient = external_axios_["default"].create(config);
|
|
254
|
+
}
|
|
255
|
+
addResponseInterceptor(findError) {
|
|
256
|
+
this.apiClient.interceptors.response.use((response)=>{
|
|
257
|
+
const error = findError(response);
|
|
258
|
+
if (error) return Promise.reject(Object.assign(error, {
|
|
259
|
+
extra: {
|
|
260
|
+
method: response.config.method,
|
|
261
|
+
url: response.config.url
|
|
262
|
+
}
|
|
263
|
+
}));
|
|
264
|
+
return response;
|
|
265
|
+
}, (error)=>{
|
|
266
|
+
const errorResponse = {
|
|
267
|
+
code: error.response?.status || 500,
|
|
268
|
+
message: error.message || "",
|
|
269
|
+
data: error.response?.data,
|
|
270
|
+
extra: {
|
|
271
|
+
method: error.config?.method,
|
|
272
|
+
url: error.config?.url
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
if (error.response?.data) {
|
|
276
|
+
if ("object" == typeof error.response.data) {
|
|
277
|
+
const serverError = error.response.data;
|
|
278
|
+
if (serverError.message) errorResponse.message = serverError.message;
|
|
279
|
+
errorResponse.data = serverError;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return Promise.reject(errorResponse);
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
async api(config) {
|
|
286
|
+
try {
|
|
287
|
+
const response = await this.apiClient(config);
|
|
288
|
+
return response.data;
|
|
289
|
+
} catch (error) {
|
|
290
|
+
return Promise.reject(Http.handleApiError(error));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
"./src/utils/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
296
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
297
|
+
hc: ()=>parseUrlQueryString,
|
|
298
|
+
I: ()=>replaceImgSrc,
|
|
299
|
+
E_: ()=>extractImgTag,
|
|
300
|
+
i9: ()=>getRandomInRange,
|
|
301
|
+
f8: ()=>PopupListener,
|
|
302
|
+
qN: ()=>copyHtmlToClipboard,
|
|
303
|
+
Tx: ()=>TimeFormatter,
|
|
304
|
+
Tb: ()=>defaultParams,
|
|
305
|
+
n: ()=>stringifyError,
|
|
306
|
+
H8: ()=>getFileState,
|
|
307
|
+
jo: ()=>executeAction,
|
|
308
|
+
e0: ()=>calculateCropCoordinates
|
|
309
|
+
});
|
|
310
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
311
|
+
var external_node_path_ = __webpack_require__("node:path");
|
|
312
|
+
var http = __webpack_require__("./src/utils/http.ts");
|
|
313
|
+
function getRandomInRange(min, max) {
|
|
314
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
315
|
+
}
|
|
316
|
+
const getFileState = (filePath)=>{
|
|
317
|
+
const filename = external_node_path_["default"].basename(filePath);
|
|
318
|
+
const fileType = __WEBPACK_EXTERNAL_MODULE_mime_types_eebf54a5__["default"].lookup(filePath);
|
|
319
|
+
const stats = external_node_fs_["default"].statSync(filePath);
|
|
320
|
+
const fileSize = stats.size;
|
|
321
|
+
const lastModifiedDate = stats.mtime;
|
|
322
|
+
return {
|
|
323
|
+
name: filename,
|
|
324
|
+
type: fileType,
|
|
325
|
+
size: fileSize,
|
|
326
|
+
lastModifiedDate: lastModifiedDate.toString()
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
const calculateCropCoordinates = (width, height, aspectRatio)=>{
|
|
330
|
+
const targetRatio = aspectRatio[0] / aspectRatio[1];
|
|
331
|
+
let cropWidth;
|
|
332
|
+
let cropHeight;
|
|
333
|
+
if (width / height > targetRatio) {
|
|
334
|
+
cropHeight = height;
|
|
335
|
+
cropWidth = height * targetRatio;
|
|
336
|
+
} else {
|
|
337
|
+
cropWidth = width;
|
|
338
|
+
cropHeight = width / targetRatio;
|
|
339
|
+
}
|
|
340
|
+
const x1 = (width - cropWidth) / 2;
|
|
341
|
+
const y1 = (height - cropHeight) / 2;
|
|
342
|
+
const x2 = x1 + cropWidth;
|
|
343
|
+
const y2 = y1 + cropHeight;
|
|
344
|
+
return {
|
|
345
|
+
x1: x1 / width,
|
|
346
|
+
y1: y1 / height,
|
|
347
|
+
x2: x2 / width,
|
|
348
|
+
y2: y2 / height
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
const extractImgTag = (html)=>{
|
|
352
|
+
const srcList = [];
|
|
353
|
+
const parser = new __WEBPACK_EXTERNAL_MODULE_htmlparser2__.Parser({
|
|
354
|
+
onopentag (name, attributes) {
|
|
355
|
+
if ("img" === name && (attributes.src.trim() || attributes.currentSrc.trim())) srcList.push(attributes.src.trim() || attributes.currentSrc.trim());
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
parser.write(html);
|
|
359
|
+
parser.end();
|
|
360
|
+
return srcList;
|
|
361
|
+
};
|
|
362
|
+
class TimeFormatter {
|
|
363
|
+
static format(timestamp, formatStr = 'yyyy-MM-dd hh:mm') {
|
|
364
|
+
if ('number' == typeof timestamp && 10 === timestamp.toString().length) timestamp *= 1000;
|
|
365
|
+
const date = new Date(timestamp);
|
|
366
|
+
const map = {
|
|
367
|
+
yyyy: String(date.getFullYear()),
|
|
368
|
+
yy: String(date.getFullYear()).slice(-2),
|
|
369
|
+
MM: String(date.getMonth() + 1).padStart(2, '0'),
|
|
370
|
+
dd: String(date.getDate()).padStart(2, '0'),
|
|
371
|
+
hh: String(date.getHours()).padStart(2, '0'),
|
|
372
|
+
mm: String(date.getMinutes()).padStart(2, '0'),
|
|
373
|
+
ss: String(date.getSeconds()).padStart(2, '0'),
|
|
374
|
+
M: String(date.getMonth() + 1),
|
|
375
|
+
d: String(date.getDate()),
|
|
376
|
+
h: String(date.getHours()),
|
|
377
|
+
m: String(date.getMinutes()),
|
|
378
|
+
s: String(date.getSeconds())
|
|
379
|
+
};
|
|
380
|
+
return formatStr.replace(/yyyy|yy|MM|dd|hh|mm|ss|M|d|h|m|s/g, (key)=>map[key]);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
const replaceImgSrc = (html, callback)=>{
|
|
384
|
+
let lastedHtml = html;
|
|
385
|
+
const isImageTag = (node)=>"tag" === node.type && "img" === node.name;
|
|
386
|
+
const traverseDom = (node)=>{
|
|
387
|
+
if (__WEBPACK_EXTERNAL_MODULE_htmlparser2__.DomUtils.hasChildren(node)) for (const child of node.children){
|
|
388
|
+
if (isImageTag(child)) callback(child);
|
|
389
|
+
traverseDom(child);
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
const handler = new __WEBPACK_EXTERNAL_MODULE_domhandler__.DomHandler((error, dom)=>{
|
|
393
|
+
if (error) console.log(error);
|
|
394
|
+
else dom.forEach(traverseDom);
|
|
395
|
+
lastedHtml = (0, __WEBPACK_EXTERNAL_MODULE_dom_serializer_aa70940b__["default"])(dom, {
|
|
396
|
+
decodeEntities: false
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
const parser = new __WEBPACK_EXTERNAL_MODULE_htmlparser2__.Parser(handler, {
|
|
400
|
+
decodeEntities: false
|
|
401
|
+
});
|
|
402
|
+
parser.write(html);
|
|
403
|
+
parser.end();
|
|
404
|
+
return lastedHtml;
|
|
405
|
+
};
|
|
406
|
+
const stringifyError = (error)=>{
|
|
407
|
+
if (error instanceof Error) return error.toString();
|
|
408
|
+
if ("object" == typeof error) return JSON.stringify(error);
|
|
409
|
+
return error;
|
|
410
|
+
};
|
|
411
|
+
const executeAction = (...actions)=>async (task, params)=>{
|
|
412
|
+
let result = {
|
|
413
|
+
code: 500,
|
|
414
|
+
message: "",
|
|
415
|
+
data: null
|
|
416
|
+
};
|
|
417
|
+
for(let index = 0; index < actions.length; index++){
|
|
418
|
+
const action = actions[index];
|
|
419
|
+
try {
|
|
420
|
+
result = await action(task, params);
|
|
421
|
+
} catch (error) {
|
|
422
|
+
result = http.e.handleApiError(error);
|
|
423
|
+
}
|
|
424
|
+
if (0 === result.code || 200 === result.code) break;
|
|
425
|
+
if (index !== actions.length - 1) task.logger.error(result.message, stringifyError(result.data), result.extra);
|
|
426
|
+
}
|
|
427
|
+
return result;
|
|
428
|
+
};
|
|
429
|
+
async function copyHtmlToClipboard(page, html, options = {
|
|
430
|
+
format: "text/html",
|
|
431
|
+
fallback: true
|
|
432
|
+
}) {
|
|
433
|
+
try {
|
|
434
|
+
await page.evaluate(async ({ htmlContent, format })=>{
|
|
435
|
+
const blob = new Blob([
|
|
436
|
+
htmlContent
|
|
437
|
+
], {
|
|
438
|
+
type: format
|
|
439
|
+
});
|
|
440
|
+
await navigator.clipboard.write([
|
|
441
|
+
new ClipboardItem({
|
|
442
|
+
[format]: blob
|
|
443
|
+
})
|
|
444
|
+
]);
|
|
445
|
+
}, {
|
|
446
|
+
htmlContent: html,
|
|
447
|
+
format: options.format
|
|
448
|
+
});
|
|
449
|
+
} catch (error) {
|
|
450
|
+
if (options.fallback) await page.evaluate((htmlContent)=>{
|
|
451
|
+
const div = document.createElement("div");
|
|
452
|
+
div.contentEditable = "true";
|
|
453
|
+
div.style.cssText = `
|
|
454
|
+
position: fixed;
|
|
455
|
+
left: -9999px;
|
|
456
|
+
opacity: 0;
|
|
457
|
+
pointer-events: none;
|
|
458
|
+
`;
|
|
459
|
+
div.innerHTML = htmlContent;
|
|
460
|
+
document.body.appendChild(div);
|
|
461
|
+
const range = document.createRange();
|
|
462
|
+
range.selectNodeContents(div);
|
|
463
|
+
const selection = window.getSelection();
|
|
464
|
+
selection.removeAllRanges();
|
|
465
|
+
selection.addRange(range);
|
|
466
|
+
document.execCommand("copy");
|
|
467
|
+
document.body.removeChild(div);
|
|
468
|
+
selection.removeAllRanges();
|
|
469
|
+
}, html);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
function PopupListener(page, popupSelector, popKey, buttonSelector, options = {}) {
|
|
473
|
+
const { checkInterval = 1000, stopAfterClick = false } = options;
|
|
474
|
+
const popup = page.locator(popupSelector);
|
|
475
|
+
const button = page.locator(buttonSelector);
|
|
476
|
+
const intervalId = setInterval(async ()=>{
|
|
477
|
+
try {
|
|
478
|
+
if (await popup.count() > 0 && await popup.isVisible() && (await popup.textContent() || "").includes(popKey)) {
|
|
479
|
+
await button.click({
|
|
480
|
+
force: true
|
|
481
|
+
});
|
|
482
|
+
if (stopAfterClick) clearInterval(intervalId);
|
|
483
|
+
}
|
|
484
|
+
} catch (err) {}
|
|
485
|
+
}, checkInterval);
|
|
486
|
+
return ()=>{
|
|
487
|
+
clearInterval(intervalId);
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
const parseUrlQueryString = (url)=>{
|
|
491
|
+
const queryStringObject = {};
|
|
492
|
+
if (!url || !url.includes("?")) return queryStringObject;
|
|
493
|
+
const queryString = url.split("?")[1];
|
|
494
|
+
if (!queryString) return queryStringObject;
|
|
495
|
+
const queryWithoutHash = queryString.split("#")[0];
|
|
496
|
+
const queryStringArray = queryWithoutHash.split("&");
|
|
497
|
+
for (const item of queryStringArray){
|
|
498
|
+
if (!item) continue;
|
|
499
|
+
const equalIndex = item.indexOf("=");
|
|
500
|
+
if (-1 === equalIndex) queryStringObject[item] = "";
|
|
501
|
+
else {
|
|
502
|
+
const key = item.slice(0, equalIndex);
|
|
503
|
+
const value = item.slice(equalIndex + 1);
|
|
504
|
+
try {
|
|
505
|
+
queryStringObject[key] = decodeURIComponent(value);
|
|
506
|
+
} catch (e) {
|
|
507
|
+
queryStringObject[key] = value;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
return queryStringObject;
|
|
512
|
+
};
|
|
513
|
+
const defaultParams = (params, defaults)=>Object.assign({}, defaults, params);
|
|
514
|
+
},
|
|
13
515
|
"./src/utils/ttABEncrypt.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
14
516
|
module = __webpack_require__.nmd(module);
|
|
15
517
|
const a0_0x45db08 = a0_0x4b0d;
|
|
@@ -1091,6 +1593,73 @@ var __webpack_modules__ = {
|
|
|
1091
1593
|
return Data2A_B(Base2Data(EnvData2CharCode(_0x315138, _0x1c32b3, _0x56536b)));
|
|
1092
1594
|
}
|
|
1093
1595
|
module[a0_0x45db08(0xae)] = GenAB;
|
|
1596
|
+
},
|
|
1597
|
+
"./src/utils/xhsXsEncrypt.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1598
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1599
|
+
H: ()=>XsEncrypt
|
|
1600
|
+
});
|
|
1601
|
+
class XsEncrypt {
|
|
1602
|
+
async encryptMD5(url) {
|
|
1603
|
+
return __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createHash("md5").update(url, "utf8").digest("hex");
|
|
1604
|
+
}
|
|
1605
|
+
async encryptText(text) {
|
|
1606
|
+
const textEncoded = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(text).toString("base64");
|
|
1607
|
+
const cipher = __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createCipheriv("aes-128-cbc", new Uint8Array(this.keyBytes), new Uint8Array(this.iv));
|
|
1608
|
+
const ciphertext = cipher.update(textEncoded, "utf8", "base64");
|
|
1609
|
+
return ciphertext + cipher.final("base64");
|
|
1610
|
+
}
|
|
1611
|
+
async base64ToHex(encodedData) {
|
|
1612
|
+
const decodedData = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(encodedData, "base64");
|
|
1613
|
+
return decodedData.toString("hex");
|
|
1614
|
+
}
|
|
1615
|
+
async encryptPayload(payload, platform) {
|
|
1616
|
+
const hexPayload = await this.base64ToHex(payload);
|
|
1617
|
+
const obj = {
|
|
1618
|
+
signSvn: "56",
|
|
1619
|
+
signType: "x2",
|
|
1620
|
+
appID: platform,
|
|
1621
|
+
signVersion: "1",
|
|
1622
|
+
payload: hexPayload
|
|
1623
|
+
};
|
|
1624
|
+
const jsonString = JSON.stringify(obj, null, 0);
|
|
1625
|
+
return __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(jsonString).toString("base64");
|
|
1626
|
+
}
|
|
1627
|
+
async encryptXs(url, a1, ts, platform = "xhs-pc-web") {
|
|
1628
|
+
const text = `x1=${await this.encryptMD5(`url=${url}`)};x2=0|0|0|1|0|0|1|0|0|0|1|0|0|0|0|1|0|0|0;x3=${a1};x4=${ts};`;
|
|
1629
|
+
return `XYW_${await this.encryptPayload(await this.encryptText(text), platform)}`;
|
|
1630
|
+
}
|
|
1631
|
+
dumps(...rest) {
|
|
1632
|
+
const [data, replacer = null, space = 0] = rest;
|
|
1633
|
+
return JSON.stringify(data, replacer, space).replace(/\n/g, "").replace(/":\s+"/g, '":"');
|
|
1634
|
+
}
|
|
1635
|
+
constructor(){
|
|
1636
|
+
this.words = [
|
|
1637
|
+
929260340,
|
|
1638
|
+
1633971297,
|
|
1639
|
+
895580464,
|
|
1640
|
+
925905270
|
|
1641
|
+
];
|
|
1642
|
+
this.keyBytes = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.concat(this.words.map((word)=>new Uint8Array(__WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from([
|
|
1643
|
+
word >> 24 & 0xff,
|
|
1644
|
+
word >> 16 & 0xff,
|
|
1645
|
+
word >> 8 & 0xff,
|
|
1646
|
+
0xff & word
|
|
1647
|
+
]))));
|
|
1648
|
+
this.iv = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from("4uzjr7mbsibcaldp", "utf8");
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
},
|
|
1652
|
+
"@iflyrpa/share": function(module) {
|
|
1653
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__;
|
|
1654
|
+
},
|
|
1655
|
+
axios: function(module) {
|
|
1656
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_axios__;
|
|
1657
|
+
},
|
|
1658
|
+
"node:fs": function(module) {
|
|
1659
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
|
|
1660
|
+
},
|
|
1661
|
+
"node:path": function(module) {
|
|
1662
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__;
|
|
1094
1663
|
}
|
|
1095
1664
|
};
|
|
1096
1665
|
var __webpack_module_cache__ = {};
|
|
@@ -1106,6 +1675,19 @@ function __webpack_require__(moduleId) {
|
|
|
1106
1675
|
module.loaded = true;
|
|
1107
1676
|
return module.exports;
|
|
1108
1677
|
}
|
|
1678
|
+
(()=>{
|
|
1679
|
+
__webpack_require__.d = function(exports, definition) {
|
|
1680
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
1681
|
+
enumerable: true,
|
|
1682
|
+
get: definition[key]
|
|
1683
|
+
});
|
|
1684
|
+
};
|
|
1685
|
+
})();
|
|
1686
|
+
(()=>{
|
|
1687
|
+
__webpack_require__.o = function(obj, prop) {
|
|
1688
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
1689
|
+
};
|
|
1690
|
+
})();
|
|
1109
1691
|
(()=>{
|
|
1110
1692
|
__webpack_require__.nmd = function(module) {
|
|
1111
1693
|
module.paths = [];
|
|
@@ -1113,258 +1695,11 @@ function __webpack_require__(moduleId) {
|
|
|
1113
1695
|
return module;
|
|
1114
1696
|
};
|
|
1115
1697
|
})();
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
message: "",
|
|
1122
|
-
data: error
|
|
1123
|
-
};
|
|
1124
|
-
}
|
|
1125
|
-
constructor(config){
|
|
1126
|
-
this.apiClient = __WEBPACK_EXTERNAL_MODULE_axios__["default"].create(config);
|
|
1127
|
-
}
|
|
1128
|
-
addResponseInterceptor(findError) {
|
|
1129
|
-
this.apiClient.interceptors.response.use((response)=>{
|
|
1130
|
-
const error = findError(response);
|
|
1131
|
-
if (error) return Promise.reject(Object.assign(error, {
|
|
1132
|
-
extra: {
|
|
1133
|
-
method: response.config.method,
|
|
1134
|
-
url: response.config.url
|
|
1135
|
-
}
|
|
1136
|
-
}));
|
|
1137
|
-
return response;
|
|
1138
|
-
}, (error)=>{
|
|
1139
|
-
const errorResponse = {
|
|
1140
|
-
code: error.response?.status || 500,
|
|
1141
|
-
message: error.message || "",
|
|
1142
|
-
data: error.response?.data,
|
|
1143
|
-
extra: {
|
|
1144
|
-
method: error.config?.method,
|
|
1145
|
-
url: error.config?.url
|
|
1146
|
-
}
|
|
1147
|
-
};
|
|
1148
|
-
if (error.response?.data) {
|
|
1149
|
-
if ("object" == typeof error.response.data) {
|
|
1150
|
-
const serverError = error.response.data;
|
|
1151
|
-
if (serverError.message) errorResponse.message = serverError.message;
|
|
1152
|
-
errorResponse.data = serverError;
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
return Promise.reject(errorResponse);
|
|
1156
|
-
});
|
|
1157
|
-
}
|
|
1158
|
-
async api(config) {
|
|
1159
|
-
try {
|
|
1160
|
-
const response = await this.apiClient(config);
|
|
1161
|
-
return response.data;
|
|
1162
|
-
} catch (error) {
|
|
1163
|
-
return Promise.reject(Http.handleApiError(error));
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
function getRandomInRange(min, max) {
|
|
1168
|
-
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
1169
|
-
}
|
|
1170
|
-
const getFileState = (filePath)=>{
|
|
1171
|
-
const filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filePath);
|
|
1172
|
-
const fileType = __WEBPACK_EXTERNAL_MODULE_mime_types_eebf54a5__["default"].lookup(filePath);
|
|
1173
|
-
const stats = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].statSync(filePath);
|
|
1174
|
-
const fileSize = stats.size;
|
|
1175
|
-
const lastModifiedDate = stats.mtime;
|
|
1176
|
-
return {
|
|
1177
|
-
name: filename,
|
|
1178
|
-
type: fileType,
|
|
1179
|
-
size: fileSize,
|
|
1180
|
-
lastModifiedDate: lastModifiedDate.toString()
|
|
1181
|
-
};
|
|
1182
|
-
};
|
|
1183
|
-
const calculateCropCoordinates = (width, height, aspectRatio)=>{
|
|
1184
|
-
const targetRatio = aspectRatio[0] / aspectRatio[1];
|
|
1185
|
-
let cropWidth;
|
|
1186
|
-
let cropHeight;
|
|
1187
|
-
if (width / height > targetRatio) {
|
|
1188
|
-
cropHeight = height;
|
|
1189
|
-
cropWidth = height * targetRatio;
|
|
1190
|
-
} else {
|
|
1191
|
-
cropWidth = width;
|
|
1192
|
-
cropHeight = width / targetRatio;
|
|
1193
|
-
}
|
|
1194
|
-
const x1 = (width - cropWidth) / 2;
|
|
1195
|
-
const y1 = (height - cropHeight) / 2;
|
|
1196
|
-
const x2 = x1 + cropWidth;
|
|
1197
|
-
const y2 = y1 + cropHeight;
|
|
1198
|
-
return {
|
|
1199
|
-
x1: x1 / width,
|
|
1200
|
-
y1: y1 / height,
|
|
1201
|
-
x2: x2 / width,
|
|
1202
|
-
y2: y2 / height
|
|
1203
|
-
};
|
|
1204
|
-
};
|
|
1205
|
-
const extractImgTag = (html)=>{
|
|
1206
|
-
const srcList = [];
|
|
1207
|
-
const parser = new __WEBPACK_EXTERNAL_MODULE_htmlparser2__.Parser({
|
|
1208
|
-
onopentag (name, attributes) {
|
|
1209
|
-
if ("img" === name && (attributes.src.trim() || attributes.currentSrc.trim())) srcList.push(attributes.src.trim() || attributes.currentSrc.trim());
|
|
1210
|
-
}
|
|
1211
|
-
});
|
|
1212
|
-
parser.write(html);
|
|
1213
|
-
parser.end();
|
|
1214
|
-
return srcList;
|
|
1215
|
-
};
|
|
1216
|
-
class TimeFormatter {
|
|
1217
|
-
static format(timestamp, formatStr = 'yyyy-MM-dd hh:mm') {
|
|
1218
|
-
if ('number' == typeof timestamp && 10 === timestamp.toString().length) timestamp *= 1000;
|
|
1219
|
-
const date = new Date(timestamp);
|
|
1220
|
-
const map = {
|
|
1221
|
-
yyyy: String(date.getFullYear()),
|
|
1222
|
-
yy: String(date.getFullYear()).slice(-2),
|
|
1223
|
-
MM: String(date.getMonth() + 1).padStart(2, '0'),
|
|
1224
|
-
dd: String(date.getDate()).padStart(2, '0'),
|
|
1225
|
-
hh: String(date.getHours()).padStart(2, '0'),
|
|
1226
|
-
mm: String(date.getMinutes()).padStart(2, '0'),
|
|
1227
|
-
ss: String(date.getSeconds()).padStart(2, '0'),
|
|
1228
|
-
M: String(date.getMonth() + 1),
|
|
1229
|
-
d: String(date.getDate()),
|
|
1230
|
-
h: String(date.getHours()),
|
|
1231
|
-
m: String(date.getMinutes()),
|
|
1232
|
-
s: String(date.getSeconds())
|
|
1233
|
-
};
|
|
1234
|
-
return formatStr.replace(/yyyy|yy|MM|dd|hh|mm|ss|M|d|h|m|s/g, (key)=>map[key]);
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
const replaceImgSrc = (html, callback)=>{
|
|
1238
|
-
let lastedHtml = html;
|
|
1239
|
-
const isImageTag = (node)=>"tag" === node.type && "img" === node.name;
|
|
1240
|
-
const traverseDom = (node)=>{
|
|
1241
|
-
if (__WEBPACK_EXTERNAL_MODULE_htmlparser2__.DomUtils.hasChildren(node)) for (const child of node.children){
|
|
1242
|
-
if (isImageTag(child)) callback(child);
|
|
1243
|
-
traverseDom(child);
|
|
1244
|
-
}
|
|
1245
|
-
};
|
|
1246
|
-
const handler = new __WEBPACK_EXTERNAL_MODULE_domhandler__.DomHandler((error, dom)=>{
|
|
1247
|
-
if (error) console.log(error);
|
|
1248
|
-
else dom.forEach(traverseDom);
|
|
1249
|
-
lastedHtml = (0, __WEBPACK_EXTERNAL_MODULE_dom_serializer_aa70940b__["default"])(dom, {
|
|
1250
|
-
decodeEntities: false
|
|
1251
|
-
});
|
|
1252
|
-
});
|
|
1253
|
-
const parser = new __WEBPACK_EXTERNAL_MODULE_htmlparser2__.Parser(handler, {
|
|
1254
|
-
decodeEntities: false
|
|
1255
|
-
});
|
|
1256
|
-
parser.write(html);
|
|
1257
|
-
parser.end();
|
|
1258
|
-
return lastedHtml;
|
|
1259
|
-
};
|
|
1260
|
-
const stringifyError = (error)=>{
|
|
1261
|
-
if (error instanceof Error) return error.toString();
|
|
1262
|
-
if ("object" == typeof error) return JSON.stringify(error);
|
|
1263
|
-
return error;
|
|
1264
|
-
};
|
|
1265
|
-
const executeAction = (...actions)=>async (task, params)=>{
|
|
1266
|
-
let result = {
|
|
1267
|
-
code: 500,
|
|
1268
|
-
message: "",
|
|
1269
|
-
data: null
|
|
1270
|
-
};
|
|
1271
|
-
for(let index = 0; index < actions.length; index++){
|
|
1272
|
-
const action = actions[index];
|
|
1273
|
-
try {
|
|
1274
|
-
result = await action(task, params);
|
|
1275
|
-
} catch (error) {
|
|
1276
|
-
result = Http.handleApiError(error);
|
|
1277
|
-
}
|
|
1278
|
-
if (0 === result.code || 200 === result.code) break;
|
|
1279
|
-
if (index !== actions.length - 1) task.logger.error(result.message, stringifyError(result.data), result.extra);
|
|
1280
|
-
}
|
|
1281
|
-
return result;
|
|
1282
|
-
};
|
|
1283
|
-
async function copyHtmlToClipboard(page, html, options = {
|
|
1284
|
-
format: "text/html",
|
|
1285
|
-
fallback: true
|
|
1286
|
-
}) {
|
|
1287
|
-
try {
|
|
1288
|
-
await page.evaluate(async ({ htmlContent, format })=>{
|
|
1289
|
-
const blob = new Blob([
|
|
1290
|
-
htmlContent
|
|
1291
|
-
], {
|
|
1292
|
-
type: format
|
|
1293
|
-
});
|
|
1294
|
-
await navigator.clipboard.write([
|
|
1295
|
-
new ClipboardItem({
|
|
1296
|
-
[format]: blob
|
|
1297
|
-
})
|
|
1298
|
-
]);
|
|
1299
|
-
}, {
|
|
1300
|
-
htmlContent: html,
|
|
1301
|
-
format: options.format
|
|
1302
|
-
});
|
|
1303
|
-
} catch (error) {
|
|
1304
|
-
if (options.fallback) await page.evaluate((htmlContent)=>{
|
|
1305
|
-
const div = document.createElement("div");
|
|
1306
|
-
div.contentEditable = "true";
|
|
1307
|
-
div.style.cssText = `
|
|
1308
|
-
position: fixed;
|
|
1309
|
-
left: -9999px;
|
|
1310
|
-
opacity: 0;
|
|
1311
|
-
pointer-events: none;
|
|
1312
|
-
`;
|
|
1313
|
-
div.innerHTML = htmlContent;
|
|
1314
|
-
document.body.appendChild(div);
|
|
1315
|
-
const range = document.createRange();
|
|
1316
|
-
range.selectNodeContents(div);
|
|
1317
|
-
const selection = window.getSelection();
|
|
1318
|
-
selection.removeAllRanges();
|
|
1319
|
-
selection.addRange(range);
|
|
1320
|
-
document.execCommand("copy");
|
|
1321
|
-
document.body.removeChild(div);
|
|
1322
|
-
selection.removeAllRanges();
|
|
1323
|
-
}, html);
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
function PopupListener(page, popupSelector, popKey, buttonSelector, options = {}) {
|
|
1327
|
-
const { checkInterval = 1000, stopAfterClick = false } = options;
|
|
1328
|
-
const popup = page.locator(popupSelector);
|
|
1329
|
-
const button = page.locator(buttonSelector);
|
|
1330
|
-
const intervalId = setInterval(async ()=>{
|
|
1331
|
-
try {
|
|
1332
|
-
if (await popup.count() > 0 && await popup.isVisible() && (await popup.textContent() || "").includes(popKey)) {
|
|
1333
|
-
await button.click({
|
|
1334
|
-
force: true
|
|
1335
|
-
});
|
|
1336
|
-
if (stopAfterClick) clearInterval(intervalId);
|
|
1337
|
-
}
|
|
1338
|
-
} catch (err) {}
|
|
1339
|
-
}, checkInterval);
|
|
1340
|
-
return ()=>{
|
|
1341
|
-
clearInterval(intervalId);
|
|
1342
|
-
};
|
|
1343
|
-
}
|
|
1344
|
-
const parseUrlQueryString = (url)=>{
|
|
1345
|
-
const queryStringObject = {};
|
|
1346
|
-
if (!url || !url.includes("?")) return queryStringObject;
|
|
1347
|
-
const queryString = url.split("?")[1];
|
|
1348
|
-
if (!queryString) return queryStringObject;
|
|
1349
|
-
const queryWithoutHash = queryString.split("#")[0];
|
|
1350
|
-
const queryStringArray = queryWithoutHash.split("&");
|
|
1351
|
-
for (const item of queryStringArray){
|
|
1352
|
-
if (!item) continue;
|
|
1353
|
-
const equalIndex = item.indexOf("=");
|
|
1354
|
-
if (-1 === equalIndex) queryStringObject[item] = "";
|
|
1355
|
-
else {
|
|
1356
|
-
const key = item.slice(0, equalIndex);
|
|
1357
|
-
const value = item.slice(equalIndex + 1);
|
|
1358
|
-
try {
|
|
1359
|
-
queryStringObject[key] = decodeURIComponent(value);
|
|
1360
|
-
} catch (e) {
|
|
1361
|
-
queryStringObject[key] = value;
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
return queryStringObject;
|
|
1366
|
-
};
|
|
1367
|
-
const defaultParams = (params, defaults)=>Object.assign({}, defaults, params);
|
|
1698
|
+
var utils = __webpack_require__("./src/utils/index.ts");
|
|
1699
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
1700
|
+
var external_node_path_ = __webpack_require__("node:path");
|
|
1701
|
+
var share_ = __webpack_require__("@iflyrpa/share");
|
|
1702
|
+
var utils_http = __webpack_require__("./src/utils/http.ts");
|
|
1368
1703
|
const errnoMap = {
|
|
1369
1704
|
20040706: "正文图片和封面图片推荐jpg、png格式。",
|
|
1370
1705
|
20040084: "正文图片和封面图片推荐jpg、png格式。",
|
|
@@ -1377,12 +1712,13 @@ const errnoMap = {
|
|
|
1377
1712
|
2004005714: "网络环境异常,请检查网络后重试发布。",
|
|
1378
1713
|
401100032: "异常,请检查图片(如:格式、版权、合规性等)。",
|
|
1379
1714
|
20040034: "封面图片推荐jpg、png格式,不支持gif格式。",
|
|
1380
|
-
20040124: "服务器异常,请稍后重试!"
|
|
1715
|
+
20040124: "服务器异常,请稍后重试!",
|
|
1716
|
+
20040001: "当前用户未登录,请登陆后重试!"
|
|
1381
1717
|
};
|
|
1382
1718
|
const mockAction = async (task, params)=>{
|
|
1383
1719
|
const { baijiahaoSingleCover, baijiahaoMultCover, baijiahaoCoverType } = params.settingInfo;
|
|
1384
1720
|
const tmpCachePath = task.getTmpPath();
|
|
1385
|
-
const http = new
|
|
1721
|
+
const http = new utils_http.e({
|
|
1386
1722
|
headers: {
|
|
1387
1723
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1388
1724
|
token: params.token
|
|
@@ -1416,8 +1752,8 @@ const mockAction = async (task, params)=>{
|
|
|
1416
1752
|
const uploadImages = async (_images)=>{
|
|
1417
1753
|
const images = _images.filter((url)=>!!url && "" !== url.trim());
|
|
1418
1754
|
return await Promise.all(images.map(async (url)=>{
|
|
1419
|
-
const fileName = (0,
|
|
1420
|
-
const image = await (0,
|
|
1755
|
+
const fileName = (0, share_.getFilenameFromUrl)(url);
|
|
1756
|
+
const image = await (0, share_.downloadImage)(url, external_node_path_["default"].join(tmpCachePath, fileName));
|
|
1421
1757
|
const formData = new __WEBPACK_EXTERNAL_MODULE_form_data_cf000082__["default"]();
|
|
1422
1758
|
formData.append("org_file_name", fileName);
|
|
1423
1759
|
formData.append("type", "image");
|
|
@@ -1426,7 +1762,7 @@ const mockAction = async (task, params)=>{
|
|
|
1426
1762
|
formData.append("save_material", "1");
|
|
1427
1763
|
formData.append("no_compress", "0");
|
|
1428
1764
|
formData.append("article_type", "news");
|
|
1429
|
-
formData.append("media",
|
|
1765
|
+
formData.append("media", external_node_fs_["default"].createReadStream(image));
|
|
1430
1766
|
const res = await http.api({
|
|
1431
1767
|
method: "post",
|
|
1432
1768
|
url: "https://baijiahao.baidu.com/materialui/picture/uploadProxy",
|
|
@@ -1436,9 +1772,9 @@ const mockAction = async (task, params)=>{
|
|
|
1436
1772
|
return res.ret;
|
|
1437
1773
|
}));
|
|
1438
1774
|
};
|
|
1439
|
-
const originContentImages =
|
|
1775
|
+
const originContentImages = (0, utils.E_)(params.content);
|
|
1440
1776
|
const targetContentImages = await uploadImages(originContentImages);
|
|
1441
|
-
const content =
|
|
1777
|
+
const content = (0, utils.I)(params.content, (dom)=>{
|
|
1442
1778
|
if (dom.attribs.src) {
|
|
1443
1779
|
const idx = originContentImages.findIndex((it)=>it === dom.attribs.src);
|
|
1444
1780
|
dom.attribs.src = targetContentImages[idx].bos_url;
|
|
@@ -1513,7 +1849,7 @@ const mockAction = async (task, params)=>{
|
|
|
1513
1849
|
},
|
|
1514
1850
|
defaultErrorMsg: isDraft ? "文章同步出现异常,请稍后重试。" : "文章发布出现异常,请稍后重试。"
|
|
1515
1851
|
});
|
|
1516
|
-
return (0,
|
|
1852
|
+
return (0, share_.success)(res.ret.article_id, "百家号发布完成。");
|
|
1517
1853
|
};
|
|
1518
1854
|
const rpaAction = async (task, params)=>{
|
|
1519
1855
|
const tmpCachePath = task.getTmpPath();
|
|
@@ -1551,7 +1887,7 @@ const rpaAction = async (task, params)=>{
|
|
|
1551
1887
|
const titleInstance = page.locator("#ueditor #bjhNewsTitle .input-box textarea");
|
|
1552
1888
|
await titleInstance.click();
|
|
1553
1889
|
await titleInstance.fill(params.title);
|
|
1554
|
-
await
|
|
1890
|
+
await (0, utils.qN)(page, params.content);
|
|
1555
1891
|
await page.click("#ueditor .edui-editor-iframeholder iframe");
|
|
1556
1892
|
await page.keyboard.press("Control+A");
|
|
1557
1893
|
await page.keyboard.press("Control+V");
|
|
@@ -1567,8 +1903,8 @@ const rpaAction = async (task, params)=>{
|
|
|
1567
1903
|
const images = await Promise.all((isSingleCover ? [
|
|
1568
1904
|
params.settingInfo.baijiahaoSingleCover
|
|
1569
1905
|
] : params.settingInfo.baijiahaoMultCover).map((url)=>{
|
|
1570
|
-
const fileName = (0,
|
|
1571
|
-
return (0,
|
|
1906
|
+
const fileName = (0, share_.getFilenameFromUrl)(url);
|
|
1907
|
+
return (0, share_.downloadImage)(url, external_node_path_["default"].join(tmpCachePath, fileName));
|
|
1572
1908
|
}));
|
|
1573
1909
|
const coverSelector = page.locator(".cheetah-form-item-control .edit-cover-container .cover-list .DraggableTags-tag-drag .coverUploaderView");
|
|
1574
1910
|
const coverCount = await coverSelector.count();
|
|
@@ -1651,7 +1987,7 @@ const rpaAction = async (task, params)=>{
|
|
|
1651
1987
|
hasText: "日"
|
|
1652
1988
|
}).click();
|
|
1653
1989
|
await page.locator('#select-date_list + * .cheetah-select-item-option', {
|
|
1654
|
-
hasText:
|
|
1990
|
+
hasText: utils.Tx.format(params.settingInfo.timer, "M月dd日")
|
|
1655
1991
|
}).click();
|
|
1656
1992
|
await page.waitForTimeout(200);
|
|
1657
1993
|
await page.locator(".timepublish-wrap-select .select-wrap", {
|
|
@@ -1672,7 +2008,7 @@ const rpaAction = async (task, params)=>{
|
|
|
1672
2008
|
let fistHourElemH = Number(fistHourElem?.split("点")[0]);
|
|
1673
2009
|
const lastHourElem = scrollHourInfo.elementItem[scrollHourInfo.elementItem.length - 1];
|
|
1674
2010
|
let lastHourElemH = Number(lastHourElem?.split("点")[0]);
|
|
1675
|
-
let targetTimeH = Number(
|
|
2011
|
+
let targetTimeH = Number(utils.Tx.format(params.settingInfo.timer, 'h'));
|
|
1676
2012
|
await page.mouse.wheel(0, targetTimeH > lastHourElemH ? (targetTimeH - lastHourElemH) * scrollHourInfo.elementHeight : targetTimeH < fistHourElemH ? -(fistHourElemH - targetTimeH) * scrollHourInfo.elementHeight : 0);
|
|
1677
2013
|
await page.locator("#select-hour_list + * .cheetah-select-item-option ", {
|
|
1678
2014
|
hasText: targetTimeH + "点"
|
|
@@ -1696,7 +2032,7 @@ const rpaAction = async (task, params)=>{
|
|
|
1696
2032
|
let fistMinuteElemH = Number(fistMinuteElem?.split("分")[0]);
|
|
1697
2033
|
const lastMinuteElem = scrollMinuteInfo.elementItem[scrollMinuteInfo.elementItem.length - 1];
|
|
1698
2034
|
let lastMinuteElemH = Number(lastMinuteElem?.split("分")[0]);
|
|
1699
|
-
let targetTimeM = Number(
|
|
2035
|
+
let targetTimeM = Number(utils.Tx.format(params.settingInfo.timer, 'm'));
|
|
1700
2036
|
await page.mouse.wheel(0, targetTimeM > lastMinuteElemH ? (targetTimeM - lastMinuteElemH) * scrollMinuteInfo.elementHeight : targetTimeM < fistMinuteElemH ? -(fistMinuteElemH - targetTimeM) * scrollMinuteInfo.elementHeight : 0);
|
|
1701
2037
|
await page.locator("#select-minute_list + * .cheetah-select-item-option ", {
|
|
1702
2038
|
hasText: targetTimeM + "分"
|
|
@@ -1710,16 +2046,16 @@ const rpaAction = async (task, params)=>{
|
|
|
1710
2046
|
}).locator("button").click();
|
|
1711
2047
|
});
|
|
1712
2048
|
await page.close();
|
|
1713
|
-
return (0,
|
|
2049
|
+
return (0, share_.success)(articleId, articleId ? "发布成功" : message);
|
|
1714
2050
|
};
|
|
1715
2051
|
const baijiahaoPublish = async (task, params)=>{
|
|
1716
2052
|
if ("rpa" === params.actionType) return rpaAction(task, params);
|
|
1717
2053
|
if ("mockApi" === params.actionType) return mockAction(task, params);
|
|
1718
|
-
return
|
|
2054
|
+
return (0, utils.jo)(mockAction, rpaAction)(task, params);
|
|
1719
2055
|
};
|
|
1720
2056
|
const getBaijiahaoActivity = async (_task, params)=>{
|
|
1721
2057
|
const cookies = params.cookies ?? [];
|
|
1722
|
-
const http = new
|
|
2058
|
+
const http = new utils_http.e({
|
|
1723
2059
|
headers: {
|
|
1724
2060
|
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1725
2061
|
token: params.token
|
|
@@ -1737,11 +2073,11 @@ const getBaijiahaoActivity = async (_task, params)=>{
|
|
|
1737
2073
|
task_type: -1
|
|
1738
2074
|
}
|
|
1739
2075
|
});
|
|
1740
|
-
return (0,
|
|
2076
|
+
return (0, share_.success)(res?.data?.list ?? []);
|
|
1741
2077
|
};
|
|
1742
2078
|
const getToutiaoConfig = async (_task, params)=>{
|
|
1743
2079
|
const cookies = params.cookies ?? [];
|
|
1744
|
-
const http = new
|
|
2080
|
+
const http = new utils_http.e({
|
|
1745
2081
|
headers: {
|
|
1746
2082
|
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1747
2083
|
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
@@ -1789,7 +2125,7 @@ const getToutiaoConfig = async (_task, params)=>{
|
|
|
1789
2125
|
getCityDistrict(),
|
|
1790
2126
|
getUserRights()
|
|
1791
2127
|
]);
|
|
1792
|
-
return (0,
|
|
2128
|
+
return (0, share_.success)({
|
|
1793
2129
|
suggestWords,
|
|
1794
2130
|
cityDistrict,
|
|
1795
2131
|
userRights
|
|
@@ -1797,7 +2133,7 @@ const getToutiaoConfig = async (_task, params)=>{
|
|
|
1797
2133
|
};
|
|
1798
2134
|
const getBaijiahaoConfig = async (_task, params)=>{
|
|
1799
2135
|
const cookies = params.cookies ?? [];
|
|
1800
|
-
const http = new
|
|
2136
|
+
const http = new utils_http.e({
|
|
1801
2137
|
headers: {
|
|
1802
2138
|
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1803
2139
|
token: params.token
|
|
@@ -1810,15 +2146,23 @@ const getBaijiahaoConfig = async (_task, params)=>{
|
|
|
1810
2146
|
type: "news"
|
|
1811
2147
|
}
|
|
1812
2148
|
});
|
|
1813
|
-
|
|
2149
|
+
const data = res?.data?.article.activity_list.map((_item)=>({
|
|
1814
2150
|
id: _item.id,
|
|
1815
2151
|
name: _item.name,
|
|
1816
2152
|
detail: _item.detail,
|
|
1817
2153
|
is_enable: _item.is_enable
|
|
1818
|
-
})) ?? []
|
|
2154
|
+
})) ?? [];
|
|
2155
|
+
data.push({
|
|
2156
|
+
id: "bjh_publish_num_left",
|
|
2157
|
+
name: "账号剩余发文数",
|
|
2158
|
+
detail: "",
|
|
2159
|
+
is_enable: 1,
|
|
2160
|
+
publish_num_left: res.data.ability.publish_num_left
|
|
2161
|
+
});
|
|
2162
|
+
return (0, share_.success)(data, "获取百家号配置项成功!");
|
|
1819
2163
|
};
|
|
1820
2164
|
const searchToutiaoTopicList = async (_task, params)=>{
|
|
1821
|
-
const http = new
|
|
2165
|
+
const http = new utils_http.e({
|
|
1822
2166
|
headers: {
|
|
1823
2167
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1824
2168
|
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
@@ -1833,14 +2177,14 @@ const searchToutiaoTopicList = async (_task, params)=>{
|
|
|
1833
2177
|
words: params.searchValue
|
|
1834
2178
|
}
|
|
1835
2179
|
});
|
|
1836
|
-
if (0 === res.code) return (0,
|
|
1837
|
-
return (0,
|
|
2180
|
+
if (0 === res.code) return (0, share_.success)(params.searchValue ? res.recents : res.hots);
|
|
2181
|
+
return (0, share_.success)([]);
|
|
1838
2182
|
} catch (error) {
|
|
1839
|
-
return (0,
|
|
2183
|
+
return (0, share_.success)([]);
|
|
1840
2184
|
}
|
|
1841
2185
|
};
|
|
1842
2186
|
const searchToutiaoLocation = async (_task, params)=>{
|
|
1843
|
-
const http = new
|
|
2187
|
+
const http = new utils_http.e({
|
|
1844
2188
|
headers: {
|
|
1845
2189
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1846
2190
|
referer: "https://mp.toutiao.com/profile_v4/graphic/publish",
|
|
@@ -1864,7 +2208,7 @@ const searchToutiaoLocation = async (_task, params)=>{
|
|
|
1864
2208
|
timestamp: Math.floor(Date.now() / 1000)
|
|
1865
2209
|
}
|
|
1866
2210
|
});
|
|
1867
|
-
if (200 === res.code) return (0,
|
|
2211
|
+
if (200 === res.code) return (0, share_.success)(res.data.poi.map((item)=>({
|
|
1868
2212
|
position: item.name,
|
|
1869
2213
|
city: item.city,
|
|
1870
2214
|
longitude: item.longitude,
|
|
@@ -1872,13 +2216,13 @@ const searchToutiaoLocation = async (_task, params)=>{
|
|
|
1872
2216
|
type_code: item.type_code,
|
|
1873
2217
|
poi_id: item.id
|
|
1874
2218
|
})));
|
|
1875
|
-
return (0,
|
|
2219
|
+
return (0, share_.success)([]);
|
|
1876
2220
|
} catch (error) {
|
|
1877
|
-
return (0,
|
|
2221
|
+
return (0, share_.success)([]);
|
|
1878
2222
|
}
|
|
1879
2223
|
};
|
|
1880
2224
|
const searchToutiaoUserInfo = async (_task, params)=>{
|
|
1881
|
-
const http = new
|
|
2225
|
+
const http = new utils_http.e({
|
|
1882
2226
|
headers: {
|
|
1883
2227
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1884
2228
|
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
@@ -1894,19 +2238,19 @@ const searchToutiaoUserInfo = async (_task, params)=>{
|
|
|
1894
2238
|
app_name: "toutiao_mp"
|
|
1895
2239
|
}
|
|
1896
2240
|
});
|
|
1897
|
-
if (0 === res.err_no) return (0,
|
|
2241
|
+
if (0 === res.err_no) return (0, share_.success)(res.data.suggest.map((item)=>({
|
|
1898
2242
|
user_id: item.user.info.user_id,
|
|
1899
2243
|
name: item.user.info.name,
|
|
1900
2244
|
avatar_url: item.user.info.avatar_url,
|
|
1901
2245
|
followers_count: item.user.relation_count.followers_count
|
|
1902
2246
|
})), '搜索成功');
|
|
1903
|
-
return (0,
|
|
2247
|
+
return (0, share_.success)([]);
|
|
1904
2248
|
} catch (error) {
|
|
1905
|
-
return (0,
|
|
2249
|
+
return (0, share_.success)([]);
|
|
1906
2250
|
}
|
|
1907
2251
|
};
|
|
1908
2252
|
const searchXiaohongshuLocation = async (_task, params)=>{
|
|
1909
|
-
const http = new
|
|
2253
|
+
const http = new utils_http.e({
|
|
1910
2254
|
headers: {
|
|
1911
2255
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1912
2256
|
referer: "https://creator.xiaohongshu.com",
|
|
@@ -1927,13 +2271,13 @@ const searchXiaohongshuLocation = async (_task, params)=>{
|
|
|
1927
2271
|
type: 3
|
|
1928
2272
|
}
|
|
1929
2273
|
});
|
|
1930
|
-
return (0,
|
|
2274
|
+
return (0, share_.success)(0 === result.code ? result.data.poi_list : []);
|
|
1931
2275
|
} catch (error) {
|
|
1932
|
-
return (0,
|
|
2276
|
+
return (0, share_.success)([]);
|
|
1933
2277
|
}
|
|
1934
2278
|
};
|
|
1935
2279
|
const searchXiaohongshuTopicList = async (_task, params)=>{
|
|
1936
|
-
const http = new
|
|
2280
|
+
const http = new utils_http.e({
|
|
1937
2281
|
headers: {
|
|
1938
2282
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1939
2283
|
referer: "https://creator.xiaohongshu.com",
|
|
@@ -1957,9 +2301,9 @@ const searchXiaohongshuTopicList = async (_task, params)=>{
|
|
|
1957
2301
|
},
|
|
1958
2302
|
defaultErrorMsg: "话题搜索异常,请稍后重试。"
|
|
1959
2303
|
});
|
|
1960
|
-
return (0,
|
|
2304
|
+
return (0, share_.success)(0 === result.code ? result.data.topic_info_dtos : [], '获取话题成功');
|
|
1961
2305
|
} catch (error) {
|
|
1962
|
-
return (0,
|
|
2306
|
+
return (0, share_.success)([]);
|
|
1963
2307
|
}
|
|
1964
2308
|
};
|
|
1965
2309
|
const GenAB = __webpack_require__("./src/utils/ttABEncrypt.js");
|
|
@@ -1976,6 +2320,7 @@ const mock_errnoMap = {
|
|
|
1976
2320
|
2010: "无头条广告权限,请修改后重试。",
|
|
1977
2321
|
3103: "今日头条号发布次数已达上限,请明天再试。",
|
|
1978
2322
|
1053: "正文图片和封面图片推荐jpg、png格式。",
|
|
2323
|
+
1050: "图片上传失败,请重试上传。",
|
|
1979
2324
|
2005: "账号无【申明原创】权限,请关闭申明后重试。",
|
|
1980
2325
|
100004: "用户未登录或登陆已过期,请重新登陆后重试。"
|
|
1981
2326
|
};
|
|
@@ -1994,7 +2339,7 @@ const get3101DetailError = (errorList, message, saveType)=>{
|
|
|
1994
2339
|
const mock_mockAction = async (task, params)=>{
|
|
1995
2340
|
const { toutiaoSingleCover, toutiaoMultCover, toutiaoCoverType, toutiaoOriginal, toutiaoExclusive, toutiaoClaim } = params.settingInfo;
|
|
1996
2341
|
const tmpCachePath = task.getTmpPath();
|
|
1997
|
-
const http = new
|
|
2342
|
+
const http = new utils_http.e({
|
|
1998
2343
|
headers: {
|
|
1999
2344
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2000
2345
|
origin: "https://mp.toutiao.com",
|
|
@@ -2018,10 +2363,10 @@ const mock_mockAction = async (task, params)=>{
|
|
|
2018
2363
|
defaultErrorMsg: `头条号登录状态失效,请重新绑定账号后${"draft" === params.saveType ? "同步" : "发布"}。`
|
|
2019
2364
|
});
|
|
2020
2365
|
const uploadImages = async (images)=>await Promise.all(images.map(async (url)=>{
|
|
2021
|
-
const fileName = (0,
|
|
2022
|
-
const image = await (0,
|
|
2366
|
+
const fileName = (0, share_.getFilenameFromUrl)(url);
|
|
2367
|
+
const image = await (0, share_.downloadImage)(url, external_node_path_["default"].join(tmpCachePath, fileName));
|
|
2023
2368
|
const formData = new __WEBPACK_EXTERNAL_MODULE_form_data_cf000082__["default"]();
|
|
2024
|
-
formData.append("image",
|
|
2369
|
+
formData.append("image", external_node_fs_["default"].createReadStream(image));
|
|
2025
2370
|
const response = await http.api({
|
|
2026
2371
|
method: "post",
|
|
2027
2372
|
url: "https://mp.toutiao.com/spice/image?upload_source=20020002&aid=1231&device_platform=web",
|
|
@@ -2030,9 +2375,9 @@ const mock_mockAction = async (task, params)=>{
|
|
|
2030
2375
|
});
|
|
2031
2376
|
return response.data;
|
|
2032
2377
|
}));
|
|
2033
|
-
const originContentImages =
|
|
2378
|
+
const originContentImages = (0, utils.E_)(params.content);
|
|
2034
2379
|
const targetContentImages = await uploadImages(originContentImages);
|
|
2035
|
-
const content =
|
|
2380
|
+
const content = (0, utils.I)(params.content, (dom)=>{
|
|
2036
2381
|
if (dom.attribs.src) {
|
|
2037
2382
|
const idx = originContentImages.findIndex((it)=>it === dom.attribs.src);
|
|
2038
2383
|
dom.attribs.src = targetContentImages[idx].image_url;
|
|
@@ -2103,7 +2448,7 @@ const mock_mockAction = async (task, params)=>{
|
|
|
2103
2448
|
is_refute_rumor: 0,
|
|
2104
2449
|
save: "publish" === params.saveType ? 1 : 0,
|
|
2105
2450
|
timer_status: params.settingInfo.timer ? 1 : 0,
|
|
2106
|
-
timer_time: params.settingInfo.timer ?
|
|
2451
|
+
timer_time: params.settingInfo.timer ? utils.Tx.format(params.settingInfo.timer) : "",
|
|
2107
2452
|
title: params.title,
|
|
2108
2453
|
content: content + topicContent,
|
|
2109
2454
|
extra: JSON.stringify(extraData),
|
|
@@ -2158,7 +2503,7 @@ const mock_mockAction = async (task, params)=>{
|
|
|
2158
2503
|
defaultErrorMsg: "draft" === params.saveType ? "文章同步异常,请稍后重试。" : "文章发布异常,请稍后重试。"
|
|
2159
2504
|
};
|
|
2160
2505
|
const publishResult = await http.api(publishOption);
|
|
2161
|
-
return (0,
|
|
2506
|
+
return (0, share_.success)(publishResult.data.pgc_id);
|
|
2162
2507
|
};
|
|
2163
2508
|
const rpa_GenAB = __webpack_require__("./src/utils/ttABEncrypt.js");
|
|
2164
2509
|
const rpa_rpaAction = async (task, params)=>{
|
|
@@ -2222,14 +2567,14 @@ const rpa_rpaAction = async (task, params)=>{
|
|
|
2222
2567
|
});
|
|
2223
2568
|
} else await route.continue();
|
|
2224
2569
|
});
|
|
2225
|
-
|
|
2570
|
+
(0, utils.f8)(page, '.byte-modal.publish-exclusive-modal .title', "激励", '.byte-modal-close-icon', {
|
|
2226
2571
|
checkInterval: 1000,
|
|
2227
2572
|
stopAfterClick: false
|
|
2228
2573
|
});
|
|
2229
2574
|
const titleInstance = page.locator(".publish-editor-title-wrapper .publish-editor-title textarea");
|
|
2230
2575
|
await titleInstance.click();
|
|
2231
2576
|
await titleInstance.fill(params.title);
|
|
2232
|
-
await
|
|
2577
|
+
await (0, utils.qN)(page, params.content);
|
|
2233
2578
|
await page.click(".publish-editor .syl-editor-wrap .ProseMirror");
|
|
2234
2579
|
await page.keyboard.press("Control+V");
|
|
2235
2580
|
const coverTypeValue = COVER_TYPE[params.settingInfo.toutiaoCoverType];
|
|
@@ -2244,8 +2589,8 @@ const rpa_rpaAction = async (task, params)=>{
|
|
|
2244
2589
|
];
|
|
2245
2590
|
else if ("multiple" === params.settingInfo.toutiaoCoverType) coverUrls = params.settingInfo.toutiaoMultCover;
|
|
2246
2591
|
const images = await Promise.all(coverUrls.map((url)=>{
|
|
2247
|
-
const fileName = (0,
|
|
2248
|
-
return (0,
|
|
2592
|
+
const fileName = (0, share_.getFilenameFromUrl)(url);
|
|
2593
|
+
return (0, share_.downloadImage)(url, external_node_path_["default"].join(tmpCachePath, fileName));
|
|
2249
2594
|
}));
|
|
2250
2595
|
const coverUploadEle = coverContainer.locator(".article-cover .article-cover-images").locator(".article-cover-img-wrap, .article-cover-add");
|
|
2251
2596
|
const coverUploadCount = await coverUploadEle.count();
|
|
@@ -2276,7 +2621,7 @@ const rpa_rpaAction = async (task, params)=>{
|
|
|
2276
2621
|
state: "visible"
|
|
2277
2622
|
});
|
|
2278
2623
|
await confirmBtn.click();
|
|
2279
|
-
await page.waitForTimeout(
|
|
2624
|
+
await page.waitForTimeout((0, utils.i9)(500, 1000));
|
|
2280
2625
|
}
|
|
2281
2626
|
if (params.settingInfo.toutiaoLocation) {
|
|
2282
2627
|
const locationContainer = page.locator(".form-container .edit-cell").filter({
|
|
@@ -2345,17 +2690,17 @@ const rpa_rpaAction = async (task, params)=>{
|
|
|
2345
2690
|
});
|
|
2346
2691
|
await page.locator(".byte-modal-content .day-select .byte-select-view-value").click();
|
|
2347
2692
|
await page.locator('li.byte-select-option', {
|
|
2348
|
-
hasText:
|
|
2693
|
+
hasText: utils.Tx.format(params.settingInfo.timer, "MM月dd日")
|
|
2349
2694
|
}).click();
|
|
2350
2695
|
await page.waitForTimeout(200);
|
|
2351
2696
|
await page.locator(".byte-modal-content .hour-select .byte-select-view-value").click();
|
|
2352
2697
|
await page.locator('li.byte-select-option', {
|
|
2353
|
-
hasText:
|
|
2698
|
+
hasText: utils.Tx.format(params.settingInfo.timer, "h")
|
|
2354
2699
|
}).click();
|
|
2355
2700
|
await page.waitForTimeout(200);
|
|
2356
2701
|
await page.locator(".byte-modal-content .minute-select .byte-select-view-value").click();
|
|
2357
2702
|
await page.locator('li.byte-select-option', {
|
|
2358
|
-
hasText:
|
|
2703
|
+
hasText: utils.Tx.format(params.settingInfo.timer, "m")
|
|
2359
2704
|
}).click();
|
|
2360
2705
|
await page.waitForTimeout(200);
|
|
2361
2706
|
await page.locator(".byte-modal-footer button").filter({
|
|
@@ -2382,7 +2727,7 @@ const rpa_rpaAction = async (task, params)=>{
|
|
|
2382
2727
|
}).click();
|
|
2383
2728
|
}
|
|
2384
2729
|
await page.close();
|
|
2385
|
-
return (0,
|
|
2730
|
+
return (0, share_.success)(articleId, "publish" === params.saveType ? "发布成功" : "保存草稿成功");
|
|
2386
2731
|
};
|
|
2387
2732
|
const COVER_TYPE = {
|
|
2388
2733
|
no: 1,
|
|
@@ -2393,10 +2738,10 @@ const getAddTypeValue = (toutiaoAd)=>"yes" === toutiaoAd ? 3 : 2;
|
|
|
2393
2738
|
const toutiaoPublish = async (task, params)=>{
|
|
2394
2739
|
if ("rpa" === params.actionType) return rpa_rpaAction(task, params);
|
|
2395
2740
|
if ("mockApi" === params.actionType) return mock_mockAction(task, params);
|
|
2396
|
-
return
|
|
2741
|
+
return (0, utils.jo)(mock_mockAction, rpa_rpaAction)(task, params);
|
|
2397
2742
|
};
|
|
2398
2743
|
const TTFansExport = async (_task, params)=>{
|
|
2399
|
-
const http = new
|
|
2744
|
+
const http = new utils_http.e({
|
|
2400
2745
|
headers: {
|
|
2401
2746
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2402
2747
|
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
@@ -2410,19 +2755,19 @@ const TTFansExport = async (_task, params)=>{
|
|
|
2410
2755
|
app_id: 1231
|
|
2411
2756
|
}
|
|
2412
2757
|
});
|
|
2413
|
-
return (0,
|
|
2758
|
+
return (0, share_.success)(0 === res.code ? {
|
|
2414
2759
|
fans_count: res.total_fans_count
|
|
2415
2760
|
} : {
|
|
2416
2761
|
fans_count: null
|
|
2417
2762
|
}, "获取粉丝数成功!");
|
|
2418
2763
|
} catch (error) {
|
|
2419
|
-
return (0,
|
|
2764
|
+
return (0, share_.success)({
|
|
2420
2765
|
fans_count: null
|
|
2421
2766
|
}, "获取粉丝数失败,请检查登陆有效性!");
|
|
2422
2767
|
}
|
|
2423
2768
|
};
|
|
2424
2769
|
const XhsFansExport = async (_task, params)=>{
|
|
2425
|
-
const http = new
|
|
2770
|
+
const http = new utils_http.e({
|
|
2426
2771
|
headers: {
|
|
2427
2772
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2428
2773
|
referer: "https://creator.xiaohongshu.com/new/home?source=official"
|
|
@@ -2433,19 +2778,19 @@ const XhsFansExport = async (_task, params)=>{
|
|
|
2433
2778
|
method: "get",
|
|
2434
2779
|
url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
|
|
2435
2780
|
});
|
|
2436
|
-
return (0,
|
|
2781
|
+
return (0, share_.success)(0 === res.result ? {
|
|
2437
2782
|
fans_count: res.data.fans_count
|
|
2438
2783
|
} : {
|
|
2439
2784
|
fans_count: null
|
|
2440
2785
|
}, "获取粉丝数成功!");
|
|
2441
2786
|
} catch (error) {
|
|
2442
|
-
return (0,
|
|
2787
|
+
return (0, share_.success)({
|
|
2443
2788
|
fans_count: null
|
|
2444
2789
|
}, "获取粉丝数失败,请检查登陆有效性!");
|
|
2445
2790
|
}
|
|
2446
2791
|
};
|
|
2447
2792
|
const WxFansExport = async (_task, params)=>{
|
|
2448
|
-
const http = new
|
|
2793
|
+
const http = new utils_http.e({
|
|
2449
2794
|
headers: {
|
|
2450
2795
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
2451
2796
|
}
|
|
@@ -2461,19 +2806,19 @@ const WxFansExport = async (_task, params)=>{
|
|
|
2461
2806
|
}
|
|
2462
2807
|
});
|
|
2463
2808
|
const match = htmlStr.match(/总用户数[\s\S]*?<mp-thousandth>(\d+)<\/mp-thousandth>/);
|
|
2464
|
-
return (0,
|
|
2809
|
+
return (0, share_.success)(match ? {
|
|
2465
2810
|
fans_count: Number(match[1])
|
|
2466
2811
|
} : {
|
|
2467
2812
|
fans_count: null
|
|
2468
2813
|
}, "获取粉丝数成功!");
|
|
2469
2814
|
} catch (error) {
|
|
2470
|
-
return (0,
|
|
2815
|
+
return (0, share_.success)({
|
|
2471
2816
|
fans_count: null
|
|
2472
2817
|
}, "获取粉丝数失败,请检查登陆有效性!");
|
|
2473
2818
|
}
|
|
2474
2819
|
};
|
|
2475
2820
|
const BjhFansExport = async (_task, params)=>{
|
|
2476
|
-
const http = new
|
|
2821
|
+
const http = new utils_http.e({
|
|
2477
2822
|
headers: {
|
|
2478
2823
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2479
2824
|
referer: "https://baijiahao.baidu.com/builder/rc/home"
|
|
@@ -2484,20 +2829,430 @@ const BjhFansExport = async (_task, params)=>{
|
|
|
2484
2829
|
method: "get",
|
|
2485
2830
|
url: "https://baijiahao.baidu.com/cms-ui/rights/growth/get_info"
|
|
2486
2831
|
});
|
|
2487
|
-
return (0,
|
|
2832
|
+
return (0, share_.success)(0 === res.errno ? {
|
|
2488
2833
|
fans_count: res.data.total_fans
|
|
2489
2834
|
} : {
|
|
2490
2835
|
fans_count: null
|
|
2491
2836
|
}, "获取粉丝数成功!");
|
|
2492
2837
|
} catch (error) {
|
|
2493
|
-
return (0,
|
|
2838
|
+
return (0, share_.success)({
|
|
2494
2839
|
fans_count: null
|
|
2495
2840
|
}, "获取粉丝数失败,请检查登陆有效性!");
|
|
2496
2841
|
}
|
|
2497
2842
|
};
|
|
2843
|
+
const TTSessionCheck = async (_task, params)=>{
|
|
2844
|
+
const http = new utils_http.e({
|
|
2845
|
+
headers: {
|
|
2846
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2847
|
+
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
2848
|
+
}
|
|
2849
|
+
});
|
|
2850
|
+
try {
|
|
2851
|
+
const res = await http.api({
|
|
2852
|
+
method: "get",
|
|
2853
|
+
url: "https://mp.toutiao.com/mp/agw/creator_center/user_info",
|
|
2854
|
+
defaultErrorMsg: `头条号登录状态失效。`
|
|
2855
|
+
});
|
|
2856
|
+
return (0, share_.success)(0 === res.code ? {
|
|
2857
|
+
isValidSession: true
|
|
2858
|
+
} : {
|
|
2859
|
+
isValidSession: false
|
|
2860
|
+
}, "头条账号有效性检测完成!");
|
|
2861
|
+
} catch (error) {
|
|
2862
|
+
return (0, share_.success)({
|
|
2863
|
+
isValidSession: false
|
|
2864
|
+
}, "头条账号有效性检测失败!");
|
|
2865
|
+
}
|
|
2866
|
+
};
|
|
2867
|
+
const WxSessionCheck = async (_task, params)=>{
|
|
2868
|
+
const http = new utils_http.e({
|
|
2869
|
+
headers: {
|
|
2870
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
2871
|
+
}
|
|
2872
|
+
});
|
|
2873
|
+
const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
|
|
2874
|
+
try {
|
|
2875
|
+
const res = await http.api({
|
|
2876
|
+
method: "get",
|
|
2877
|
+
url: "https://mp.weixin.qq.com/cgi-bin/appmsgpublish",
|
|
2878
|
+
params: {
|
|
2879
|
+
fingerprint,
|
|
2880
|
+
sub: "list",
|
|
2881
|
+
begin: 0,
|
|
2882
|
+
count: 10,
|
|
2883
|
+
query: "",
|
|
2884
|
+
type: 1011102103,
|
|
2885
|
+
show_type: "",
|
|
2886
|
+
free_publish_type: 1102103,
|
|
2887
|
+
sub_action: "list_ex",
|
|
2888
|
+
search_card: 0,
|
|
2889
|
+
token: params.token,
|
|
2890
|
+
lang: "zh_CN",
|
|
2891
|
+
f: "json",
|
|
2892
|
+
ajax: 1
|
|
2893
|
+
}
|
|
2894
|
+
});
|
|
2895
|
+
return (0, share_.success)(0 === res.base_resp.ret ? {
|
|
2896
|
+
isValidSession: true
|
|
2897
|
+
} : {
|
|
2898
|
+
isValidSession: false
|
|
2899
|
+
}, "微信账号有效性检测完成!");
|
|
2900
|
+
} catch (error) {
|
|
2901
|
+
return (0, share_.success)({
|
|
2902
|
+
isValidSession: false
|
|
2903
|
+
}, "微信账号有效性检测失败!");
|
|
2904
|
+
}
|
|
2905
|
+
};
|
|
2906
|
+
const XhsSessionCheck = async (_task, params)=>{
|
|
2907
|
+
const http = new utils_http.e({
|
|
2908
|
+
headers: {
|
|
2909
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2910
|
+
referer: "https://creator.xiaohongshu.com/new/home?source=official"
|
|
2911
|
+
}
|
|
2912
|
+
});
|
|
2913
|
+
try {
|
|
2914
|
+
const res = await http.api({
|
|
2915
|
+
method: "get",
|
|
2916
|
+
url: "https://creator.xiaohongshu.com/api/galaxy/user/info"
|
|
2917
|
+
});
|
|
2918
|
+
return (0, share_.success)(0 === res.result ? {
|
|
2919
|
+
isValidSession: true
|
|
2920
|
+
} : {
|
|
2921
|
+
isValidSession: false
|
|
2922
|
+
}, "小红书账号有效性检测完成!");
|
|
2923
|
+
} catch (error) {
|
|
2924
|
+
return (0, share_.success)({
|
|
2925
|
+
isValidSession: false
|
|
2926
|
+
}, "小红书账号有效性检测完成!");
|
|
2927
|
+
}
|
|
2928
|
+
};
|
|
2929
|
+
const BjhSessionCheck = async (_task, params)=>{
|
|
2930
|
+
const http = new utils_http.e({
|
|
2931
|
+
headers: {
|
|
2932
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2933
|
+
referer: "https://baijiahao.baidu.com/builder/rc/home"
|
|
2934
|
+
}
|
|
2935
|
+
});
|
|
2936
|
+
try {
|
|
2937
|
+
const res = await http.api({
|
|
2938
|
+
method: "get",
|
|
2939
|
+
url: "https://baijiahao.baidu.com/pcui/home/index",
|
|
2940
|
+
defaultErrorMsg: `百家号登录状态失效。`
|
|
2941
|
+
});
|
|
2942
|
+
return (0, share_.success)(0 === res.errno ? {
|
|
2943
|
+
isValidSession: true
|
|
2944
|
+
} : {
|
|
2945
|
+
isValidSession: false
|
|
2946
|
+
}, "百家号账号有效性检测完成!");
|
|
2947
|
+
} catch (error) {
|
|
2948
|
+
return (0, share_.success)({
|
|
2949
|
+
isValidSession: false
|
|
2950
|
+
}, "百家号账号有效性检测失败!");
|
|
2951
|
+
}
|
|
2952
|
+
};
|
|
2953
|
+
var searchAccountInfo = __webpack_require__("./src/actions/searchAccountInfo/index.ts");
|
|
2954
|
+
var xhsXsEncrypt = __webpack_require__("./src/utils/xhsXsEncrypt.ts");
|
|
2955
|
+
const FetchArticles = async (_task, params)=>{
|
|
2956
|
+
const { platform, cookies, token, pageNum = 1, pageSize = 10, onlySuccess = false, showOriginalData = false } = params;
|
|
2957
|
+
try {
|
|
2958
|
+
switch(platform){
|
|
2959
|
+
case "toutiao":
|
|
2960
|
+
{
|
|
2961
|
+
const http = new utils_http.e({
|
|
2962
|
+
headers: {
|
|
2963
|
+
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
2964
|
+
}
|
|
2965
|
+
});
|
|
2966
|
+
const visitedUid = await http.api({
|
|
2967
|
+
url: "https://mp.toutiao.com/mp/agw/creator_center/user_info?",
|
|
2968
|
+
method: "get",
|
|
2969
|
+
params: {
|
|
2970
|
+
app_id: 1231
|
|
2971
|
+
}
|
|
2972
|
+
});
|
|
2973
|
+
const articleInfo = await http.api({
|
|
2974
|
+
method: "get",
|
|
2975
|
+
url: "https://mp.toutiao.com/api/feed/mp_provider/v1/",
|
|
2976
|
+
params: {
|
|
2977
|
+
provider_type: "mp_provider",
|
|
2978
|
+
aid: "13",
|
|
2979
|
+
app_name: "news_article",
|
|
2980
|
+
category: "mp_all",
|
|
2981
|
+
channel: "",
|
|
2982
|
+
stream_api_version: "88",
|
|
2983
|
+
genre_type_switch: '{"repost":1,"small_video":1,"toutiao_graphic":1,"weitoutiao":1,"xigua_video":1}',
|
|
2984
|
+
device_platform: "pc",
|
|
2985
|
+
platform_id: "0",
|
|
2986
|
+
visited_uid: visitedUid.user_id_str,
|
|
2987
|
+
offset: (pageNum - 1) * pageSize,
|
|
2988
|
+
count: pageSize,
|
|
2989
|
+
keyword: "",
|
|
2990
|
+
client_extra_params: `{"category":"mp_all","real_app_id":"1231","need_forward":"true","offset_mode":"1","page_index":"1","status":${onlySuccess ? "2" : "8"},"source":"0"}`,
|
|
2991
|
+
app_id: "1231"
|
|
2992
|
+
}
|
|
2993
|
+
});
|
|
2994
|
+
const articleCell = articleInfo.data.map((item)=>({
|
|
2995
|
+
title: item.assembleCell.itemCell.articleBase.title,
|
|
2996
|
+
imageUrl: item.assembleCell.itemCell.imageList.staggerFeedCover[0].url,
|
|
2997
|
+
createTime: item.assembleCell.itemCell.articleBase.publishTime,
|
|
2998
|
+
redirectUrl: item.assembleCell.itemCell.articleBase.articleURL,
|
|
2999
|
+
showNum: item.assembleCell.itemCell.itemCounter.showCount,
|
|
3000
|
+
readNum: item.assembleCell.itemCell.itemCounter.readCount,
|
|
3001
|
+
likeNum: item.assembleCell.itemCell.itemCounter.diggCount,
|
|
3002
|
+
commentNum: item.assembleCell.itemCell.itemCounter.commentCount,
|
|
3003
|
+
...showOriginalData ? {
|
|
3004
|
+
originalData: item
|
|
3005
|
+
} : {}
|
|
3006
|
+
}));
|
|
3007
|
+
const api_base_info_json = JSON.parse(articleInfo.api_base_info.app_extra_params);
|
|
3008
|
+
return (0, share_.success)({
|
|
3009
|
+
articleCell,
|
|
3010
|
+
pagination: {
|
|
3011
|
+
total: api_base_info_json.total_count,
|
|
3012
|
+
pageNum,
|
|
3013
|
+
pageSize
|
|
3014
|
+
}
|
|
3015
|
+
}, "头条号文章获取成功");
|
|
3016
|
+
}
|
|
3017
|
+
case "weixin":
|
|
3018
|
+
{
|
|
3019
|
+
if (!token) return {
|
|
3020
|
+
code: 200,
|
|
3021
|
+
message: "缺少token",
|
|
3022
|
+
data: null
|
|
3023
|
+
};
|
|
3024
|
+
const http = new utils_http.e({
|
|
3025
|
+
headers: {
|
|
3026
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
3027
|
+
}
|
|
3028
|
+
});
|
|
3029
|
+
const ParsePublishPage = (body)=>{
|
|
3030
|
+
const decodeHtml = (str)=>str.replace(/"/g, '"').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/'/g, "'").replace(/ /g, ' ');
|
|
3031
|
+
const match = body.match(/publish_page\s*=\s*(\{[\s\S]*?\})\s*;/);
|
|
3032
|
+
if (!match) throw new Error('无法提取 publish_page 字段');
|
|
3033
|
+
const rawPublishPageStr = match[1];
|
|
3034
|
+
const parsedData = JSON.parse(rawPublishPageStr);
|
|
3035
|
+
const finalData = {
|
|
3036
|
+
...parsedData,
|
|
3037
|
+
publish_list: parsedData.publish_list.map((item)=>{
|
|
3038
|
+
const decoded = decodeHtml(item.publish_info);
|
|
3039
|
+
const parsedInfo = JSON.parse(decoded);
|
|
3040
|
+
return {
|
|
3041
|
+
publish_type: item.publish_type,
|
|
3042
|
+
publish_info: parsedInfo
|
|
3043
|
+
};
|
|
3044
|
+
})
|
|
3045
|
+
};
|
|
3046
|
+
return finalData;
|
|
3047
|
+
};
|
|
3048
|
+
const rawArticlesInfo = await http.api({
|
|
3049
|
+
method: "get",
|
|
3050
|
+
url: 'https://mp.weixin.qq.com/cgi-bin/appmsgpublish?sub=list&begin=0&count=10&token=1453947575&lang=zh_CN',
|
|
3051
|
+
params: {
|
|
3052
|
+
sub: "list",
|
|
3053
|
+
begin: (pageNum - 1) * pageSize,
|
|
3054
|
+
count: pageSize,
|
|
3055
|
+
token: token,
|
|
3056
|
+
lang: "zh_CN"
|
|
3057
|
+
}
|
|
3058
|
+
});
|
|
3059
|
+
const articlesInfo = ParsePublishPage(rawArticlesInfo);
|
|
3060
|
+
const articleCell = articlesInfo?.publish_list.map((item)=>({
|
|
3061
|
+
title: item.publish_info.appmsg_info[0].title,
|
|
3062
|
+
imageUrl: item.publish_info.appmsg_info[0].cover,
|
|
3063
|
+
createTime: item.publish_info.appmsg_info[0].line_info.send_time,
|
|
3064
|
+
redirectUrl: item.publish_info.appmsg_info[0].content_url,
|
|
3065
|
+
readNum: item.publish_info.appmsg_info[0].read_num,
|
|
3066
|
+
likeNum: item.publish_info.appmsg_info[0].old_like_num,
|
|
3067
|
+
shareNum: item.publish_info.appmsg_info[0].share_num,
|
|
3068
|
+
recommendNum: item.publish_info.appmsg_info[0].like_num,
|
|
3069
|
+
...showOriginalData ? {
|
|
3070
|
+
originalData: item
|
|
3071
|
+
} : {}
|
|
3072
|
+
}));
|
|
3073
|
+
return (0, share_.success)({
|
|
3074
|
+
articleCell,
|
|
3075
|
+
...onlySuccess ? {
|
|
3076
|
+
pagination: {
|
|
3077
|
+
total: articlesInfo?.total_count,
|
|
3078
|
+
pageNum,
|
|
3079
|
+
pageSize
|
|
3080
|
+
}
|
|
3081
|
+
} : null
|
|
3082
|
+
}, "微信文章获取成功");
|
|
3083
|
+
}
|
|
3084
|
+
case "baijiahao":
|
|
3085
|
+
{
|
|
3086
|
+
if (!token) return {
|
|
3087
|
+
code: 200,
|
|
3088
|
+
message: "缺少token",
|
|
3089
|
+
data: null
|
|
3090
|
+
};
|
|
3091
|
+
const http = new utils_http.e({
|
|
3092
|
+
headers: {
|
|
3093
|
+
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
3094
|
+
token: token
|
|
3095
|
+
}
|
|
3096
|
+
});
|
|
3097
|
+
async function fetchArticles(pageNum, pageSize, onlySuccess = false) {
|
|
3098
|
+
return await http.api({
|
|
3099
|
+
method: "get",
|
|
3100
|
+
url: "https://baijiahao.baidu.com/pcui/article/lists",
|
|
3101
|
+
params: {
|
|
3102
|
+
currentPage: pageNum,
|
|
3103
|
+
pageSize: pageSize,
|
|
3104
|
+
search: "",
|
|
3105
|
+
type: "",
|
|
3106
|
+
collection: onlySuccess ? "publish" : "",
|
|
3107
|
+
clearBeforeFetch: false,
|
|
3108
|
+
dynamic: 1
|
|
3109
|
+
}
|
|
3110
|
+
});
|
|
3111
|
+
}
|
|
3112
|
+
const articleInfo = await fetchArticles(pageNum, pageSize, onlySuccess);
|
|
3113
|
+
let filtered = articleInfo.data.list.filter((item)=>"draft" !== item.status);
|
|
3114
|
+
const totalPage = articleInfo.data.page?.totalPage || 1;
|
|
3115
|
+
let currentPage = pageNum + 1;
|
|
3116
|
+
const usedPages = new Set();
|
|
3117
|
+
while(filtered.length < pageSize && currentPage <= totalPage){
|
|
3118
|
+
if (usedPages.has(currentPage)) {
|
|
3119
|
+
currentPage++;
|
|
3120
|
+
continue;
|
|
3121
|
+
}
|
|
3122
|
+
const res = await fetchArticles(currentPage, pageSize, onlySuccess);
|
|
3123
|
+
usedPages.add(currentPage);
|
|
3124
|
+
const validItems = res.data.list.filter((item)=>"draft" !== item.status);
|
|
3125
|
+
filtered.push(...validItems);
|
|
3126
|
+
currentPage++;
|
|
3127
|
+
}
|
|
3128
|
+
const final = filtered.slice(0, pageSize);
|
|
3129
|
+
const articleCell = final.map((item)=>({
|
|
3130
|
+
title: item.title,
|
|
3131
|
+
imageUrl: JSON.parse(item.cover_images)[0].src,
|
|
3132
|
+
createTime: Math.floor(new Date(item.publish_at.replace(/-/g, "/")).getTime() / 1000),
|
|
3133
|
+
redirectUrl: item.url,
|
|
3134
|
+
recommendNum: item.rec_amount,
|
|
3135
|
+
collectNum: item.collection_amount,
|
|
3136
|
+
readNum: item.read_amount,
|
|
3137
|
+
likeNum: item.like_amount,
|
|
3138
|
+
commentNum: item.comment_amount,
|
|
3139
|
+
shareNum: item.share_amount,
|
|
3140
|
+
...showOriginalData ? {
|
|
3141
|
+
originalData: item
|
|
3142
|
+
} : {}
|
|
3143
|
+
}));
|
|
3144
|
+
return (0, share_.success)({
|
|
3145
|
+
articleCell,
|
|
3146
|
+
...onlySuccess ? {
|
|
3147
|
+
pagination: {
|
|
3148
|
+
total: articleInfo.data.page?.totalCount,
|
|
3149
|
+
pageNum,
|
|
3150
|
+
pageSize
|
|
3151
|
+
}
|
|
3152
|
+
} : null
|
|
3153
|
+
}, "百家号文章获取成功");
|
|
3154
|
+
}
|
|
3155
|
+
case "xiaohongshu":
|
|
3156
|
+
{
|
|
3157
|
+
const xsEncrypt = new xhsXsEncrypt.H();
|
|
3158
|
+
const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
|
|
3159
|
+
if (!a1Cookie) return {
|
|
3160
|
+
code: 200,
|
|
3161
|
+
message: "账号数据异常",
|
|
3162
|
+
data: null
|
|
3163
|
+
};
|
|
3164
|
+
if (10 != pageSize) return {
|
|
3165
|
+
code: 200,
|
|
3166
|
+
message: "小红书pageSize不可修改",
|
|
3167
|
+
data: null
|
|
3168
|
+
};
|
|
3169
|
+
const http = new utils_http.e({
|
|
3170
|
+
headers: {
|
|
3171
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
3172
|
+
referer: "https://creator.xiaohongshu.com",
|
|
3173
|
+
origin: "https://creator.xiaohongshu.com"
|
|
3174
|
+
}
|
|
3175
|
+
});
|
|
3176
|
+
const xt = Date.now().toString();
|
|
3177
|
+
const serveUrl = `/web_api/sns/v5/creator/note/user/posted?tab=${onlySuccess ? 1 : 0}&page=${pageNum - 1}`;
|
|
3178
|
+
const xs = await xsEncrypt.encryptXs(serveUrl, a1Cookie, xt);
|
|
3179
|
+
const articleInfo = await http.api({
|
|
3180
|
+
method: "get",
|
|
3181
|
+
baseURL: "https://edith.xiaohongshu.com",
|
|
3182
|
+
url: serveUrl,
|
|
3183
|
+
headers: {
|
|
3184
|
+
"x-s": xs,
|
|
3185
|
+
"x-t": xt
|
|
3186
|
+
}
|
|
3187
|
+
});
|
|
3188
|
+
const articleCell = articleInfo.data.notes.map((item)=>({
|
|
3189
|
+
title: item.display_title,
|
|
3190
|
+
imageUrl: item.images_list[0].url,
|
|
3191
|
+
createTime: Math.floor(new Date(item.time.replace(/-/g, "/")).getTime() / 1000),
|
|
3192
|
+
redirectUrl: `https://www.xiaohongshu.com/explore/${item.id}?xsec_token=${item.xsec_token}&xsec_source=pc_creatormng`,
|
|
3193
|
+
readNum: item.view_count,
|
|
3194
|
+
likeNum: item.likes,
|
|
3195
|
+
commentNum: item.comments_count,
|
|
3196
|
+
collectNum: item.collected_count,
|
|
3197
|
+
shareNum: item.shared_count,
|
|
3198
|
+
...showOriginalData ? {
|
|
3199
|
+
originalData: item
|
|
3200
|
+
} : {}
|
|
3201
|
+
}));
|
|
3202
|
+
return (0, share_.success)({
|
|
3203
|
+
articleCell,
|
|
3204
|
+
...onlySuccess ? {
|
|
3205
|
+
pagination: {
|
|
3206
|
+
total: articleInfo.data.tags[0].notes_count,
|
|
3207
|
+
pageNum,
|
|
3208
|
+
pageSize
|
|
3209
|
+
}
|
|
3210
|
+
} : null
|
|
3211
|
+
}, "小红书文章获取成功");
|
|
3212
|
+
}
|
|
3213
|
+
default:
|
|
3214
|
+
return {
|
|
3215
|
+
code: 200,
|
|
3216
|
+
message: "暂不支持该平台",
|
|
3217
|
+
data: null
|
|
3218
|
+
};
|
|
3219
|
+
}
|
|
3220
|
+
} catch (error) {
|
|
3221
|
+
console.error("获取文章数据失败:", error);
|
|
3222
|
+
return {
|
|
3223
|
+
code: 500,
|
|
3224
|
+
message: "获取文章数据失败",
|
|
3225
|
+
data: null
|
|
3226
|
+
};
|
|
3227
|
+
}
|
|
3228
|
+
};
|
|
3229
|
+
const getWeixinConfig = async (_task, params)=>{
|
|
3230
|
+
const http = new utils_http.e({
|
|
3231
|
+
headers: {
|
|
3232
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
3233
|
+
}
|
|
3234
|
+
});
|
|
3235
|
+
const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
|
|
3236
|
+
const res = await http.api({
|
|
3237
|
+
method: "get",
|
|
3238
|
+
url: "https://mp.weixin.qq.com/cgi-bin/masssendpage",
|
|
3239
|
+
params: {
|
|
3240
|
+
f: 'json',
|
|
3241
|
+
token: params.token,
|
|
3242
|
+
lang: 'zh_CN',
|
|
3243
|
+
ajax: 1,
|
|
3244
|
+
fingerprint: fingerprint,
|
|
3245
|
+
random: Math.random().toString()
|
|
3246
|
+
}
|
|
3247
|
+
});
|
|
3248
|
+
const filtered = {
|
|
3249
|
+
publishQuota: 0 === res.base_resp.ret ? res.quota_detail_list.filter((item)=>"kQuotaTypeMassSendNormal" === item.quota_type).map((item)=>item.quota_item_list) : []
|
|
3250
|
+
};
|
|
3251
|
+
return (0, share_.success)(filtered, 0 === res.base_resp.ret ? "微信配置信息获取成功!" : "微信配置信息获取失败!");
|
|
3252
|
+
};
|
|
2498
3253
|
const weitoutiaoPublish_mock_mockAction = async (task, params)=>{
|
|
2499
3254
|
const tmpCachePath = task.getTmpPath();
|
|
2500
|
-
const http = new
|
|
3255
|
+
const http = new utils_http.e({
|
|
2501
3256
|
headers: {
|
|
2502
3257
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2503
3258
|
origin: "https://mp.toutiao.com",
|
|
@@ -2516,12 +3271,12 @@ const weitoutiaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
2516
3271
|
const imageList = [];
|
|
2517
3272
|
if (params.banners && params.banners.length > 0) {
|
|
2518
3273
|
const images = await Promise.all(params.banners.map((url)=>{
|
|
2519
|
-
const fileName = (0,
|
|
2520
|
-
return (0,
|
|
3274
|
+
const fileName = (0, share_.getFilenameFromUrl)(url);
|
|
3275
|
+
return (0, share_.downloadImage)(url, external_node_path_["default"].join(tmpCachePath, fileName));
|
|
2521
3276
|
}));
|
|
2522
3277
|
const res = await Promise.all(images.map(async (it)=>{
|
|
2523
3278
|
const formData = new __WEBPACK_EXTERNAL_MODULE_form_data_cf000082__["default"]();
|
|
2524
|
-
formData.append("image",
|
|
3279
|
+
formData.append("image", external_node_fs_["default"].createReadStream(it));
|
|
2525
3280
|
const response = await http.api({
|
|
2526
3281
|
method: "post",
|
|
2527
3282
|
url: "https://mp.toutiao.com/spice/image?upload_source=20020003&aid=1231&device_platform=web",
|
|
@@ -2564,7 +3319,7 @@ const weitoutiaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
2564
3319
|
url: "https://mp.toutiao.com/mp/agw/article/wtt",
|
|
2565
3320
|
data: syncData
|
|
2566
3321
|
});
|
|
2567
|
-
return (0,
|
|
3322
|
+
return (0, share_.success)(res.data);
|
|
2568
3323
|
};
|
|
2569
3324
|
const weitoutiaoPublish_rpa_rpaAction = async (task, params)=>{
|
|
2570
3325
|
const commonCookies = {
|
|
@@ -2597,8 +3352,8 @@ const weitoutiaoPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
2597
3352
|
await descInstance.fill(params.content);
|
|
2598
3353
|
if (params.banners && params.banners?.length > 0) {
|
|
2599
3354
|
const images = await Promise.all(params.banners.map((url)=>{
|
|
2600
|
-
const fileName = (0,
|
|
2601
|
-
return (0,
|
|
3355
|
+
const fileName = (0, share_.getFilenameFromUrl)(url);
|
|
3356
|
+
return (0, share_.downloadImage)(url, external_node_path_["default"].join(tmpCachePath, fileName));
|
|
2602
3357
|
}));
|
|
2603
3358
|
const fileChooserPromise = page.waitForEvent("filechooser");
|
|
2604
3359
|
await page.locator(".toolbar .syl-toolbar-tool.weitoutiao-image-plugin").click();
|
|
@@ -2629,12 +3384,12 @@ const weitoutiaoPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
2629
3384
|
await declarationFormItem.locator(`.byte-checkbox:has(input[value="${params.declaration}"])`).click();
|
|
2630
3385
|
}
|
|
2631
3386
|
await page.locator(".footer-wrap button.publish-content").click();
|
|
2632
|
-
return (0,
|
|
3387
|
+
return (0, share_.success)("");
|
|
2633
3388
|
};
|
|
2634
3389
|
const weitoutiaoPublish = async (task, params)=>{
|
|
2635
3390
|
if ("rpa" === params.actionType) return weitoutiaoPublish_rpa_rpaAction(task, params);
|
|
2636
3391
|
if ("mockApi" === params.actionType) return weitoutiaoPublish_mock_mockAction(task, params);
|
|
2637
|
-
return
|
|
3392
|
+
return (0, utils.jo)(weitoutiaoPublish_mock_mockAction, weitoutiaoPublish_rpa_rpaAction)(task, params);
|
|
2638
3393
|
};
|
|
2639
3394
|
const scanRetryMaxCount = 30;
|
|
2640
3395
|
const QuotaType = {
|
|
@@ -2691,7 +3446,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
2691
3446
|
const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
|
|
2692
3447
|
const client_time_diff = +Number("1743488763") - Math.floor(new Date().getTime() / 1000);
|
|
2693
3448
|
const tmpCachePath = task.getTmpPath();
|
|
2694
|
-
const http = new
|
|
3449
|
+
const http = new utils_http.e({
|
|
2695
3450
|
headers: {
|
|
2696
3451
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0",
|
|
2697
3452
|
Cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
@@ -2734,19 +3489,19 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
2734
3489
|
const uploadImages = async (images)=>{
|
|
2735
3490
|
const cloudImages = [];
|
|
2736
3491
|
const localImages = await Promise.all(images.map((url)=>{
|
|
2737
|
-
const fileName = (0,
|
|
2738
|
-
return (0,
|
|
3492
|
+
const fileName = (0, share_.getFilenameFromUrl)(url);
|
|
3493
|
+
return (0, share_.downloadImage)(url, external_node_path_["default"].join(tmpCachePath, fileName));
|
|
2739
3494
|
}));
|
|
2740
3495
|
for(let index = 0; index < images.length; index++){
|
|
2741
3496
|
const image = localImages[index];
|
|
2742
|
-
const fileState =
|
|
3497
|
+
const fileState = (0, utils.H8)(image);
|
|
2743
3498
|
const formData = new __WEBPACK_EXTERNAL_MODULE_form_data_cf000082__["default"]();
|
|
2744
3499
|
formData.append("id", `WU_FILE_${index + 1}`);
|
|
2745
3500
|
formData.append("name", fileState.name);
|
|
2746
3501
|
formData.append("type", fileState.type);
|
|
2747
3502
|
formData.append("lastModifiedDate", fileState.lastModifiedDate);
|
|
2748
3503
|
formData.append("size", fileState.size);
|
|
2749
|
-
formData.append("file",
|
|
3504
|
+
formData.append("file", external_node_fs_["default"].createReadStream(image));
|
|
2750
3505
|
const response = await http.api({
|
|
2751
3506
|
method: "post",
|
|
2752
3507
|
url: `https://mp.weixin.qq.com/cgi-bin/filetransfer?action=upload_material&f=json&writetype=doublewrite&token=${params.token}&lang=zh_CN`,
|
|
@@ -2757,9 +3512,9 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
2757
3512
|
}
|
|
2758
3513
|
return cloudImages;
|
|
2759
3514
|
};
|
|
2760
|
-
const originContentImages =
|
|
3515
|
+
const originContentImages = (0, utils.E_)(params.content);
|
|
2761
3516
|
const targetContentImages = await uploadImages(originContentImages);
|
|
2762
|
-
const content =
|
|
3517
|
+
const content = (0, utils.I)(params.content, (dom)=>{
|
|
2763
3518
|
if (dom.attribs.src) {
|
|
2764
3519
|
const idx = originContentImages.findIndex((it)=>it === dom.attribs.src);
|
|
2765
3520
|
dom.attribs.src = targetContentImages[idx].cdn_url;
|
|
@@ -2876,13 +3631,13 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
2876
3631
|
defaultErrorMsg: GET_QRCODE_DEFAULT_ERROR
|
|
2877
3632
|
});
|
|
2878
3633
|
const rewardBuffer = Buffer.from(rewardbind.qrcode_base64, 'base64');
|
|
2879
|
-
const rewardFilePath =
|
|
2880
|
-
|
|
3634
|
+
const rewardFilePath = external_node_path_["default"].join(tmpCachePath, "weixin_reward.jpg");
|
|
3635
|
+
external_node_fs_["default"].writeFileSync(rewardFilePath, new Uint8Array(rewardBuffer));
|
|
2881
3636
|
params.safeQrcodeCallback?.(rewardFilePath);
|
|
2882
3637
|
const task_id = rewardbind.task_id;
|
|
2883
3638
|
let code = null;
|
|
2884
3639
|
for(let i = 0; i < scanRetryMaxCount; i++){
|
|
2885
|
-
await (0,
|
|
3640
|
+
await (0, share_.sleep)(2000);
|
|
2886
3641
|
const checkScanResult = await http.api({
|
|
2887
3642
|
method: "get",
|
|
2888
3643
|
url: "https://mp.weixin.qq.com/acct/writermgr",
|
|
@@ -3143,7 +3898,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3143
3898
|
appmsgid: appMsgId
|
|
3144
3899
|
};
|
|
3145
3900
|
for(let i = 0; i < 10; i++){
|
|
3146
|
-
await (0,
|
|
3901
|
+
await (0, share_.sleep)(1000);
|
|
3147
3902
|
const lastData = {
|
|
3148
3903
|
...copyrightStatData,
|
|
3149
3904
|
first_check: 0 === i ? 1 : 0
|
|
@@ -3151,7 +3906,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3151
3906
|
const checkCopyrightStatRes = await checkCopyrightStat(http, params, lastData);
|
|
3152
3907
|
if (checkCopyrightStatRes.open_ad_reprint_status) break;
|
|
3153
3908
|
}
|
|
3154
|
-
await (0,
|
|
3909
|
+
await (0, share_.sleep)(300);
|
|
3155
3910
|
await http.api({
|
|
3156
3911
|
method: "post",
|
|
3157
3912
|
url: "https://mp.weixin.qq.com/cgi-bin/masssend",
|
|
@@ -3172,7 +3927,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3172
3927
|
random: Math.random().toString()
|
|
3173
3928
|
})
|
|
3174
3929
|
});
|
|
3175
|
-
await (0,
|
|
3930
|
+
await (0, share_.sleep)(300);
|
|
3176
3931
|
await http.api({
|
|
3177
3932
|
method: "post",
|
|
3178
3933
|
url: "https://mp.weixin.qq.com/cgi-bin/masssend",
|
|
@@ -3190,7 +3945,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3190
3945
|
random: Math.random().toString()
|
|
3191
3946
|
})
|
|
3192
3947
|
});
|
|
3193
|
-
await (0,
|
|
3948
|
+
await (0, share_.sleep)(300);
|
|
3194
3949
|
const getTicketResult = await http.api({
|
|
3195
3950
|
method: "post",
|
|
3196
3951
|
url: "https://mp.weixin.qq.com/misc/safeassistant",
|
|
@@ -3210,7 +3965,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3210
3965
|
}),
|
|
3211
3966
|
defaultErrorMsg: GET_QRCODE_DEFAULT_ERROR
|
|
3212
3967
|
});
|
|
3213
|
-
await (0,
|
|
3968
|
+
await (0, share_.sleep)(300);
|
|
3214
3969
|
const getUuidResult = await http.api({
|
|
3215
3970
|
method: "post",
|
|
3216
3971
|
url: "https://mp.weixin.qq.com/safe/safeqrconnect",
|
|
@@ -3233,14 +3988,14 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3233
3988
|
}),
|
|
3234
3989
|
defaultErrorMsg: GET_QRCODE_DEFAULT_ERROR
|
|
3235
3990
|
});
|
|
3236
|
-
await (0,
|
|
3991
|
+
await (0, share_.sleep)(1000);
|
|
3237
3992
|
if (0 !== getUuidResult.genuuid_res) return {
|
|
3238
3993
|
code: 200,
|
|
3239
3994
|
message: GET_QRCODE_DEFAULT_ERROR,
|
|
3240
3995
|
data: ""
|
|
3241
3996
|
};
|
|
3242
3997
|
const uuid = getUuidResult.uuid;
|
|
3243
|
-
await (0,
|
|
3998
|
+
await (0, share_.sleep)(1000);
|
|
3244
3999
|
const qrcodeResult = await http.api({
|
|
3245
4000
|
method: "get",
|
|
3246
4001
|
url: "https://mp.weixin.qq.com/safe/safeqrcode",
|
|
@@ -3260,12 +4015,12 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3260
4015
|
responseType: "arraybuffer"
|
|
3261
4016
|
});
|
|
3262
4017
|
const qrcodeBuffer = Buffer.from(qrcodeResult);
|
|
3263
|
-
const qrcodeFilePath =
|
|
3264
|
-
|
|
4018
|
+
const qrcodeFilePath = external_node_path_["default"].join(tmpCachePath, "weixin_qrcode.jpg");
|
|
4019
|
+
external_node_fs_["default"].writeFileSync(qrcodeFilePath, new Uint8Array(qrcodeBuffer));
|
|
3265
4020
|
params.safeQrcodeCallback?.(qrcodeFilePath);
|
|
3266
4021
|
let code = "";
|
|
3267
4022
|
for(let i = 0; i < scanRetryMaxCount; i++){
|
|
3268
|
-
await (0,
|
|
4023
|
+
await (0, share_.sleep)(2000);
|
|
3269
4024
|
const checkScanResult = await http.api({
|
|
3270
4025
|
method: "post",
|
|
3271
4026
|
url: "https://mp.weixin.qq.com/safe/safeuuid",
|
|
@@ -3352,7 +4107,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3352
4107
|
share_page: "1",
|
|
3353
4108
|
synctxweibo: "0",
|
|
3354
4109
|
operation_seq,
|
|
3355
|
-
req_id: (0,
|
|
4110
|
+
req_id: (0, share_.randomString)(32),
|
|
3356
4111
|
req_time: new Date().getTime() + 1e3 * client_time_diff,
|
|
3357
4112
|
sync_version: "1",
|
|
3358
4113
|
isFreePublish: params.masssend ? "false" : "true",
|
|
@@ -3364,8 +4119,9 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3364
4119
|
}),
|
|
3365
4120
|
defaultErrorMsg: params.masssend ? "文章群发异常,请尝试关闭群发或稍后重试。" : "文章发布异常,请稍后重试。"
|
|
3366
4121
|
});
|
|
3367
|
-
return (0,
|
|
4122
|
+
return (0, share_.success)(appMsgId, params.settingInfo.timer ? "微信公众号文章定时发布成功。" : "微信公众号发布完成。");
|
|
3368
4123
|
};
|
|
4124
|
+
var external_axios_ = __webpack_require__("axios");
|
|
3369
4125
|
const waitQrcodeResultMaxTime = 2000 * scanRetryMaxCount;
|
|
3370
4126
|
const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
3371
4127
|
const tmpCachePath = task.getTmpPath();
|
|
@@ -3413,8 +4169,8 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
3413
4169
|
const qrcodeSrc = await reward_page.locator(".invite-qrcode").getAttribute('src');
|
|
3414
4170
|
if (qrcodeSrc) {
|
|
3415
4171
|
const rewardBuffer = Buffer.from(qrcodeSrc.replace(/^data:image\/\w+;base64,/, ''), 'base64');
|
|
3416
|
-
const rewardFilePath =
|
|
3417
|
-
|
|
4172
|
+
const rewardFilePath = external_node_path_["default"].join(tmpCachePath, "weixin_reward.jpg");
|
|
4173
|
+
external_node_fs_["default"].writeFileSync(rewardFilePath, new Uint8Array(rewardBuffer));
|
|
3418
4174
|
params.safeQrcodeCallback?.(rewardFilePath);
|
|
3419
4175
|
}
|
|
3420
4176
|
} catch (error) {
|
|
@@ -3481,11 +4237,11 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
3481
4237
|
await page.waitForSelector("#editor_pannel", {
|
|
3482
4238
|
state: "visible"
|
|
3483
4239
|
});
|
|
3484
|
-
|
|
4240
|
+
(0, utils.f8)(page, '[v-transfer-dom="#vue_app"] .weui-desktop-dialog', "更新", '[v-transfer-dom="#vue_app"] .weui-desktop-icon-btn.weui-desktop-dialog__close-btn', {
|
|
3485
4241
|
checkInterval: 1000,
|
|
3486
4242
|
stopAfterClick: false
|
|
3487
4243
|
});
|
|
3488
|
-
|
|
4244
|
+
(0, utils.f8)(page, '[extclass="weui-desktop-dialog_simple"] .weui-desktop-dialog', "小店", '[extclass="weui-desktop-dialog_simple"] .weui-desktop-icon-btn.weui-desktop-dialog__close-btn', {
|
|
3489
4245
|
checkInterval: 1000,
|
|
3490
4246
|
stopAfterClick: true
|
|
3491
4247
|
});
|
|
@@ -3497,7 +4253,7 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
3497
4253
|
await titleInstance.click();
|
|
3498
4254
|
await titleInstance.fill(params.settingInfo.wxAuthor);
|
|
3499
4255
|
}
|
|
3500
|
-
await
|
|
4256
|
+
await (0, utils.qN)(page, params.content);
|
|
3501
4257
|
await page.click(".js_editor_area .ProseMirror");
|
|
3502
4258
|
await page.keyboard.press("Control+V");
|
|
3503
4259
|
await page.locator("#article_setting_area").evaluate((node)=>node.scrollIntoView());
|
|
@@ -3507,8 +4263,8 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
3507
4263
|
await titleInstance.fill(params.settingInfo.wxAbstract);
|
|
3508
4264
|
}
|
|
3509
4265
|
if (params.settingInfo.wxCover) {
|
|
3510
|
-
const fileName = (0,
|
|
3511
|
-
const cover = await (0,
|
|
4266
|
+
const fileName = (0, share_.getFilenameFromUrl)(params.settingInfo.wxCover);
|
|
4267
|
+
const cover = await (0, share_.downloadImage)(params.settingInfo.wxCover, external_node_path_["default"].join(tmpCachePath, fileName));
|
|
3512
4268
|
await page.locator("#article_setting_area #js_cover_area .select-cover__btn").hover();
|
|
3513
4269
|
await page.locator("#article_setting_area #js_cover_area .pop-opr__group-select-cover .pop-opr__list .pop-opr__item").filter({
|
|
3514
4270
|
hasText: "从图片库选择"
|
|
@@ -3694,7 +4450,7 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
3694
4450
|
const articleId = await new Promise(async (resolve)=>{
|
|
3695
4451
|
const handleResponse = async (response)=>{
|
|
3696
4452
|
const url = response.url();
|
|
3697
|
-
const query =
|
|
4453
|
+
const query = (0, utils.hc)(url);
|
|
3698
4454
|
if (url.includes("/cgi-bin/operate_appmsg") && query?.t === "ajax-response") {
|
|
3699
4455
|
const jsonResponse = await response.json();
|
|
3700
4456
|
page.off("response", handleResponse);
|
|
@@ -3708,15 +4464,15 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
3708
4464
|
await page.locator(".mass-send .mass-send__td-setting", {
|
|
3709
4465
|
hasText: "定时发表"
|
|
3710
4466
|
}).locator(".weui-desktop-switch__box").check();
|
|
3711
|
-
let dateD = Number(
|
|
3712
|
-
let nowD = Number(
|
|
4467
|
+
let dateD = Number(utils.Tx.format(params.settingInfo.timer, "d"));
|
|
4468
|
+
let nowD = Number(utils.Tx.format(Date.now(), "d"));
|
|
3713
4469
|
await page.locator(".mass-send__timer .weui-desktop-form__dropdown__dt").click();
|
|
3714
4470
|
const dropMenu = page.locator(".mass-send__timer .weui-desktop-dropdown-menu").locator(".weui-desktop-dropdown__list-ele");
|
|
3715
4471
|
await dropMenu.filter({
|
|
3716
|
-
hasText: dateD == nowD ? "今天" : dateD == nowD + 1 ? "明天" :
|
|
4472
|
+
hasText: dateD == nowD ? "今天" : dateD == nowD + 1 ? "明天" : utils.Tx.format(params.settingInfo.timer, "M月d日")
|
|
3717
4473
|
}).click();
|
|
3718
4474
|
const timeDropMenu = page.locator(".mass-send__timer .weui-desktop-picker__time:visible");
|
|
3719
|
-
await timeDropMenu.locator(".weui-desktop-form__input").fill(
|
|
4475
|
+
await timeDropMenu.locator(".weui-desktop-form__input").fill(utils.Tx.format(params.settingInfo.timer, "hh:mm"));
|
|
3720
4476
|
await timeDropMenu.locator("i.weui-desktop-icon__time").click();
|
|
3721
4477
|
}
|
|
3722
4478
|
});
|
|
@@ -3774,13 +4530,13 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
3774
4530
|
const qrcodeSrc = await page.locator(".dialog .js_wxchecks.safe_check img.qrcode.js_qrcode").first().getAttribute("src");
|
|
3775
4531
|
if (qrcodeSrc) {
|
|
3776
4532
|
const imgUrl = new URL(qrcodeSrc, page.url()).href;
|
|
3777
|
-
const response = await (0,
|
|
4533
|
+
const response = await (0, external_axios_["default"])({
|
|
3778
4534
|
method: "get",
|
|
3779
4535
|
url: imgUrl,
|
|
3780
4536
|
responseType: "arraybuffer"
|
|
3781
4537
|
});
|
|
3782
|
-
const qrcodeFilePath =
|
|
3783
|
-
|
|
4538
|
+
const qrcodeFilePath = external_node_path_["default"].join(tmpCachePath, "weixin_qrcode.jpg");
|
|
4539
|
+
external_node_fs_["default"].writeFileSync(qrcodeFilePath, response.data);
|
|
3784
4540
|
params.safeQrcodeCallback?.(qrcodeFilePath);
|
|
3785
4541
|
} else throw new Error("qrcodeSrc is empty");
|
|
3786
4542
|
});
|
|
@@ -3794,15 +4550,15 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
3794
4550
|
}
|
|
3795
4551
|
await page.waitForTimeout(3000);
|
|
3796
4552
|
await page.close();
|
|
3797
|
-
return (0,
|
|
4553
|
+
return (0, share_.success)(articleId);
|
|
3798
4554
|
};
|
|
3799
4555
|
const weixinPublish = async (task, _params)=>{
|
|
3800
|
-
const params =
|
|
4556
|
+
const params = (0, utils.Tb)(_params, {
|
|
3801
4557
|
masssend: true
|
|
3802
4558
|
});
|
|
3803
4559
|
if ("rpa" === params.actionType) return weixinPublish_rpa_rpaAction(task, params);
|
|
3804
4560
|
if ("mockApi" === params.actionType) return weixinPublish_mock_mockAction(task, params);
|
|
3805
|
-
return
|
|
4561
|
+
return (0, utils.jo)(weixinPublish_mock_mockAction, weixinPublish_rpa_rpaAction)(task, params);
|
|
3806
4562
|
};
|
|
3807
4563
|
const saveDraft = (http, params, data)=>{
|
|
3808
4564
|
const formData = new __WEBPACK_EXTERNAL_MODULE_form_data_cf000082__["default"]();
|
|
@@ -3822,7 +4578,7 @@ const saveDraft = (http, params, data)=>{
|
|
|
3822
4578
|
};
|
|
3823
4579
|
const weixinmpPublish_mock_mockAction = async (task, params)=>{
|
|
3824
4580
|
const tmpCachePath = task.getTmpPath();
|
|
3825
|
-
const http = new
|
|
4581
|
+
const http = new utils_http.e({
|
|
3826
4582
|
headers: {
|
|
3827
4583
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
3828
4584
|
origin: "https://mp.weixin.qq.com",
|
|
@@ -3833,19 +4589,19 @@ const weixinmpPublish_mock_mockAction = async (task, params)=>{
|
|
|
3833
4589
|
const cropResult = {};
|
|
3834
4590
|
if (params.banners && params.banners.length > 0) {
|
|
3835
4591
|
const images = await Promise.all(params.banners.map((url)=>{
|
|
3836
|
-
const fileName = (0,
|
|
3837
|
-
return (0,
|
|
4592
|
+
const fileName = (0, share_.getFilenameFromUrl)(url);
|
|
4593
|
+
return (0, share_.downloadImage)(url, external_node_path_["default"].join(tmpCachePath, fileName));
|
|
3838
4594
|
}));
|
|
3839
4595
|
for(let index = 0; index < images.length; index++){
|
|
3840
4596
|
const image = images[index];
|
|
3841
|
-
const fileState =
|
|
4597
|
+
const fileState = (0, utils.H8)(image);
|
|
3842
4598
|
const formData = new __WEBPACK_EXTERNAL_MODULE_form_data_cf000082__["default"]();
|
|
3843
4599
|
formData.append("id", `WU_FILE_${index + 1}`);
|
|
3844
4600
|
formData.append("name", fileState.name);
|
|
3845
4601
|
formData.append("type", fileState.type);
|
|
3846
4602
|
formData.append("lastModifiedDate", fileState.lastModifiedDate);
|
|
3847
4603
|
formData.append("size", fileState.size);
|
|
3848
|
-
formData.append("file",
|
|
4604
|
+
formData.append("file", external_node_fs_["default"].createReadStream(image));
|
|
3849
4605
|
const response = await http.api({
|
|
3850
4606
|
method: "post",
|
|
3851
4607
|
url: `https://mp.weixin.qq.com/cgi-bin/filetransfer?action=upload_material&f=json&writetype=doublewrite&token=${params.token}&lang=zh_CN`,
|
|
@@ -3893,7 +4649,7 @@ const weixinmpPublish_mock_mockAction = async (task, params)=>{
|
|
|
3893
4649
|
];
|
|
3894
4650
|
cropFormData.append("size_count", cropRatios.length);
|
|
3895
4651
|
const cropCoordinates = cropRatios.map((r, idx)=>{
|
|
3896
|
-
const cropCoordinate =
|
|
4652
|
+
const cropCoordinate = (0, utils.e0)(colorResponseData.width, colorResponseData.height, r);
|
|
3897
4653
|
cropFormData.append(`size${idx}_x1`, cropCoordinate.x1);
|
|
3898
4654
|
cropFormData.append(`size${idx}_y1`, cropCoordinate.y1);
|
|
3899
4655
|
cropFormData.append(`size${idx}_x2`, cropCoordinate.x2);
|
|
@@ -3946,7 +4702,7 @@ const weixinmpPublish_mock_mockAction = async (task, params)=>{
|
|
|
3946
4702
|
content0: params.content,
|
|
3947
4703
|
share_imageinfo0: JSON.stringify(shareImageInfos)
|
|
3948
4704
|
});
|
|
3949
|
-
return (0,
|
|
4705
|
+
return (0, share_.success)(res);
|
|
3950
4706
|
};
|
|
3951
4707
|
const sourceText = {
|
|
3952
4708
|
ai: "内容由AI生成",
|
|
@@ -3983,8 +4739,8 @@ const weixinmpPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
3983
4739
|
const container = page.locator("#editor_pannel");
|
|
3984
4740
|
if (params.banners && params.banners.length > 0) {
|
|
3985
4741
|
const images = await Promise.all(params.banners.map((url)=>{
|
|
3986
|
-
const fileName = (0,
|
|
3987
|
-
return (0,
|
|
4742
|
+
const fileName = (0, share_.getFilenameFromUrl)(url);
|
|
4743
|
+
return (0, share_.downloadImage)(url, external_node_path_["default"].join(tmpCachePath, fileName));
|
|
3988
4744
|
}));
|
|
3989
4745
|
const fileChooserPromise = page.waitForEvent("filechooser");
|
|
3990
4746
|
await container.locator(".image-selector__add").hover();
|
|
@@ -4009,69 +4765,20 @@ const weixinmpPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
4009
4765
|
if (params.banners && params.banners.length > 0) await page.waitForSelector("#editor_pannel .image-selector .image-selector__preview");
|
|
4010
4766
|
if (params.draft) await container.locator("#bottom_main #js_submit button").click();
|
|
4011
4767
|
else await container.locator("#bottom_main #js_send button").click();
|
|
4012
|
-
return (0,
|
|
4768
|
+
return (0, share_.success)("");
|
|
4013
4769
|
};
|
|
4014
4770
|
const weixinmpPublish = async (task, params)=>{
|
|
4015
4771
|
if ("rpa" === params.actionType) return weixinmpPublish_rpa_rpaAction(task, params);
|
|
4016
4772
|
if ("mockApi" === params.actionType) return weixinmpPublish_mock_mockAction(task, params);
|
|
4017
|
-
return
|
|
4773
|
+
return (0, utils.jo)(weixinmpPublish_mock_mockAction, weixinmpPublish_rpa_rpaAction)(task, params);
|
|
4018
4774
|
};
|
|
4019
|
-
class XsEncrypt {
|
|
4020
|
-
async encryptMD5(url) {
|
|
4021
|
-
return __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createHash("md5").update(url, "utf8").digest("hex");
|
|
4022
|
-
}
|
|
4023
|
-
async encryptText(text) {
|
|
4024
|
-
const textEncoded = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(text).toString("base64");
|
|
4025
|
-
const cipher = __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createCipheriv("aes-128-cbc", new Uint8Array(this.keyBytes), new Uint8Array(this.iv));
|
|
4026
|
-
const ciphertext = cipher.update(textEncoded, "utf8", "base64");
|
|
4027
|
-
return ciphertext + cipher.final("base64");
|
|
4028
|
-
}
|
|
4029
|
-
async base64ToHex(encodedData) {
|
|
4030
|
-
const decodedData = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(encodedData, "base64");
|
|
4031
|
-
return decodedData.toString("hex");
|
|
4032
|
-
}
|
|
4033
|
-
async encryptPayload(payload, platform) {
|
|
4034
|
-
const hexPayload = await this.base64ToHex(payload);
|
|
4035
|
-
const obj = {
|
|
4036
|
-
signSvn: "56",
|
|
4037
|
-
signType: "x2",
|
|
4038
|
-
appID: platform,
|
|
4039
|
-
signVersion: "1",
|
|
4040
|
-
payload: hexPayload
|
|
4041
|
-
};
|
|
4042
|
-
const jsonString = JSON.stringify(obj, null, 0);
|
|
4043
|
-
return __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(jsonString).toString("base64");
|
|
4044
|
-
}
|
|
4045
|
-
async encryptXs(url, a1, ts, platform = "xhs-pc-web") {
|
|
4046
|
-
const text = `x1=${await this.encryptMD5(`url=${url}`)};x2=0|0|0|1|0|0|1|0|0|0|1|0|0|0|0|1|0|0|0;x3=${a1};x4=${ts};`;
|
|
4047
|
-
return `XYW_${await this.encryptPayload(await this.encryptText(text), platform)}`;
|
|
4048
|
-
}
|
|
4049
|
-
dumps(...rest) {
|
|
4050
|
-
const [data, replacer = null, space = 0] = rest;
|
|
4051
|
-
return JSON.stringify(data, replacer, space).replace(/\n/g, "").replace(/":\s+"/g, '":"');
|
|
4052
|
-
}
|
|
4053
|
-
constructor(){
|
|
4054
|
-
this.words = [
|
|
4055
|
-
929260340,
|
|
4056
|
-
1633971297,
|
|
4057
|
-
895580464,
|
|
4058
|
-
925905270
|
|
4059
|
-
];
|
|
4060
|
-
this.keyBytes = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.concat(this.words.map((word)=>new Uint8Array(__WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from([
|
|
4061
|
-
word >> 24 & 0xff,
|
|
4062
|
-
word >> 16 & 0xff,
|
|
4063
|
-
word >> 8 & 0xff,
|
|
4064
|
-
0xff & word
|
|
4065
|
-
]))));
|
|
4066
|
-
this.iv = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from("4uzjr7mbsibcaldp", "utf8");
|
|
4067
|
-
}
|
|
4068
|
-
}
|
|
4069
4775
|
const xiaohongshuPublish_mock_errnoMap = {
|
|
4070
4776
|
915: "所属C端账号手机号被修改,请重新登录",
|
|
4777
|
+
914: "所属C端账号密码被修改,请重新登录",
|
|
4071
4778
|
903: "账户已登出,需重新登陆重试!",
|
|
4072
4779
|
902: "登录已过期,请重新登录!"
|
|
4073
4780
|
};
|
|
4074
|
-
const
|
|
4781
|
+
const mock_xsEncrypt = new xhsXsEncrypt.H();
|
|
4075
4782
|
const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
4076
4783
|
const tmpCachePath = task.getTmpPath();
|
|
4077
4784
|
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
@@ -4080,7 +4787,7 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
4080
4787
|
message: "账号数据异常,请重新绑定账号后重试。",
|
|
4081
4788
|
data: ""
|
|
4082
4789
|
};
|
|
4083
|
-
const http = new
|
|
4790
|
+
const http = new utils_http.e({
|
|
4084
4791
|
headers: {
|
|
4085
4792
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
4086
4793
|
origin: "https://creator.xiaohongshu.com",
|
|
@@ -4101,7 +4808,7 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
4101
4808
|
});
|
|
4102
4809
|
const fetchCoverUrl = `/api/media/v1/upload/creator/permit?biz_name=spectrum&scene=image&file_count=${params.banners.length}&version=1&source=web`;
|
|
4103
4810
|
const xt = Date.now().toString();
|
|
4104
|
-
const xs = await
|
|
4811
|
+
const xs = await mock_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt);
|
|
4105
4812
|
const coverIdInfo = await http.api({
|
|
4106
4813
|
method: "get",
|
|
4107
4814
|
baseURL: "https://creator.xiaohongshu.com",
|
|
@@ -4120,10 +4827,10 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
4120
4827
|
data: ""
|
|
4121
4828
|
};
|
|
4122
4829
|
const uploadFile = async (url, index)=>{
|
|
4123
|
-
const fileName = (0,
|
|
4124
|
-
const localUrl = await (0,
|
|
4830
|
+
const fileName = (0, share_.getFilenameFromUrl)(url);
|
|
4831
|
+
const localUrl = await (0, share_.downloadImage)(url, external_node_path_["default"].join(tmpCachePath, fileName));
|
|
4125
4832
|
const ossFileId = coverIds[index];
|
|
4126
|
-
const fileBuffer =
|
|
4833
|
+
const fileBuffer = external_node_fs_["default"].readFileSync(localUrl);
|
|
4127
4834
|
await http.api({
|
|
4128
4835
|
method: "put",
|
|
4129
4836
|
url: `https://ros-upload.xiaohongshu.com/${ossFileId}`,
|
|
@@ -4144,9 +4851,9 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
4144
4851
|
const topicData = {
|
|
4145
4852
|
topic_names: topic["name"]
|
|
4146
4853
|
};
|
|
4147
|
-
const topicDataStr =
|
|
4854
|
+
const topicDataStr = mock_xsEncrypt.dumps(topicData);
|
|
4148
4855
|
const publishXt = Date.now().toString();
|
|
4149
|
-
const publishXs = await
|
|
4856
|
+
const publishXs = await mock_xsEncrypt.encryptXs(`/web_api/sns/capa/postgw/topic/batch_customized${topicDataStr}`, a1Cookie, publishXt);
|
|
4150
4857
|
let createTopic = await http.api({
|
|
4151
4858
|
method: "POST",
|
|
4152
4859
|
url: "https://edith.xiaohongshu.com/web_api/sns/capa/postgw/topic/batch_customized",
|
|
@@ -4245,9 +4952,9 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
4245
4952
|
} : {}
|
|
4246
4953
|
};
|
|
4247
4954
|
publishData.common.business_binds = JSON.stringify(business_binds);
|
|
4248
|
-
const publishDataStr =
|
|
4955
|
+
const publishDataStr = mock_xsEncrypt.dumps(publishData);
|
|
4249
4956
|
const publishXt = Date.now().toString();
|
|
4250
|
-
const publishXs = await
|
|
4957
|
+
const publishXs = await mock_xsEncrypt.encryptXs(`/web_api/sns/v2/note${publishDataStr}`, a1Cookie, publishXt);
|
|
4251
4958
|
const publishResult = await http.api({
|
|
4252
4959
|
method: "post",
|
|
4253
4960
|
url: "https://edith.xiaohongshu.com/web_api/sns/v2/note",
|
|
@@ -4258,9 +4965,9 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
4258
4965
|
},
|
|
4259
4966
|
defaultErrorMsg: "文章发布异常,请稍后重试。"
|
|
4260
4967
|
});
|
|
4261
|
-
return (0,
|
|
4968
|
+
return (0, share_.success)(publishResult.data?.id);
|
|
4262
4969
|
};
|
|
4263
|
-
const rpa_xsEncrypt = new
|
|
4970
|
+
const rpa_xsEncrypt = new xhsXsEncrypt.H();
|
|
4264
4971
|
const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
|
|
4265
4972
|
const commonCookies = {
|
|
4266
4973
|
path: "/",
|
|
@@ -4369,8 +5076,8 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
4369
5076
|
hasText: /^上传图文$/
|
|
4370
5077
|
}).click();
|
|
4371
5078
|
const images = await Promise.all(params.banners.map((url)=>{
|
|
4372
|
-
const fileName = (0,
|
|
4373
|
-
return (0,
|
|
5079
|
+
const fileName = (0, share_.getFilenameFromUrl)(url);
|
|
5080
|
+
return (0, share_.downloadImage)(url, external_node_path_["default"].join(tmpCachePath, fileName));
|
|
4374
5081
|
}));
|
|
4375
5082
|
const fileChooserPromise = page.waitForEvent("filechooser");
|
|
4376
5083
|
await page.getByRole("textbox").click();
|
|
@@ -4468,15 +5175,15 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
4468
5175
|
page.locator(".submit .publishBtn").click();
|
|
4469
5176
|
});
|
|
4470
5177
|
await page.close();
|
|
4471
|
-
return (0,
|
|
5178
|
+
return (0, share_.success)(response);
|
|
4472
5179
|
};
|
|
4473
5180
|
const xiaohongshuPublish = async (task, params)=>{
|
|
4474
5181
|
if ("rpa" === params.actionType) return xiaohongshuPublish_rpa_rpaAction(task, params);
|
|
4475
5182
|
if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
|
|
4476
|
-
return
|
|
5183
|
+
return (0, utils.jo)(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
|
|
4477
5184
|
};
|
|
4478
5185
|
var package_namespaceObject = {
|
|
4479
|
-
i8: "1.2.
|
|
5186
|
+
i8: "1.2.13"
|
|
4480
5187
|
};
|
|
4481
5188
|
class Action {
|
|
4482
5189
|
constructor(task){
|
|
@@ -4489,15 +5196,33 @@ class Action {
|
|
|
4489
5196
|
try {
|
|
4490
5197
|
responseData = await func(this.task, params);
|
|
4491
5198
|
} catch (error) {
|
|
4492
|
-
responseData =
|
|
5199
|
+
responseData = utils_http.e.handleApiError(error);
|
|
4493
5200
|
}
|
|
4494
5201
|
if (200 === responseData.code) this.task.logger.info(`${func.name} action params error`, responseData);
|
|
4495
5202
|
else if (0 !== responseData.code) {
|
|
4496
|
-
this.task.logger.error(responseData.message || `${func.name} 执行失败`,
|
|
5203
|
+
this.task.logger.error(responseData.message || `${func.name} 执行失败`, (0, utils.n)(responseData.data), responseData.extra);
|
|
4497
5204
|
this.task.logger.info(`${func.name} action failed`);
|
|
4498
5205
|
} else this.task.logger.info(`${func.name} action success`);
|
|
4499
5206
|
return responseData;
|
|
4500
5207
|
}
|
|
5208
|
+
FetchArticles(params) {
|
|
5209
|
+
return this.bindTask(FetchArticles, params);
|
|
5210
|
+
}
|
|
5211
|
+
SearchAccountInfo(params) {
|
|
5212
|
+
return this.bindTask(searchAccountInfo.A, params);
|
|
5213
|
+
}
|
|
5214
|
+
TTSessionCheck(params) {
|
|
5215
|
+
return this.bindTask(TTSessionCheck, params);
|
|
5216
|
+
}
|
|
5217
|
+
WxSessionCheck(params) {
|
|
5218
|
+
return this.bindTask(WxSessionCheck, params);
|
|
5219
|
+
}
|
|
5220
|
+
XhsSessionCheck(params) {
|
|
5221
|
+
return this.bindTask(XhsSessionCheck, params);
|
|
5222
|
+
}
|
|
5223
|
+
BjhSessionCheck(params) {
|
|
5224
|
+
return this.bindTask(BjhSessionCheck, params);
|
|
5225
|
+
}
|
|
4501
5226
|
searchToutiaoTopicList(params) {
|
|
4502
5227
|
return this.bindTask(searchToutiaoTopicList, params);
|
|
4503
5228
|
}
|
|
@@ -4522,6 +5247,9 @@ class Action {
|
|
|
4522
5247
|
getToutiaoConfig(params) {
|
|
4523
5248
|
return this.bindTask(getToutiaoConfig, params);
|
|
4524
5249
|
}
|
|
5250
|
+
getWeixinConfig(params) {
|
|
5251
|
+
return this.bindTask(getWeixinConfig, params);
|
|
5252
|
+
}
|
|
4525
5253
|
getBaijiahaoConfig(params) {
|
|
4526
5254
|
return this.bindTask(getBaijiahaoConfig, params);
|
|
4527
5255
|
}
|