@iflyrpa/actions 1.2.14-beta.3 → 1.2.14-beta.4
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/searchPublishInfo/types.d.ts +2 -1
- package/dist/bundle.js +11762 -11807
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +544 -578
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +549 -588
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,374 +1,15 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
1
3
|
import * as __WEBPACK_EXTERNAL_MODULE_dom_serializer_aa70940b__ from "dom-serializer";
|
|
2
4
|
import * as __WEBPACK_EXTERNAL_MODULE_domhandler__ from "domhandler";
|
|
3
5
|
import * as __WEBPACK_EXTERNAL_MODULE_htmlparser2__ from "htmlparser2";
|
|
4
6
|
import * as __WEBPACK_EXTERNAL_MODULE_mime_types_eebf54a5__ from "mime-types";
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__ from "@iflyrpa/share";
|
|
6
7
|
import * as __WEBPACK_EXTERNAL_MODULE_axios__ from "axios";
|
|
7
|
-
import * as
|
|
8
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__ from "@iflyrpa/share";
|
|
9
9
|
import * as __WEBPACK_EXTERNAL_MODULE_form_data_cf000082__ from "form-data";
|
|
10
10
|
import * as __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__ from "node:buffer";
|
|
11
11
|
import * as __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__ from "node:crypto";
|
|
12
12
|
var __webpack_modules__ = {
|
|
13
|
-
"./src/actions/searchAccountInfo/getWxInfo.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
14
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
15
|
-
n: ()=>getWeixinData
|
|
16
|
-
});
|
|
17
|
-
var _iflyrpa_share__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("@iflyrpa/share");
|
|
18
|
-
var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/actions/searchAccountInfo/types.ts");
|
|
19
|
-
var _utils_http__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/utils/http.ts");
|
|
20
|
-
var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
|
|
21
|
-
async function getWeixinData(params) {
|
|
22
|
-
const { token } = params;
|
|
23
|
-
if (!token) return {
|
|
24
|
-
code: 200,
|
|
25
|
-
message: "缺少token",
|
|
26
|
-
data: null
|
|
27
|
-
};
|
|
28
|
-
try {
|
|
29
|
-
const { token } = params;
|
|
30
|
-
if (!token) return (0, _types__WEBPACK_IMPORTED_MODULE_1__.V)("缺少token", 200);
|
|
31
|
-
const http = new _utils_http__WEBPACK_IMPORTED_MODULE_2__.e({
|
|
32
|
-
headers: {
|
|
33
|
-
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
const massRandomIDHtml = await http.api({
|
|
37
|
-
method: "get",
|
|
38
|
-
url: "https://mp.weixin.qq.com/misc/appmsganalysis",
|
|
39
|
-
params: {
|
|
40
|
-
token,
|
|
41
|
-
lang: "zh_CN",
|
|
42
|
-
action: "report"
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
const massRandomIDReg = massRandomIDHtml.match(/mass_all\.([a-z0-9]+)\.js/);
|
|
46
|
-
const massRandomID = massRandomIDReg ? massRandomIDReg[1] : "";
|
|
47
|
-
const [readInfo, fansInfoHtml] = await Promise.all([
|
|
48
|
-
http.api({
|
|
49
|
-
method: "get",
|
|
50
|
-
url: `https://res.wx.qq.com/mpres/zh_CN/htmledition/pages/statistics/mass_all/mass_all.${massRandomID}.js`
|
|
51
|
-
}),
|
|
52
|
-
http.api({
|
|
53
|
-
method: "get",
|
|
54
|
-
url: "https://mp.weixin.qq.com/misc/useranalysis",
|
|
55
|
-
params: {
|
|
56
|
-
token,
|
|
57
|
-
lang: "zh_CN"
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
]);
|
|
61
|
-
const regex = /(readAllList|shareAllList|completeAllList):\s*(\[[^\]]+\])/g;
|
|
62
|
-
let match;
|
|
63
|
-
const arrays = {};
|
|
64
|
-
while(null !== (match = regex.exec(readInfo)))arrays[match[1]] = JSON.parse(match[2]);
|
|
65
|
-
const readAllList = arrays.readAllList || [];
|
|
66
|
-
const shareAllList = arrays.shareAllList || [];
|
|
67
|
-
const fansInfoReg = fansInfoHtml.match(/window\.CGI_DATA\['pages\/statistics\/user_statistics'\]\s*=\s*(\{[\s\S]*?\});/);
|
|
68
|
-
if (!fansInfoReg) return (0, _types__WEBPACK_IMPORTED_MODULE_1__.V)("未找到粉丝信息", 200);
|
|
69
|
-
const fansInfo = eval("(" + fansInfoReg[1] + ")");
|
|
70
|
-
const yesterday = _utils__WEBPACK_IMPORTED_MODULE_3__.Tx.format(new Date().setDate(new Date().getDate() - 1), "yyyy-MM-dd");
|
|
71
|
-
const yesterdayFansInfo = fansInfo.list[0]?.list.find((item)=>item.date === yesterday);
|
|
72
|
-
if (!yesterdayFansInfo) return (0, _types__WEBPACK_IMPORTED_MODULE_1__.V)("未找到粉丝数", 200);
|
|
73
|
-
const wxData = {
|
|
74
|
-
fansNum: yesterdayFansInfo.cumulate_user,
|
|
75
|
-
fansNumYesterday: yesterdayFansInfo.new_user - yesterdayFansInfo.cancel_user,
|
|
76
|
-
readNumYesterday: readAllList[0] || 0,
|
|
77
|
-
shareNumYesterday: shareAllList[0] || 0
|
|
78
|
-
};
|
|
79
|
-
return (0, _iflyrpa_share__WEBPACK_IMPORTED_MODULE_0__.success)(wxData, "微信粉丝数据获取成功!");
|
|
80
|
-
} catch (error) {
|
|
81
|
-
return (0, _types__WEBPACK_IMPORTED_MODULE_1__.V)(error instanceof Error ? error.message : "微信数据获取失败");
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
"./src/actions/searchAccountInfo/types.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
86
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
87
|
-
V: ()=>errorResponse
|
|
88
|
-
});
|
|
89
|
-
const errorResponse = (message, code = 500)=>({
|
|
90
|
-
code,
|
|
91
|
-
message,
|
|
92
|
-
data: null
|
|
93
|
-
});
|
|
94
|
-
},
|
|
95
|
-
"./src/utils/http.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
96
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
97
|
-
e: ()=>Http
|
|
98
|
-
});
|
|
99
|
-
var external_axios_ = __webpack_require__("axios");
|
|
100
|
-
class Http {
|
|
101
|
-
static handleApiError(error) {
|
|
102
|
-
if (error && "object" == typeof error && "code" in error && "message" in error) return error;
|
|
103
|
-
return {
|
|
104
|
-
code: 500,
|
|
105
|
-
message: "",
|
|
106
|
-
data: error
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
constructor(config){
|
|
110
|
-
this.apiClient = external_axios_["default"].create(config);
|
|
111
|
-
}
|
|
112
|
-
addResponseInterceptor(findError) {
|
|
113
|
-
this.apiClient.interceptors.response.use((response)=>{
|
|
114
|
-
const error = findError(response);
|
|
115
|
-
if (error) return Promise.reject(Object.assign(error, {
|
|
116
|
-
extra: {
|
|
117
|
-
method: response.config.method,
|
|
118
|
-
url: response.config.url
|
|
119
|
-
}
|
|
120
|
-
}));
|
|
121
|
-
return response;
|
|
122
|
-
}, (error)=>{
|
|
123
|
-
const errorResponse = {
|
|
124
|
-
code: error.response?.status || 500,
|
|
125
|
-
message: error.message || "",
|
|
126
|
-
data: error.response?.data,
|
|
127
|
-
extra: {
|
|
128
|
-
method: error.config?.method,
|
|
129
|
-
url: error.config?.url
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
if (error.response?.data) {
|
|
133
|
-
if ("object" == typeof error.response.data) {
|
|
134
|
-
const serverError = error.response.data;
|
|
135
|
-
if (serverError.message) errorResponse.message = serverError.message;
|
|
136
|
-
errorResponse.data = serverError;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return Promise.reject(errorResponse);
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
async api(config) {
|
|
143
|
-
try {
|
|
144
|
-
const response = await this.apiClient(config);
|
|
145
|
-
return response.data;
|
|
146
|
-
} catch (error) {
|
|
147
|
-
return Promise.reject(Http.handleApiError(error));
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
"./src/utils/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
153
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
154
|
-
hc: ()=>parseUrlQueryString,
|
|
155
|
-
I: ()=>replaceImgSrc,
|
|
156
|
-
E_: ()=>extractImgTag,
|
|
157
|
-
i9: ()=>getRandomInRange,
|
|
158
|
-
f8: ()=>PopupListener,
|
|
159
|
-
qN: ()=>copyHtmlToClipboard,
|
|
160
|
-
Tx: ()=>TimeFormatter,
|
|
161
|
-
Tb: ()=>defaultParams,
|
|
162
|
-
n: ()=>stringifyError,
|
|
163
|
-
H8: ()=>getFileState,
|
|
164
|
-
jo: ()=>executeAction,
|
|
165
|
-
e0: ()=>calculateCropCoordinates
|
|
166
|
-
});
|
|
167
|
-
var external_node_fs_ = __webpack_require__("node:fs");
|
|
168
|
-
var external_node_path_ = __webpack_require__("node:path");
|
|
169
|
-
var http = __webpack_require__("./src/utils/http.ts");
|
|
170
|
-
function getRandomInRange(min, max) {
|
|
171
|
-
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
172
|
-
}
|
|
173
|
-
const getFileState = (filePath)=>{
|
|
174
|
-
const filename = external_node_path_["default"].basename(filePath);
|
|
175
|
-
const fileType = __WEBPACK_EXTERNAL_MODULE_mime_types_eebf54a5__["default"].lookup(filePath);
|
|
176
|
-
const stats = external_node_fs_["default"].statSync(filePath);
|
|
177
|
-
const fileSize = stats.size;
|
|
178
|
-
const lastModifiedDate = stats.mtime;
|
|
179
|
-
return {
|
|
180
|
-
name: filename,
|
|
181
|
-
type: fileType,
|
|
182
|
-
size: fileSize,
|
|
183
|
-
lastModifiedDate: lastModifiedDate.toString()
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
const calculateCropCoordinates = (width, height, aspectRatio)=>{
|
|
187
|
-
const targetRatio = aspectRatio[0] / aspectRatio[1];
|
|
188
|
-
let cropWidth;
|
|
189
|
-
let cropHeight;
|
|
190
|
-
if (width / height > targetRatio) {
|
|
191
|
-
cropHeight = height;
|
|
192
|
-
cropWidth = height * targetRatio;
|
|
193
|
-
} else {
|
|
194
|
-
cropWidth = width;
|
|
195
|
-
cropHeight = width / targetRatio;
|
|
196
|
-
}
|
|
197
|
-
const x1 = (width - cropWidth) / 2;
|
|
198
|
-
const y1 = (height - cropHeight) / 2;
|
|
199
|
-
const x2 = x1 + cropWidth;
|
|
200
|
-
const y2 = y1 + cropHeight;
|
|
201
|
-
return {
|
|
202
|
-
x1: x1 / width,
|
|
203
|
-
y1: y1 / height,
|
|
204
|
-
x2: x2 / width,
|
|
205
|
-
y2: y2 / height
|
|
206
|
-
};
|
|
207
|
-
};
|
|
208
|
-
const extractImgTag = (html)=>{
|
|
209
|
-
const srcList = [];
|
|
210
|
-
const parser = new __WEBPACK_EXTERNAL_MODULE_htmlparser2__.Parser({
|
|
211
|
-
onopentag (name, attributes) {
|
|
212
|
-
if ("img" === name && (attributes.src.trim() || attributes.currentSrc.trim())) srcList.push(attributes.src.trim() || attributes.currentSrc.trim());
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
parser.write(html);
|
|
216
|
-
parser.end();
|
|
217
|
-
return srcList;
|
|
218
|
-
};
|
|
219
|
-
class TimeFormatter {
|
|
220
|
-
static format(timestamp, formatStr = 'yyyy-MM-dd hh:mm') {
|
|
221
|
-
if ('number' == typeof timestamp && 10 === timestamp.toString().length) timestamp *= 1000;
|
|
222
|
-
const date = new Date(timestamp);
|
|
223
|
-
const map = {
|
|
224
|
-
yyyy: String(date.getFullYear()),
|
|
225
|
-
yy: String(date.getFullYear()).slice(-2),
|
|
226
|
-
MM: String(date.getMonth() + 1).padStart(2, '0'),
|
|
227
|
-
dd: String(date.getDate()).padStart(2, '0'),
|
|
228
|
-
hh: String(date.getHours()).padStart(2, '0'),
|
|
229
|
-
mm: String(date.getMinutes()).padStart(2, '0'),
|
|
230
|
-
ss: String(date.getSeconds()).padStart(2, '0'),
|
|
231
|
-
M: String(date.getMonth() + 1),
|
|
232
|
-
d: String(date.getDate()),
|
|
233
|
-
h: String(date.getHours()),
|
|
234
|
-
m: String(date.getMinutes()),
|
|
235
|
-
s: String(date.getSeconds())
|
|
236
|
-
};
|
|
237
|
-
return formatStr.replace(/yyyy|yy|MM|dd|hh|mm|ss|M|d|h|m|s/g, (key)=>map[key]);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
const replaceImgSrc = (html, callback)=>{
|
|
241
|
-
let lastedHtml = html;
|
|
242
|
-
const isImageTag = (node)=>"tag" === node.type && "img" === node.name;
|
|
243
|
-
const traverseDom = (node)=>{
|
|
244
|
-
if (__WEBPACK_EXTERNAL_MODULE_htmlparser2__.DomUtils.hasChildren(node)) for (const child of node.children){
|
|
245
|
-
if (isImageTag(child)) callback(child);
|
|
246
|
-
traverseDom(child);
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
const handler = new __WEBPACK_EXTERNAL_MODULE_domhandler__.DomHandler((error, dom)=>{
|
|
250
|
-
if (error) console.log(error);
|
|
251
|
-
else dom.forEach(traverseDom);
|
|
252
|
-
lastedHtml = (0, __WEBPACK_EXTERNAL_MODULE_dom_serializer_aa70940b__["default"])(dom, {
|
|
253
|
-
decodeEntities: false
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
const parser = new __WEBPACK_EXTERNAL_MODULE_htmlparser2__.Parser(handler, {
|
|
257
|
-
decodeEntities: false
|
|
258
|
-
});
|
|
259
|
-
parser.write(html);
|
|
260
|
-
parser.end();
|
|
261
|
-
return lastedHtml;
|
|
262
|
-
};
|
|
263
|
-
const stringifyError = (error)=>{
|
|
264
|
-
if (error instanceof Error) return error.toString();
|
|
265
|
-
if ("object" == typeof error) return JSON.stringify(error);
|
|
266
|
-
return error;
|
|
267
|
-
};
|
|
268
|
-
const executeAction = (...actions)=>async (task, params)=>{
|
|
269
|
-
let result = {
|
|
270
|
-
code: 500,
|
|
271
|
-
message: "",
|
|
272
|
-
data: null
|
|
273
|
-
};
|
|
274
|
-
for(let index = 0; index < actions.length; index++){
|
|
275
|
-
const action = actions[index];
|
|
276
|
-
try {
|
|
277
|
-
result = await action(task, params);
|
|
278
|
-
} catch (error) {
|
|
279
|
-
result = http.e.handleApiError(error);
|
|
280
|
-
}
|
|
281
|
-
if (0 === result.code || 200 === result.code) break;
|
|
282
|
-
if (index !== actions.length - 1) task.logger.error(result.message, stringifyError(result.data), result.extra);
|
|
283
|
-
}
|
|
284
|
-
return result;
|
|
285
|
-
};
|
|
286
|
-
async function copyHtmlToClipboard(page, html, options = {
|
|
287
|
-
format: "text/html",
|
|
288
|
-
fallback: true
|
|
289
|
-
}) {
|
|
290
|
-
try {
|
|
291
|
-
await page.evaluate(async ({ htmlContent, format })=>{
|
|
292
|
-
const blob = new Blob([
|
|
293
|
-
htmlContent
|
|
294
|
-
], {
|
|
295
|
-
type: format
|
|
296
|
-
});
|
|
297
|
-
await navigator.clipboard.write([
|
|
298
|
-
new ClipboardItem({
|
|
299
|
-
[format]: blob
|
|
300
|
-
})
|
|
301
|
-
]);
|
|
302
|
-
}, {
|
|
303
|
-
htmlContent: html,
|
|
304
|
-
format: options.format
|
|
305
|
-
});
|
|
306
|
-
} catch (error) {
|
|
307
|
-
if (options.fallback) await page.evaluate((htmlContent)=>{
|
|
308
|
-
const div = document.createElement("div");
|
|
309
|
-
div.contentEditable = "true";
|
|
310
|
-
div.style.cssText = `
|
|
311
|
-
position: fixed;
|
|
312
|
-
left: -9999px;
|
|
313
|
-
opacity: 0;
|
|
314
|
-
pointer-events: none;
|
|
315
|
-
`;
|
|
316
|
-
div.innerHTML = htmlContent;
|
|
317
|
-
document.body.appendChild(div);
|
|
318
|
-
const range = document.createRange();
|
|
319
|
-
range.selectNodeContents(div);
|
|
320
|
-
const selection = window.getSelection();
|
|
321
|
-
selection.removeAllRanges();
|
|
322
|
-
selection.addRange(range);
|
|
323
|
-
document.execCommand("copy");
|
|
324
|
-
document.body.removeChild(div);
|
|
325
|
-
selection.removeAllRanges();
|
|
326
|
-
}, html);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
function PopupListener(page, popupSelector, popKey, buttonSelector, options = {}) {
|
|
330
|
-
const { checkInterval = 1000, stopAfterClick = false } = options;
|
|
331
|
-
const popup = page.locator(popupSelector);
|
|
332
|
-
const button = page.locator(buttonSelector);
|
|
333
|
-
const intervalId = setInterval(async ()=>{
|
|
334
|
-
try {
|
|
335
|
-
if (await popup.count() > 0 && await popup.isVisible() && (await popup.textContent() || "").includes(popKey)) {
|
|
336
|
-
await button.click({
|
|
337
|
-
force: true
|
|
338
|
-
});
|
|
339
|
-
if (stopAfterClick) clearInterval(intervalId);
|
|
340
|
-
}
|
|
341
|
-
} catch (err) {}
|
|
342
|
-
}, checkInterval);
|
|
343
|
-
return ()=>{
|
|
344
|
-
clearInterval(intervalId);
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
const parseUrlQueryString = (url)=>{
|
|
348
|
-
const queryStringObject = {};
|
|
349
|
-
if (!url || !url.includes("?")) return queryStringObject;
|
|
350
|
-
const queryString = url.split("?")[1];
|
|
351
|
-
if (!queryString) return queryStringObject;
|
|
352
|
-
const queryWithoutHash = queryString.split("#")[0];
|
|
353
|
-
const queryStringArray = queryWithoutHash.split("&");
|
|
354
|
-
for (const item of queryStringArray){
|
|
355
|
-
if (!item) continue;
|
|
356
|
-
const equalIndex = item.indexOf("=");
|
|
357
|
-
if (-1 === equalIndex) queryStringObject[item] = "";
|
|
358
|
-
else {
|
|
359
|
-
const key = item.slice(0, equalIndex);
|
|
360
|
-
const value = item.slice(equalIndex + 1);
|
|
361
|
-
try {
|
|
362
|
-
queryStringObject[key] = decodeURIComponent(value);
|
|
363
|
-
} catch (e) {
|
|
364
|
-
queryStringObject[key] = value;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
return queryStringObject;
|
|
369
|
-
};
|
|
370
|
-
const defaultParams = (params, defaults)=>Object.assign({}, defaults, params);
|
|
371
|
-
},
|
|
372
13
|
"./src/utils/ttABEncrypt.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
373
14
|
module = __webpack_require__.nmd(module);
|
|
374
15
|
const a0_0x45db08 = a0_0x4b0d;
|
|
@@ -1450,18 +1091,6 @@ var __webpack_modules__ = {
|
|
|
1450
1091
|
return Data2A_B(Base2Data(EnvData2CharCode(_0x315138, _0x1c32b3, _0x56536b)));
|
|
1451
1092
|
}
|
|
1452
1093
|
module[a0_0x45db08(0xae)] = GenAB;
|
|
1453
|
-
},
|
|
1454
|
-
"@iflyrpa/share": function(module) {
|
|
1455
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__;
|
|
1456
|
-
},
|
|
1457
|
-
axios: function(module) {
|
|
1458
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_axios__;
|
|
1459
|
-
},
|
|
1460
|
-
"node:fs": function(module) {
|
|
1461
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
|
|
1462
|
-
},
|
|
1463
|
-
"node:path": function(module) {
|
|
1464
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__;
|
|
1465
1094
|
}
|
|
1466
1095
|
};
|
|
1467
1096
|
var __webpack_module_cache__ = {};
|
|
@@ -1477,19 +1106,6 @@ function __webpack_require__(moduleId) {
|
|
|
1477
1106
|
module.loaded = true;
|
|
1478
1107
|
return module.exports;
|
|
1479
1108
|
}
|
|
1480
|
-
(()=>{
|
|
1481
|
-
__webpack_require__.d = function(exports, definition) {
|
|
1482
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
1483
|
-
enumerable: true,
|
|
1484
|
-
get: definition[key]
|
|
1485
|
-
});
|
|
1486
|
-
};
|
|
1487
|
-
})();
|
|
1488
|
-
(()=>{
|
|
1489
|
-
__webpack_require__.o = function(obj, prop) {
|
|
1490
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
1491
|
-
};
|
|
1492
|
-
})();
|
|
1493
1109
|
(()=>{
|
|
1494
1110
|
__webpack_require__.nmd = function(module) {
|
|
1495
1111
|
module.paths = [];
|
|
@@ -1497,11 +1113,258 @@ function __webpack_require__(moduleId) {
|
|
|
1497
1113
|
return module;
|
|
1498
1114
|
};
|
|
1499
1115
|
})();
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1116
|
+
class Http {
|
|
1117
|
+
static handleApiError(error) {
|
|
1118
|
+
if (error && "object" == typeof error && "code" in error && "message" in error) return error;
|
|
1119
|
+
return {
|
|
1120
|
+
code: 500,
|
|
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);
|
|
1505
1368
|
const errnoMap = {
|
|
1506
1369
|
20040706: "正文图片和封面图片推荐jpg、png格式。",
|
|
1507
1370
|
20040084: "正文图片和封面图片推荐jpg、png格式。",
|
|
@@ -1520,7 +1383,7 @@ const errnoMap = {
|
|
|
1520
1383
|
const mockAction = async (task, params)=>{
|
|
1521
1384
|
const { baijiahaoSingleCover, baijiahaoMultCover, baijiahaoCoverType } = params.settingInfo;
|
|
1522
1385
|
const tmpCachePath = task.getTmpPath();
|
|
1523
|
-
const http = new
|
|
1386
|
+
const http = new Http({
|
|
1524
1387
|
headers: {
|
|
1525
1388
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1526
1389
|
token: params.token
|
|
@@ -1554,8 +1417,8 @@ const mockAction = async (task, params)=>{
|
|
|
1554
1417
|
const uploadImages = async (_images)=>{
|
|
1555
1418
|
const images = _images.filter((url)=>!!url && "" !== url.trim());
|
|
1556
1419
|
return await Promise.all(images.map(async (url)=>{
|
|
1557
|
-
const fileName = (0,
|
|
1558
|
-
const image = await (0,
|
|
1420
|
+
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
1421
|
+
const image = await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
1559
1422
|
const formData = new __WEBPACK_EXTERNAL_MODULE_form_data_cf000082__["default"]();
|
|
1560
1423
|
formData.append("org_file_name", fileName);
|
|
1561
1424
|
formData.append("type", "image");
|
|
@@ -1564,7 +1427,7 @@ const mockAction = async (task, params)=>{
|
|
|
1564
1427
|
formData.append("save_material", "1");
|
|
1565
1428
|
formData.append("no_compress", "0");
|
|
1566
1429
|
formData.append("article_type", "news");
|
|
1567
|
-
formData.append("media",
|
|
1430
|
+
formData.append("media", __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].createReadStream(image));
|
|
1568
1431
|
const res = await http.api({
|
|
1569
1432
|
method: "post",
|
|
1570
1433
|
url: "https://baijiahao.baidu.com/materialui/picture/uploadProxy",
|
|
@@ -1574,9 +1437,9 @@ const mockAction = async (task, params)=>{
|
|
|
1574
1437
|
return res.ret;
|
|
1575
1438
|
}));
|
|
1576
1439
|
};
|
|
1577
|
-
const originContentImages = (
|
|
1440
|
+
const originContentImages = extractImgTag(params.content);
|
|
1578
1441
|
const targetContentImages = await uploadImages(originContentImages);
|
|
1579
|
-
const content = (
|
|
1442
|
+
const content = replaceImgSrc(params.content, (dom)=>{
|
|
1580
1443
|
if (dom.attribs.src) {
|
|
1581
1444
|
const idx = originContentImages.findIndex((it)=>it === dom.attribs.src);
|
|
1582
1445
|
dom.attribs.src = targetContentImages[idx].bos_url;
|
|
@@ -1651,7 +1514,7 @@ const mockAction = async (task, params)=>{
|
|
|
1651
1514
|
},
|
|
1652
1515
|
defaultErrorMsg: isDraft ? "文章同步出现异常,请稍后重试。" : "文章发布出现异常,请稍后重试。"
|
|
1653
1516
|
});
|
|
1654
|
-
return (0,
|
|
1517
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(res.ret.article_id, "百家号发布完成。");
|
|
1655
1518
|
};
|
|
1656
1519
|
const rpaAction = async (task, params)=>{
|
|
1657
1520
|
const tmpCachePath = task.getTmpPath();
|
|
@@ -1689,7 +1552,7 @@ const rpaAction = async (task, params)=>{
|
|
|
1689
1552
|
const titleInstance = page.locator("#ueditor #bjhNewsTitle .input-box textarea");
|
|
1690
1553
|
await titleInstance.click();
|
|
1691
1554
|
await titleInstance.fill(params.title);
|
|
1692
|
-
await (
|
|
1555
|
+
await copyHtmlToClipboard(page, params.content);
|
|
1693
1556
|
await page.click("#ueditor .edui-editor-iframeholder iframe");
|
|
1694
1557
|
await page.keyboard.press("Control+A");
|
|
1695
1558
|
await page.keyboard.press("Control+V");
|
|
@@ -1705,8 +1568,8 @@ const rpaAction = async (task, params)=>{
|
|
|
1705
1568
|
const images = await Promise.all((isSingleCover ? [
|
|
1706
1569
|
params.settingInfo.baijiahaoSingleCover
|
|
1707
1570
|
] : params.settingInfo.baijiahaoMultCover).map((url)=>{
|
|
1708
|
-
const fileName = (0,
|
|
1709
|
-
return (0,
|
|
1571
|
+
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
1572
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
1710
1573
|
}));
|
|
1711
1574
|
const coverSelector = page.locator(".cheetah-form-item-control .edit-cover-container .cover-list .DraggableTags-tag-drag .coverUploaderView");
|
|
1712
1575
|
const coverCount = await coverSelector.count();
|
|
@@ -1789,7 +1652,7 @@ const rpaAction = async (task, params)=>{
|
|
|
1789
1652
|
hasText: "日"
|
|
1790
1653
|
}).click();
|
|
1791
1654
|
await page.locator('#select-date_list + * .cheetah-select-item-option', {
|
|
1792
|
-
hasText:
|
|
1655
|
+
hasText: TimeFormatter.format(params.settingInfo.timer, "M月dd日")
|
|
1793
1656
|
}).click();
|
|
1794
1657
|
await page.waitForTimeout(200);
|
|
1795
1658
|
await page.locator(".timepublish-wrap-select .select-wrap", {
|
|
@@ -1810,7 +1673,7 @@ const rpaAction = async (task, params)=>{
|
|
|
1810
1673
|
let fistHourElemH = Number(fistHourElem?.split("点")[0]);
|
|
1811
1674
|
const lastHourElem = scrollHourInfo.elementItem[scrollHourInfo.elementItem.length - 1];
|
|
1812
1675
|
let lastHourElemH = Number(lastHourElem?.split("点")[0]);
|
|
1813
|
-
let targetTimeH = Number(
|
|
1676
|
+
let targetTimeH = Number(TimeFormatter.format(params.settingInfo.timer, 'h'));
|
|
1814
1677
|
await page.mouse.wheel(0, targetTimeH > lastHourElemH ? (targetTimeH - lastHourElemH) * scrollHourInfo.elementHeight : targetTimeH < fistHourElemH ? -(fistHourElemH - targetTimeH) * scrollHourInfo.elementHeight : 0);
|
|
1815
1678
|
await page.locator("#select-hour_list + * .cheetah-select-item-option ", {
|
|
1816
1679
|
hasText: targetTimeH + "点"
|
|
@@ -1834,7 +1697,7 @@ const rpaAction = async (task, params)=>{
|
|
|
1834
1697
|
let fistMinuteElemH = Number(fistMinuteElem?.split("分")[0]);
|
|
1835
1698
|
const lastMinuteElem = scrollMinuteInfo.elementItem[scrollMinuteInfo.elementItem.length - 1];
|
|
1836
1699
|
let lastMinuteElemH = Number(lastMinuteElem?.split("分")[0]);
|
|
1837
|
-
let targetTimeM = Number(
|
|
1700
|
+
let targetTimeM = Number(TimeFormatter.format(params.settingInfo.timer, 'm'));
|
|
1838
1701
|
await page.mouse.wheel(0, targetTimeM > lastMinuteElemH ? (targetTimeM - lastMinuteElemH) * scrollMinuteInfo.elementHeight : targetTimeM < fistMinuteElemH ? -(fistMinuteElemH - targetTimeM) * scrollMinuteInfo.elementHeight : 0);
|
|
1839
1702
|
await page.locator("#select-minute_list + * .cheetah-select-item-option ", {
|
|
1840
1703
|
hasText: targetTimeM + "分"
|
|
@@ -1848,16 +1711,16 @@ const rpaAction = async (task, params)=>{
|
|
|
1848
1711
|
}).locator("button").click();
|
|
1849
1712
|
});
|
|
1850
1713
|
await page.close();
|
|
1851
|
-
return (0,
|
|
1714
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(articleId, articleId ? "发布成功" : message);
|
|
1852
1715
|
};
|
|
1853
1716
|
const baijiahaoPublish = async (task, params)=>{
|
|
1854
1717
|
if ("rpa" === params.actionType) return rpaAction(task, params);
|
|
1855
1718
|
if ("mockApi" === params.actionType) return mockAction(task, params);
|
|
1856
|
-
return (
|
|
1719
|
+
return executeAction(mockAction, rpaAction)(task, params);
|
|
1857
1720
|
};
|
|
1858
1721
|
const getBaijiahaoActivity = async (_task, params)=>{
|
|
1859
1722
|
const cookies = params.cookies ?? [];
|
|
1860
|
-
const http = new
|
|
1723
|
+
const http = new Http({
|
|
1861
1724
|
headers: {
|
|
1862
1725
|
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1863
1726
|
token: params.token
|
|
@@ -1875,11 +1738,11 @@ const getBaijiahaoActivity = async (_task, params)=>{
|
|
|
1875
1738
|
task_type: -1
|
|
1876
1739
|
}
|
|
1877
1740
|
});
|
|
1878
|
-
return (0,
|
|
1741
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(res?.data?.list ?? []);
|
|
1879
1742
|
};
|
|
1880
1743
|
const getToutiaoConfig = async (_task, params)=>{
|
|
1881
1744
|
const cookies = params.cookies ?? [];
|
|
1882
|
-
const http = new
|
|
1745
|
+
const http = new Http({
|
|
1883
1746
|
headers: {
|
|
1884
1747
|
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1885
1748
|
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
@@ -1927,7 +1790,7 @@ const getToutiaoConfig = async (_task, params)=>{
|
|
|
1927
1790
|
getCityDistrict(),
|
|
1928
1791
|
getUserRights()
|
|
1929
1792
|
]);
|
|
1930
|
-
return (0,
|
|
1793
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
1931
1794
|
suggestWords,
|
|
1932
1795
|
cityDistrict,
|
|
1933
1796
|
userRights
|
|
@@ -1935,7 +1798,7 @@ const getToutiaoConfig = async (_task, params)=>{
|
|
|
1935
1798
|
};
|
|
1936
1799
|
const getBaijiahaoConfig = async (_task, params)=>{
|
|
1937
1800
|
const cookies = params.cookies ?? [];
|
|
1938
|
-
const http = new
|
|
1801
|
+
const http = new Http({
|
|
1939
1802
|
headers: {
|
|
1940
1803
|
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1941
1804
|
token: params.token
|
|
@@ -1961,10 +1824,10 @@ const getBaijiahaoConfig = async (_task, params)=>{
|
|
|
1961
1824
|
is_enable: 1,
|
|
1962
1825
|
publish_num_left: res.data.ability.publish_num_left
|
|
1963
1826
|
});
|
|
1964
|
-
return (0,
|
|
1827
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(data, "获取百家号配置项成功!");
|
|
1965
1828
|
};
|
|
1966
1829
|
const searchToutiaoTopicList = async (_task, params)=>{
|
|
1967
|
-
const http = new
|
|
1830
|
+
const http = new Http({
|
|
1968
1831
|
headers: {
|
|
1969
1832
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1970
1833
|
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
@@ -1979,14 +1842,14 @@ const searchToutiaoTopicList = async (_task, params)=>{
|
|
|
1979
1842
|
words: params.searchValue
|
|
1980
1843
|
}
|
|
1981
1844
|
});
|
|
1982
|
-
if (0 === res.code) return (0,
|
|
1983
|
-
return (0,
|
|
1845
|
+
if (0 === res.code) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(params.searchValue ? res.recents : res.hots);
|
|
1846
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
|
|
1984
1847
|
} catch (error) {
|
|
1985
|
-
return (0,
|
|
1848
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
|
|
1986
1849
|
}
|
|
1987
1850
|
};
|
|
1988
1851
|
const searchToutiaoLocation = async (_task, params)=>{
|
|
1989
|
-
const http = new
|
|
1852
|
+
const http = new Http({
|
|
1990
1853
|
headers: {
|
|
1991
1854
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
1992
1855
|
referer: "https://mp.toutiao.com/profile_v4/graphic/publish",
|
|
@@ -2010,7 +1873,7 @@ const searchToutiaoLocation = async (_task, params)=>{
|
|
|
2010
1873
|
timestamp: Math.floor(Date.now() / 1000)
|
|
2011
1874
|
}
|
|
2012
1875
|
});
|
|
2013
|
-
if (200 === res.code) return (0,
|
|
1876
|
+
if (200 === res.code) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(res.data.poi.map((item)=>({
|
|
2014
1877
|
position: item.name,
|
|
2015
1878
|
city: item.city,
|
|
2016
1879
|
longitude: item.longitude,
|
|
@@ -2018,13 +1881,13 @@ const searchToutiaoLocation = async (_task, params)=>{
|
|
|
2018
1881
|
type_code: item.type_code,
|
|
2019
1882
|
poi_id: item.id
|
|
2020
1883
|
})));
|
|
2021
|
-
return (0,
|
|
1884
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
|
|
2022
1885
|
} catch (error) {
|
|
2023
|
-
return (0,
|
|
1886
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
|
|
2024
1887
|
}
|
|
2025
1888
|
};
|
|
2026
1889
|
const searchToutiaoUserInfo = async (_task, params)=>{
|
|
2027
|
-
const http = new
|
|
1890
|
+
const http = new Http({
|
|
2028
1891
|
headers: {
|
|
2029
1892
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2030
1893
|
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
@@ -2040,19 +1903,19 @@ const searchToutiaoUserInfo = async (_task, params)=>{
|
|
|
2040
1903
|
app_name: "toutiao_mp"
|
|
2041
1904
|
}
|
|
2042
1905
|
});
|
|
2043
|
-
if (0 === res.err_no) return (0,
|
|
1906
|
+
if (0 === res.err_no) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(res.data.suggest.map((item)=>({
|
|
2044
1907
|
user_id: item.user.info.user_id,
|
|
2045
1908
|
name: item.user.info.name,
|
|
2046
1909
|
avatar_url: item.user.info.avatar_url,
|
|
2047
1910
|
followers_count: item.user.relation_count.followers_count
|
|
2048
1911
|
})), '搜索成功');
|
|
2049
|
-
return (0,
|
|
1912
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
|
|
2050
1913
|
} catch (error) {
|
|
2051
|
-
return (0,
|
|
1914
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
|
|
2052
1915
|
}
|
|
2053
1916
|
};
|
|
2054
1917
|
const searchXiaohongshuLocation = async (_task, params)=>{
|
|
2055
|
-
const http = new
|
|
1918
|
+
const http = new Http({
|
|
2056
1919
|
headers: {
|
|
2057
1920
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2058
1921
|
referer: "https://creator.xiaohongshu.com",
|
|
@@ -2073,13 +1936,13 @@ const searchXiaohongshuLocation = async (_task, params)=>{
|
|
|
2073
1936
|
type: 3
|
|
2074
1937
|
}
|
|
2075
1938
|
});
|
|
2076
|
-
return (0,
|
|
1939
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(0 === result.code ? result.data.poi_list : []);
|
|
2077
1940
|
} catch (error) {
|
|
2078
|
-
return (0,
|
|
1941
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
|
|
2079
1942
|
}
|
|
2080
1943
|
};
|
|
2081
1944
|
const searchXiaohongshuTopicList = async (_task, params)=>{
|
|
2082
|
-
const http = new
|
|
1945
|
+
const http = new Http({
|
|
2083
1946
|
headers: {
|
|
2084
1947
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2085
1948
|
referer: "https://creator.xiaohongshu.com",
|
|
@@ -2103,9 +1966,9 @@ const searchXiaohongshuTopicList = async (_task, params)=>{
|
|
|
2103
1966
|
},
|
|
2104
1967
|
defaultErrorMsg: "话题搜索异常,请稍后重试。"
|
|
2105
1968
|
});
|
|
2106
|
-
return (0,
|
|
1969
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(0 === result.code ? result.data.topic_info_dtos : [], '获取话题成功');
|
|
2107
1970
|
} catch (error) {
|
|
2108
|
-
return (0,
|
|
1971
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
|
|
2109
1972
|
}
|
|
2110
1973
|
};
|
|
2111
1974
|
const GenAB = __webpack_require__("./src/utils/ttABEncrypt.js");
|
|
@@ -2141,7 +2004,7 @@ const get3101DetailError = (errorList, message, saveType)=>{
|
|
|
2141
2004
|
const mock_mockAction = async (task, params)=>{
|
|
2142
2005
|
const { toutiaoSingleCover, toutiaoMultCover, toutiaoCoverType, toutiaoOriginal, toutiaoExclusive, toutiaoClaim } = params.settingInfo;
|
|
2143
2006
|
const tmpCachePath = task.getTmpPath();
|
|
2144
|
-
const http = new
|
|
2007
|
+
const http = new Http({
|
|
2145
2008
|
headers: {
|
|
2146
2009
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2147
2010
|
origin: "https://mp.toutiao.com",
|
|
@@ -2165,10 +2028,10 @@ const mock_mockAction = async (task, params)=>{
|
|
|
2165
2028
|
defaultErrorMsg: `头条号登录状态失效,请重新绑定账号后${"draft" === params.saveType ? "同步" : "发布"}。`
|
|
2166
2029
|
});
|
|
2167
2030
|
const uploadImages = async (images)=>await Promise.all(images.map(async (url)=>{
|
|
2168
|
-
const fileName = (0,
|
|
2169
|
-
const image = await (0,
|
|
2031
|
+
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
2032
|
+
const image = await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
2170
2033
|
const formData = new __WEBPACK_EXTERNAL_MODULE_form_data_cf000082__["default"]();
|
|
2171
|
-
formData.append("image",
|
|
2034
|
+
formData.append("image", __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].createReadStream(image));
|
|
2172
2035
|
const response = await http.api({
|
|
2173
2036
|
method: "post",
|
|
2174
2037
|
url: "https://mp.toutiao.com/spice/image?upload_source=20020002&aid=1231&device_platform=web",
|
|
@@ -2177,9 +2040,9 @@ const mock_mockAction = async (task, params)=>{
|
|
|
2177
2040
|
});
|
|
2178
2041
|
return response.data;
|
|
2179
2042
|
}));
|
|
2180
|
-
const originContentImages = (
|
|
2043
|
+
const originContentImages = extractImgTag(params.content);
|
|
2181
2044
|
const targetContentImages = await uploadImages(originContentImages);
|
|
2182
|
-
const content = (
|
|
2045
|
+
const content = replaceImgSrc(params.content, (dom)=>{
|
|
2183
2046
|
if (dom.attribs.src) {
|
|
2184
2047
|
const idx = originContentImages.findIndex((it)=>it === dom.attribs.src);
|
|
2185
2048
|
dom.attribs.src = targetContentImages[idx].image_url;
|
|
@@ -2250,7 +2113,7 @@ const mock_mockAction = async (task, params)=>{
|
|
|
2250
2113
|
is_refute_rumor: 0,
|
|
2251
2114
|
save: "publish" === params.saveType ? 1 : 0,
|
|
2252
2115
|
timer_status: params.settingInfo.timer ? 1 : 0,
|
|
2253
|
-
timer_time: params.settingInfo.timer ?
|
|
2116
|
+
timer_time: params.settingInfo.timer ? TimeFormatter.format(params.settingInfo.timer) : "",
|
|
2254
2117
|
title: params.title,
|
|
2255
2118
|
content: content + topicContent,
|
|
2256
2119
|
extra: JSON.stringify(extraData),
|
|
@@ -2305,7 +2168,7 @@ const mock_mockAction = async (task, params)=>{
|
|
|
2305
2168
|
defaultErrorMsg: "draft" === params.saveType ? "文章同步异常,请稍后重试。" : "文章发布异常,请稍后重试。"
|
|
2306
2169
|
};
|
|
2307
2170
|
const publishResult = await http.api(publishOption);
|
|
2308
|
-
return (0,
|
|
2171
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(publishResult.data.pgc_id);
|
|
2309
2172
|
};
|
|
2310
2173
|
const rpa_GenAB = __webpack_require__("./src/utils/ttABEncrypt.js");
|
|
2311
2174
|
const rpa_rpaAction = async (task, params)=>{
|
|
@@ -2369,14 +2232,14 @@ const rpa_rpaAction = async (task, params)=>{
|
|
|
2369
2232
|
});
|
|
2370
2233
|
} else await route.continue();
|
|
2371
2234
|
});
|
|
2372
|
-
(
|
|
2235
|
+
PopupListener(page, '.byte-modal.publish-exclusive-modal .title', "激励", '.byte-modal-close-icon', {
|
|
2373
2236
|
checkInterval: 1000,
|
|
2374
2237
|
stopAfterClick: false
|
|
2375
2238
|
});
|
|
2376
2239
|
const titleInstance = page.locator(".publish-editor-title-wrapper .publish-editor-title textarea");
|
|
2377
2240
|
await titleInstance.click();
|
|
2378
2241
|
await titleInstance.fill(params.title);
|
|
2379
|
-
await (
|
|
2242
|
+
await copyHtmlToClipboard(page, params.content);
|
|
2380
2243
|
await page.click(".publish-editor .syl-editor-wrap .ProseMirror");
|
|
2381
2244
|
await page.keyboard.press("Control+V");
|
|
2382
2245
|
const coverTypeValue = COVER_TYPE[params.settingInfo.toutiaoCoverType];
|
|
@@ -2391,8 +2254,8 @@ const rpa_rpaAction = async (task, params)=>{
|
|
|
2391
2254
|
];
|
|
2392
2255
|
else if ("multiple" === params.settingInfo.toutiaoCoverType) coverUrls = params.settingInfo.toutiaoMultCover;
|
|
2393
2256
|
const images = await Promise.all(coverUrls.map((url)=>{
|
|
2394
|
-
const fileName = (0,
|
|
2395
|
-
return (0,
|
|
2257
|
+
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
2258
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
2396
2259
|
}));
|
|
2397
2260
|
const coverUploadEle = coverContainer.locator(".article-cover .article-cover-images").locator(".article-cover-img-wrap, .article-cover-add");
|
|
2398
2261
|
const coverUploadCount = await coverUploadEle.count();
|
|
@@ -2423,7 +2286,7 @@ const rpa_rpaAction = async (task, params)=>{
|
|
|
2423
2286
|
state: "visible"
|
|
2424
2287
|
});
|
|
2425
2288
|
await confirmBtn.click();
|
|
2426
|
-
await page.waitForTimeout((
|
|
2289
|
+
await page.waitForTimeout(getRandomInRange(500, 1000));
|
|
2427
2290
|
}
|
|
2428
2291
|
if (params.settingInfo.toutiaoLocation) {
|
|
2429
2292
|
const locationContainer = page.locator(".form-container .edit-cell").filter({
|
|
@@ -2492,17 +2355,17 @@ const rpa_rpaAction = async (task, params)=>{
|
|
|
2492
2355
|
});
|
|
2493
2356
|
await page.locator(".byte-modal-content .day-select .byte-select-view-value").click();
|
|
2494
2357
|
await page.locator('li.byte-select-option', {
|
|
2495
|
-
hasText:
|
|
2358
|
+
hasText: TimeFormatter.format(params.settingInfo.timer, "MM月dd日")
|
|
2496
2359
|
}).click();
|
|
2497
2360
|
await page.waitForTimeout(200);
|
|
2498
2361
|
await page.locator(".byte-modal-content .hour-select .byte-select-view-value").click();
|
|
2499
2362
|
await page.locator('li.byte-select-option', {
|
|
2500
|
-
hasText:
|
|
2363
|
+
hasText: TimeFormatter.format(params.settingInfo.timer, "h")
|
|
2501
2364
|
}).click();
|
|
2502
2365
|
await page.waitForTimeout(200);
|
|
2503
2366
|
await page.locator(".byte-modal-content .minute-select .byte-select-view-value").click();
|
|
2504
2367
|
await page.locator('li.byte-select-option', {
|
|
2505
|
-
hasText:
|
|
2368
|
+
hasText: TimeFormatter.format(params.settingInfo.timer, "m")
|
|
2506
2369
|
}).click();
|
|
2507
2370
|
await page.waitForTimeout(200);
|
|
2508
2371
|
await page.locator(".byte-modal-footer button").filter({
|
|
@@ -2529,7 +2392,7 @@ const rpa_rpaAction = async (task, params)=>{
|
|
|
2529
2392
|
}).click();
|
|
2530
2393
|
}
|
|
2531
2394
|
await page.close();
|
|
2532
|
-
return (0,
|
|
2395
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(articleId, "publish" === params.saveType ? "发布成功" : "保存草稿成功");
|
|
2533
2396
|
};
|
|
2534
2397
|
const COVER_TYPE = {
|
|
2535
2398
|
no: 1,
|
|
@@ -2540,10 +2403,10 @@ const getAddTypeValue = (toutiaoAd)=>"yes" === toutiaoAd ? 3 : 2;
|
|
|
2540
2403
|
const toutiaoPublish = async (task, params)=>{
|
|
2541
2404
|
if ("rpa" === params.actionType) return rpa_rpaAction(task, params);
|
|
2542
2405
|
if ("mockApi" === params.actionType) return mock_mockAction(task, params);
|
|
2543
|
-
return (
|
|
2406
|
+
return executeAction(mock_mockAction, rpa_rpaAction)(task, params);
|
|
2544
2407
|
};
|
|
2545
2408
|
const TTFansExport = async (_task, params)=>{
|
|
2546
|
-
const http = new
|
|
2409
|
+
const http = new Http({
|
|
2547
2410
|
headers: {
|
|
2548
2411
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2549
2412
|
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
@@ -2557,19 +2420,19 @@ const TTFansExport = async (_task, params)=>{
|
|
|
2557
2420
|
app_id: 1231
|
|
2558
2421
|
}
|
|
2559
2422
|
});
|
|
2560
|
-
return (0,
|
|
2423
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(0 === res.code ? {
|
|
2561
2424
|
fans_count: res.total_fans_count
|
|
2562
2425
|
} : {
|
|
2563
2426
|
fans_count: null
|
|
2564
2427
|
}, "获取粉丝数成功!");
|
|
2565
2428
|
} catch (error) {
|
|
2566
|
-
return (0,
|
|
2429
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
2567
2430
|
fans_count: null
|
|
2568
2431
|
}, "获取粉丝数失败,请检查登陆有效性!");
|
|
2569
2432
|
}
|
|
2570
2433
|
};
|
|
2571
2434
|
const XhsFansExport = async (_task, params)=>{
|
|
2572
|
-
const http = new
|
|
2435
|
+
const http = new Http({
|
|
2573
2436
|
headers: {
|
|
2574
2437
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2575
2438
|
referer: "https://creator.xiaohongshu.com/new/home?source=official"
|
|
@@ -2580,19 +2443,19 @@ const XhsFansExport = async (_task, params)=>{
|
|
|
2580
2443
|
method: "get",
|
|
2581
2444
|
url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
|
|
2582
2445
|
});
|
|
2583
|
-
return (0,
|
|
2446
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(0 === res.result ? {
|
|
2584
2447
|
fans_count: res.data.fans_count
|
|
2585
2448
|
} : {
|
|
2586
2449
|
fans_count: null
|
|
2587
2450
|
}, "获取粉丝数成功!");
|
|
2588
2451
|
} catch (error) {
|
|
2589
|
-
return (0,
|
|
2452
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
2590
2453
|
fans_count: null
|
|
2591
2454
|
}, "获取粉丝数失败,请检查登陆有效性!");
|
|
2592
2455
|
}
|
|
2593
2456
|
};
|
|
2594
2457
|
const WxFansExport = async (_task, params)=>{
|
|
2595
|
-
const http = new
|
|
2458
|
+
const http = new Http({
|
|
2596
2459
|
headers: {
|
|
2597
2460
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
2598
2461
|
}
|
|
@@ -2608,19 +2471,19 @@ const WxFansExport = async (_task, params)=>{
|
|
|
2608
2471
|
}
|
|
2609
2472
|
});
|
|
2610
2473
|
const match = htmlStr.match(/总用户数[\s\S]*?<mp-thousandth>(\d+)<\/mp-thousandth>/);
|
|
2611
|
-
return (0,
|
|
2474
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(match ? {
|
|
2612
2475
|
fans_count: Number(match[1])
|
|
2613
2476
|
} : {
|
|
2614
2477
|
fans_count: null
|
|
2615
2478
|
}, "获取粉丝数成功!");
|
|
2616
2479
|
} catch (error) {
|
|
2617
|
-
return (0,
|
|
2480
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
2618
2481
|
fans_count: null
|
|
2619
2482
|
}, "获取粉丝数失败,请检查登陆有效性!");
|
|
2620
2483
|
}
|
|
2621
2484
|
};
|
|
2622
2485
|
const BjhFansExport = async (_task, params)=>{
|
|
2623
|
-
const http = new
|
|
2486
|
+
const http = new Http({
|
|
2624
2487
|
headers: {
|
|
2625
2488
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2626
2489
|
referer: "https://baijiahao.baidu.com/builder/rc/home"
|
|
@@ -2631,19 +2494,19 @@ const BjhFansExport = async (_task, params)=>{
|
|
|
2631
2494
|
method: "get",
|
|
2632
2495
|
url: "https://baijiahao.baidu.com/cms-ui/rights/growth/get_info"
|
|
2633
2496
|
});
|
|
2634
|
-
return (0,
|
|
2497
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(0 === res.errno ? {
|
|
2635
2498
|
fans_count: res.data.total_fans
|
|
2636
2499
|
} : {
|
|
2637
2500
|
fans_count: null
|
|
2638
2501
|
}, "获取粉丝数成功!");
|
|
2639
2502
|
} catch (error) {
|
|
2640
|
-
return (0,
|
|
2503
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
2641
2504
|
fans_count: null
|
|
2642
2505
|
}, "获取粉丝数失败,请检查登陆有效性!");
|
|
2643
2506
|
}
|
|
2644
2507
|
};
|
|
2645
2508
|
const TTSessionCheck = async (_task, params)=>{
|
|
2646
|
-
const http = new
|
|
2509
|
+
const http = new Http({
|
|
2647
2510
|
headers: {
|
|
2648
2511
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2649
2512
|
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
@@ -2655,19 +2518,19 @@ const TTSessionCheck = async (_task, params)=>{
|
|
|
2655
2518
|
url: "https://mp.toutiao.com/mp/agw/creator_center/user_info",
|
|
2656
2519
|
defaultErrorMsg: `头条号登录状态失效。`
|
|
2657
2520
|
});
|
|
2658
|
-
return (0,
|
|
2521
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(0 === res.code ? {
|
|
2659
2522
|
isValidSession: true
|
|
2660
2523
|
} : {
|
|
2661
2524
|
isValidSession: false
|
|
2662
2525
|
}, "头条账号有效性检测完成!");
|
|
2663
2526
|
} catch (error) {
|
|
2664
|
-
return (0,
|
|
2527
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
2665
2528
|
isValidSession: false
|
|
2666
2529
|
}, "头条账号有效性检测失败!");
|
|
2667
2530
|
}
|
|
2668
2531
|
};
|
|
2669
2532
|
const WxSessionCheck = async (_task, params)=>{
|
|
2670
|
-
const http = new
|
|
2533
|
+
const http = new Http({
|
|
2671
2534
|
headers: {
|
|
2672
2535
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
2673
2536
|
}
|
|
@@ -2694,19 +2557,19 @@ const WxSessionCheck = async (_task, params)=>{
|
|
|
2694
2557
|
ajax: 1
|
|
2695
2558
|
}
|
|
2696
2559
|
});
|
|
2697
|
-
return (0,
|
|
2560
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(0 === res.base_resp.ret ? {
|
|
2698
2561
|
isValidSession: true
|
|
2699
2562
|
} : {
|
|
2700
2563
|
isValidSession: false
|
|
2701
2564
|
}, "微信账号有效性检测完成!");
|
|
2702
2565
|
} catch (error) {
|
|
2703
|
-
return (0,
|
|
2566
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
2704
2567
|
isValidSession: false
|
|
2705
2568
|
}, "微信账号有效性检测失败!");
|
|
2706
2569
|
}
|
|
2707
2570
|
};
|
|
2708
2571
|
const XhsSessionCheck = async (_task, params)=>{
|
|
2709
|
-
const http = new
|
|
2572
|
+
const http = new Http({
|
|
2710
2573
|
headers: {
|
|
2711
2574
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2712
2575
|
referer: "https://creator.xiaohongshu.com/new/home?source=official"
|
|
@@ -2717,19 +2580,19 @@ const XhsSessionCheck = async (_task, params)=>{
|
|
|
2717
2580
|
method: "get",
|
|
2718
2581
|
url: "https://creator.xiaohongshu.com/api/galaxy/user/info"
|
|
2719
2582
|
});
|
|
2720
|
-
return (0,
|
|
2583
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(0 === res.result ? {
|
|
2721
2584
|
isValidSession: true
|
|
2722
2585
|
} : {
|
|
2723
2586
|
isValidSession: false
|
|
2724
2587
|
}, "小红书账号有效性检测完成!");
|
|
2725
2588
|
} catch (error) {
|
|
2726
|
-
return (0,
|
|
2589
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
2727
2590
|
isValidSession: false
|
|
2728
2591
|
}, "小红书账号有效性检测完成!");
|
|
2729
2592
|
}
|
|
2730
2593
|
};
|
|
2731
2594
|
const BjhSessionCheck = async (_task, params)=>{
|
|
2732
|
-
const http = new
|
|
2595
|
+
const http = new Http({
|
|
2733
2596
|
headers: {
|
|
2734
2597
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2735
2598
|
referer: "https://baijiahao.baidu.com/builder/rc/home"
|
|
@@ -2741,30 +2604,34 @@ const BjhSessionCheck = async (_task, params)=>{
|
|
|
2741
2604
|
url: "https://baijiahao.baidu.com/pcui/home/index",
|
|
2742
2605
|
defaultErrorMsg: `百家号登录状态失效。`
|
|
2743
2606
|
});
|
|
2744
|
-
return (0,
|
|
2607
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(0 === res.errno ? {
|
|
2745
2608
|
isValidSession: true
|
|
2746
2609
|
} : {
|
|
2747
2610
|
isValidSession: false
|
|
2748
2611
|
}, "百家号账号有效性检测完成!");
|
|
2749
2612
|
} catch (error) {
|
|
2750
|
-
return (0,
|
|
2613
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
2751
2614
|
isValidSession: false
|
|
2752
2615
|
}, "百家号账号有效性检测失败!");
|
|
2753
2616
|
}
|
|
2754
2617
|
};
|
|
2755
|
-
|
|
2618
|
+
const types_errorResponse = (message, code = 500)=>({
|
|
2619
|
+
code,
|
|
2620
|
+
message,
|
|
2621
|
+
data: null
|
|
2622
|
+
});
|
|
2756
2623
|
async function getBaijiahaoData(params) {
|
|
2757
2624
|
try {
|
|
2758
2625
|
const { token } = params;
|
|
2759
|
-
if (!token) return (
|
|
2760
|
-
const http = new
|
|
2626
|
+
if (!token) return types_errorResponse("缺少token", 200);
|
|
2627
|
+
const http = new Http({
|
|
2761
2628
|
headers: {
|
|
2762
2629
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2763
2630
|
token: String(token),
|
|
2764
2631
|
Referer: "https://baijiahao.baidu.com/builder/rc/home"
|
|
2765
2632
|
}
|
|
2766
2633
|
});
|
|
2767
|
-
const yesterday =
|
|
2634
|
+
const yesterday = TimeFormatter.format(new Date().setDate(new Date().getDate() - 1), "yyyyMMdd");
|
|
2768
2635
|
const [fansData, readData, incomeData, yesterdayData] = await Promise.all([
|
|
2769
2636
|
http.api({
|
|
2770
2637
|
method: "get",
|
|
@@ -2801,15 +2668,15 @@ async function getBaijiahaoData(params) {
|
|
|
2801
2668
|
likeNumYesterday: -1 == yesterdayData.data.data.likes_count ? null : yesterdayData.data.data.likes_count,
|
|
2802
2669
|
commentNumYesterday: -1 == yesterdayData.data.data.comment_count ? null : yesterdayData.data.data.comment_count
|
|
2803
2670
|
};
|
|
2804
|
-
return (0,
|
|
2671
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(bjhData, "百家号平台数据获取成功!");
|
|
2805
2672
|
} catch (error) {
|
|
2806
|
-
return (
|
|
2673
|
+
return types_errorResponse(error instanceof Error ? error.message : "百家号平台数据获取失败");
|
|
2807
2674
|
}
|
|
2808
2675
|
}
|
|
2809
2676
|
async function getToutiaoData(params) {
|
|
2810
2677
|
const { cookies } = params;
|
|
2811
2678
|
try {
|
|
2812
|
-
const http = new
|
|
2679
|
+
const http = new Http({
|
|
2813
2680
|
headers: {
|
|
2814
2681
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2815
2682
|
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
@@ -2850,12 +2717,71 @@ async function getToutiaoData(params) {
|
|
|
2850
2717
|
likeNumYesterday: contentDataYesterday.author_stat.interaction_data.digg_count,
|
|
2851
2718
|
commentNumYesterday: contentDataYesterday.author_stat.interaction_data.comment_count
|
|
2852
2719
|
};
|
|
2853
|
-
return (0,
|
|
2720
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(ttData, "头条号粉丝数据获取成功!");
|
|
2721
|
+
} catch (error) {
|
|
2722
|
+
return types_errorResponse(error instanceof Error ? error.message : "头条号数据获取失败");
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2725
|
+
async function getWeixinData(params) {
|
|
2726
|
+
const { token } = params;
|
|
2727
|
+
if (!token) return {
|
|
2728
|
+
code: 200,
|
|
2729
|
+
message: "缺少token",
|
|
2730
|
+
data: null
|
|
2731
|
+
};
|
|
2732
|
+
try {
|
|
2733
|
+
const { token } = params;
|
|
2734
|
+
if (!token) return types_errorResponse("缺少token", 200);
|
|
2735
|
+
const http = new Http({
|
|
2736
|
+
headers: {
|
|
2737
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
2738
|
+
}
|
|
2739
|
+
});
|
|
2740
|
+
const userInfo = {
|
|
2741
|
+
originalCount: 0,
|
|
2742
|
+
totalUsers: 0,
|
|
2743
|
+
userIncrease: 0,
|
|
2744
|
+
yesterday: {
|
|
2745
|
+
read: 0,
|
|
2746
|
+
share: 0,
|
|
2747
|
+
subscribe: 0
|
|
2748
|
+
}
|
|
2749
|
+
};
|
|
2750
|
+
const userInfoHtml = await http.api({
|
|
2751
|
+
method: "get",
|
|
2752
|
+
url: "https://mp.weixin.qq.com/cgi-bin/home",
|
|
2753
|
+
params: {
|
|
2754
|
+
t: "home/index",
|
|
2755
|
+
token,
|
|
2756
|
+
lang: "zh_CN"
|
|
2757
|
+
}
|
|
2758
|
+
});
|
|
2759
|
+
const originalMatch = userInfoHtml.trim().match(/原创内容[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
|
|
2760
|
+
if (originalMatch) userInfo.originalCount = parseInt(originalMatch[1].replace(/,/g, ''), 10);
|
|
2761
|
+
const totalUsersMatch = userInfoHtml.match(/总用户数[\s\S]*?<div[^>]*class=["']weui-desktop-user_sum["'][^>]*>[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
|
|
2762
|
+
if (totalUsersMatch) userInfo.totalUsers = parseInt(totalUsersMatch[1].replace(/,/g, ''), 10);
|
|
2763
|
+
const increaseMatch = userInfoHtml.match(/weui-desktop-user_increase_num[^>]*>\s*([+-]?)\s*<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
|
|
2764
|
+
if (increaseMatch) {
|
|
2765
|
+
const sign = '-' === increaseMatch[1] ? -1 : 1;
|
|
2766
|
+
userInfo.userIncrease = sign * parseInt(increaseMatch[2].replace(/,/g, ''), 10);
|
|
2767
|
+
}
|
|
2768
|
+
const readMatch = userInfoHtml.match(/昨日阅读[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
|
|
2769
|
+
if (readMatch) userInfo.yesterday.read = parseInt(readMatch[1].replace(/,/g, ''), 10);
|
|
2770
|
+
const shareMatch = userInfoHtml.match(/昨日分享[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
|
|
2771
|
+
if (shareMatch) userInfo.yesterday.share = parseInt(shareMatch[1].replace(/,/g, ''), 10);
|
|
2772
|
+
const subscribeMatch = userInfoHtml.match(/昨日新增关注[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
|
|
2773
|
+
if (subscribeMatch) userInfo.yesterday.subscribe = parseInt(subscribeMatch[1].replace(/,/g, ''), 10);
|
|
2774
|
+
const wxData = {
|
|
2775
|
+
fansNum: userInfo.totalUsers,
|
|
2776
|
+
fansNumYesterday: userInfo.yesterday.subscribe,
|
|
2777
|
+
readNumYesterday: userInfo.yesterday.read,
|
|
2778
|
+
shareNumYesterday: userInfo.yesterday.share
|
|
2779
|
+
};
|
|
2780
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(wxData, "微信平台数据获取成功!");
|
|
2854
2781
|
} catch (error) {
|
|
2855
|
-
return (
|
|
2782
|
+
return types_errorResponse(error instanceof Error ? error.message : "微信平台数据获取失败");
|
|
2856
2783
|
}
|
|
2857
2784
|
}
|
|
2858
|
-
var getWxInfo = __webpack_require__("./src/actions/searchAccountInfo/getWxInfo.ts");
|
|
2859
2785
|
class XsEncrypt {
|
|
2860
2786
|
async encryptMD5(url) {
|
|
2861
2787
|
return __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createHash("md5").update(url, "utf8").digest("hex");
|
|
@@ -2909,8 +2835,8 @@ class XsEncrypt {
|
|
|
2909
2835
|
async function getXiaohongshuData(params) {
|
|
2910
2836
|
try {
|
|
2911
2837
|
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
2912
|
-
if (!a1Cookie) return (
|
|
2913
|
-
const http = new
|
|
2838
|
+
if (!a1Cookie) return types_errorResponse("账号数据异常,请重新绑定账号后重试。", 200);
|
|
2839
|
+
const http = new Http({
|
|
2914
2840
|
headers: {
|
|
2915
2841
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2916
2842
|
referer: "https://creator.xiaohongshu.com",
|
|
@@ -2946,9 +2872,9 @@ async function getXiaohongshuData(params) {
|
|
|
2946
2872
|
fansNumLastWeek: sevenData.data.seven.rise_fans_count,
|
|
2947
2873
|
fansNumYesterday: sevenData.data.seven.rise_fans_list[0].count
|
|
2948
2874
|
};
|
|
2949
|
-
return (0,
|
|
2875
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(xhsData, "小红书平台数据获取成功!");
|
|
2950
2876
|
} catch (error) {
|
|
2951
|
-
return (
|
|
2877
|
+
return types_errorResponse(error instanceof Error ? error.message : "小红书平台数据获取失败");
|
|
2952
2878
|
}
|
|
2953
2879
|
}
|
|
2954
2880
|
const SearchAccountInfo = async (_task, params)=>{
|
|
@@ -2959,14 +2885,14 @@ const SearchAccountInfo = async (_task, params)=>{
|
|
|
2959
2885
|
case "xiaohongshu":
|
|
2960
2886
|
return getXiaohongshuData(params);
|
|
2961
2887
|
case "weixin":
|
|
2962
|
-
return (
|
|
2888
|
+
return getWeixinData(params);
|
|
2963
2889
|
case "baijiahao":
|
|
2964
2890
|
return getBaijiahaoData(params);
|
|
2965
2891
|
default:
|
|
2966
|
-
return (0,
|
|
2892
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(null, "暂不支持该平台");
|
|
2967
2893
|
}
|
|
2968
2894
|
};
|
|
2969
|
-
const
|
|
2895
|
+
const searchPublishInfo_types_errorResponse = (message, code = 500)=>({
|
|
2970
2896
|
code,
|
|
2971
2897
|
message,
|
|
2972
2898
|
data: null
|
|
@@ -2974,7 +2900,7 @@ const errorResponse = (message, code = 500)=>({
|
|
|
2974
2900
|
async function handleToutiaoData(params) {
|
|
2975
2901
|
try {
|
|
2976
2902
|
const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
|
|
2977
|
-
const http = new
|
|
2903
|
+
const http = new Http({
|
|
2978
2904
|
headers: {
|
|
2979
2905
|
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
2980
2906
|
}
|
|
@@ -3021,7 +2947,7 @@ async function handleToutiaoData(params) {
|
|
|
3021
2947
|
} : {}
|
|
3022
2948
|
}));
|
|
3023
2949
|
const api_base_info_json = JSON.parse(articleInfo.api_base_info.app_extra_params);
|
|
3024
|
-
return (0,
|
|
2950
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
3025
2951
|
articleCell,
|
|
3026
2952
|
...onlySuccess ? {
|
|
3027
2953
|
pagination: {
|
|
@@ -3030,9 +2956,9 @@ async function handleToutiaoData(params) {
|
|
|
3030
2956
|
pageSize
|
|
3031
2957
|
}
|
|
3032
2958
|
} : null
|
|
3033
|
-
}, "
|
|
2959
|
+
}, "头条号文章文章获取成功");
|
|
3034
2960
|
} catch (error) {
|
|
3035
|
-
return
|
|
2961
|
+
return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "头条号文章数据获取失败");
|
|
3036
2962
|
}
|
|
3037
2963
|
}
|
|
3038
2964
|
async function handleWeixinData(params) {
|
|
@@ -3043,21 +2969,57 @@ async function handleWeixinData(params) {
|
|
|
3043
2969
|
message: "缺少token",
|
|
3044
2970
|
data: null
|
|
3045
2971
|
};
|
|
3046
|
-
const http = new
|
|
2972
|
+
const http = new Http({
|
|
3047
2973
|
headers: {
|
|
3048
2974
|
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
3049
2975
|
}
|
|
3050
2976
|
});
|
|
3051
2977
|
const ParsePublishPage = (body)=>{
|
|
3052
|
-
const
|
|
3053
|
-
const match = body.match(/publish_page\s*=\s*(\{[\s\S]*?\})\s*;/);
|
|
2978
|
+
const match = body.match(/publish_page\s*=\s*({[\s\S]*?});/);
|
|
3054
2979
|
if (!match) throw new Error('无法提取 publish_page 字段');
|
|
3055
|
-
|
|
3056
|
-
const
|
|
2980
|
+
let parsedData = JSON.parse(match[1]);
|
|
2981
|
+
const decodeEntities = function(str, decode = false) {
|
|
2982
|
+
const encodeMap = [
|
|
2983
|
+
"&",
|
|
2984
|
+
"&",
|
|
2985
|
+
"<",
|
|
2986
|
+
"<",
|
|
2987
|
+
">",
|
|
2988
|
+
">",
|
|
2989
|
+
" ",
|
|
2990
|
+
" ",
|
|
2991
|
+
'"',
|
|
2992
|
+
""",
|
|
2993
|
+
"'",
|
|
2994
|
+
"'"
|
|
2995
|
+
];
|
|
2996
|
+
const decodeMap = [
|
|
2997
|
+
"'",
|
|
2998
|
+
"'",
|
|
2999
|
+
""",
|
|
3000
|
+
'"',
|
|
3001
|
+
" ",
|
|
3002
|
+
" ",
|
|
3003
|
+
">",
|
|
3004
|
+
">",
|
|
3005
|
+
"<",
|
|
3006
|
+
"<",
|
|
3007
|
+
"&",
|
|
3008
|
+
"&",
|
|
3009
|
+
"<",
|
|
3010
|
+
"<",
|
|
3011
|
+
">",
|
|
3012
|
+
">"
|
|
3013
|
+
];
|
|
3014
|
+
const map = decode ? decodeMap : encodeMap;
|
|
3015
|
+
let result = str;
|
|
3016
|
+
for(let i = 0; i < map.length; i += 2)result = result.replace(new RegExp(map[i], "g"), map[i + 1]);
|
|
3017
|
+
return result;
|
|
3018
|
+
};
|
|
3057
3019
|
const finalData = {
|
|
3058
3020
|
...parsedData,
|
|
3059
3021
|
publish_list: parsedData.publish_list.map((item)=>{
|
|
3060
|
-
const decoded =
|
|
3022
|
+
const decoded = decodeEntities(item.publish_info, true);
|
|
3061
3023
|
const parsedInfo = JSON.parse(decoded);
|
|
3062
3024
|
return {
|
|
3063
3025
|
publish_type: item.publish_type,
|
|
@@ -3092,7 +3054,7 @@ async function handleWeixinData(params) {
|
|
|
3092
3054
|
originalData: item
|
|
3093
3055
|
} : {}
|
|
3094
3056
|
}));
|
|
3095
|
-
return (0,
|
|
3057
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
3096
3058
|
articleCell,
|
|
3097
3059
|
...onlySuccess ? {
|
|
3098
3060
|
pagination: {
|
|
@@ -3101,9 +3063,9 @@ async function handleWeixinData(params) {
|
|
|
3101
3063
|
pageSize
|
|
3102
3064
|
}
|
|
3103
3065
|
} : null
|
|
3104
|
-
}, "
|
|
3066
|
+
}, "微信文章文章获取成功");
|
|
3105
3067
|
} catch (error) {
|
|
3106
|
-
return
|
|
3068
|
+
return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "微信文章数据获取失败");
|
|
3107
3069
|
}
|
|
3108
3070
|
}
|
|
3109
3071
|
async function handleBaijiahaoData(params) {
|
|
@@ -3114,7 +3076,7 @@ async function handleBaijiahaoData(params) {
|
|
|
3114
3076
|
message: "缺少token",
|
|
3115
3077
|
data: null
|
|
3116
3078
|
};
|
|
3117
|
-
const http = new
|
|
3079
|
+
const http = new Http({
|
|
3118
3080
|
headers: {
|
|
3119
3081
|
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
3120
3082
|
token: token
|
|
@@ -3167,7 +3129,7 @@ async function handleBaijiahaoData(params) {
|
|
|
3167
3129
|
originalData: item
|
|
3168
3130
|
} : {}
|
|
3169
3131
|
}));
|
|
3170
|
-
return (0,
|
|
3132
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
3171
3133
|
articleCell,
|
|
3172
3134
|
...onlySuccess ? {
|
|
3173
3135
|
pagination: {
|
|
@@ -3176,9 +3138,9 @@ async function handleBaijiahaoData(params) {
|
|
|
3176
3138
|
pageSize
|
|
3177
3139
|
}
|
|
3178
3140
|
} : null
|
|
3179
|
-
}, "
|
|
3141
|
+
}, "百家号文章数据获取成功");
|
|
3180
3142
|
} catch (error) {
|
|
3181
|
-
return
|
|
3143
|
+
return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "百家号文章数据获取失败");
|
|
3182
3144
|
}
|
|
3183
3145
|
}
|
|
3184
3146
|
async function handleXiaohongshuData(params) {
|
|
@@ -3196,7 +3158,7 @@ async function handleXiaohongshuData(params) {
|
|
|
3196
3158
|
message: "小红书pageSize不可修改",
|
|
3197
3159
|
data: null
|
|
3198
3160
|
};
|
|
3199
|
-
const http = new
|
|
3161
|
+
const http = new Http({
|
|
3200
3162
|
headers: {
|
|
3201
3163
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
3202
3164
|
referer: "https://creator.xiaohongshu.com",
|
|
@@ -3249,18 +3211,18 @@ async function handleXiaohongshuData(params) {
|
|
|
3249
3211
|
originalData: item
|
|
3250
3212
|
} : {}
|
|
3251
3213
|
}));
|
|
3252
|
-
return (0,
|
|
3214
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
|
|
3253
3215
|
articleCell,
|
|
3254
3216
|
...onlySuccess ? {
|
|
3255
3217
|
pagination: {
|
|
3256
|
-
|
|
3218
|
+
nextPage: hasNextpage,
|
|
3257
3219
|
pageNum,
|
|
3258
3220
|
pageSize
|
|
3259
3221
|
}
|
|
3260
3222
|
} : null
|
|
3261
|
-
}, "
|
|
3223
|
+
}, "小红书文章数据获取成功");
|
|
3262
3224
|
} catch (error) {
|
|
3263
|
-
return
|
|
3225
|
+
return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "小红书文章数据获取失败");
|
|
3264
3226
|
}
|
|
3265
3227
|
}
|
|
3266
3228
|
const FetchArticles = async (_task, params)=>{
|
|
@@ -3275,11 +3237,11 @@ const FetchArticles = async (_task, params)=>{
|
|
|
3275
3237
|
case "xiaohongshu":
|
|
3276
3238
|
return handleXiaohongshuData(params);
|
|
3277
3239
|
default:
|
|
3278
|
-
return (0,
|
|
3240
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(null, "暂不支持该平台");
|
|
3279
3241
|
}
|
|
3280
3242
|
};
|
|
3281
3243
|
const getWeixinConfig = async (_task, params)=>{
|
|
3282
|
-
const http = new
|
|
3244
|
+
const http = new Http({
|
|
3283
3245
|
headers: {
|
|
3284
3246
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
3285
3247
|
}
|
|
@@ -3300,11 +3262,11 @@ const getWeixinConfig = async (_task, params)=>{
|
|
|
3300
3262
|
const filtered = {
|
|
3301
3263
|
publishQuota: 0 === res.base_resp.ret ? res.quota_detail_list.filter((item)=>"kQuotaTypeMassSendNormal" === item.quota_type).map((item)=>item.quota_item_list) : []
|
|
3302
3264
|
};
|
|
3303
|
-
return (0,
|
|
3265
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(filtered, 0 === res.base_resp.ret ? "微信配置信息获取成功!" : "微信配置信息获取失败!");
|
|
3304
3266
|
};
|
|
3305
3267
|
const weitoutiaoPublish_mock_mockAction = async (task, params)=>{
|
|
3306
3268
|
const tmpCachePath = task.getTmpPath();
|
|
3307
|
-
const http = new
|
|
3269
|
+
const http = new Http({
|
|
3308
3270
|
headers: {
|
|
3309
3271
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
3310
3272
|
origin: "https://mp.toutiao.com",
|
|
@@ -3323,12 +3285,12 @@ const weitoutiaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
3323
3285
|
const imageList = [];
|
|
3324
3286
|
if (params.banners && params.banners.length > 0) {
|
|
3325
3287
|
const images = await Promise.all(params.banners.map((url)=>{
|
|
3326
|
-
const fileName = (0,
|
|
3327
|
-
return (0,
|
|
3288
|
+
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
3289
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
3328
3290
|
}));
|
|
3329
3291
|
const res = await Promise.all(images.map(async (it)=>{
|
|
3330
3292
|
const formData = new __WEBPACK_EXTERNAL_MODULE_form_data_cf000082__["default"]();
|
|
3331
|
-
formData.append("image",
|
|
3293
|
+
formData.append("image", __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].createReadStream(it));
|
|
3332
3294
|
const response = await http.api({
|
|
3333
3295
|
method: "post",
|
|
3334
3296
|
url: "https://mp.toutiao.com/spice/image?upload_source=20020003&aid=1231&device_platform=web",
|
|
@@ -3371,7 +3333,7 @@ const weitoutiaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
3371
3333
|
url: "https://mp.toutiao.com/mp/agw/article/wtt",
|
|
3372
3334
|
data: syncData
|
|
3373
3335
|
});
|
|
3374
|
-
return (0,
|
|
3336
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(res.data);
|
|
3375
3337
|
};
|
|
3376
3338
|
const weitoutiaoPublish_rpa_rpaAction = async (task, params)=>{
|
|
3377
3339
|
const commonCookies = {
|
|
@@ -3404,8 +3366,8 @@ const weitoutiaoPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
3404
3366
|
await descInstance.fill(params.content);
|
|
3405
3367
|
if (params.banners && params.banners?.length > 0) {
|
|
3406
3368
|
const images = await Promise.all(params.banners.map((url)=>{
|
|
3407
|
-
const fileName = (0,
|
|
3408
|
-
return (0,
|
|
3369
|
+
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
3370
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
3409
3371
|
}));
|
|
3410
3372
|
const fileChooserPromise = page.waitForEvent("filechooser");
|
|
3411
3373
|
await page.locator(".toolbar .syl-toolbar-tool.weitoutiao-image-plugin").click();
|
|
@@ -3436,12 +3398,12 @@ const weitoutiaoPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
3436
3398
|
await declarationFormItem.locator(`.byte-checkbox:has(input[value="${params.declaration}"])`).click();
|
|
3437
3399
|
}
|
|
3438
3400
|
await page.locator(".footer-wrap button.publish-content").click();
|
|
3439
|
-
return (0,
|
|
3401
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)("");
|
|
3440
3402
|
};
|
|
3441
3403
|
const weitoutiaoPublish = async (task, params)=>{
|
|
3442
3404
|
if ("rpa" === params.actionType) return weitoutiaoPublish_rpa_rpaAction(task, params);
|
|
3443
3405
|
if ("mockApi" === params.actionType) return weitoutiaoPublish_mock_mockAction(task, params);
|
|
3444
|
-
return (
|
|
3406
|
+
return executeAction(weitoutiaoPublish_mock_mockAction, weitoutiaoPublish_rpa_rpaAction)(task, params);
|
|
3445
3407
|
};
|
|
3446
3408
|
const scanRetryMaxCount = 30;
|
|
3447
3409
|
const QuotaType = {
|
|
@@ -3498,7 +3460,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3498
3460
|
const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
|
|
3499
3461
|
const client_time_diff = +Number("1743488763") - Math.floor(new Date().getTime() / 1000);
|
|
3500
3462
|
const tmpCachePath = task.getTmpPath();
|
|
3501
|
-
const http = new
|
|
3463
|
+
const http = new Http({
|
|
3502
3464
|
headers: {
|
|
3503
3465
|
"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",
|
|
3504
3466
|
Cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
@@ -3541,19 +3503,19 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3541
3503
|
const uploadImages = async (images)=>{
|
|
3542
3504
|
const cloudImages = [];
|
|
3543
3505
|
const localImages = await Promise.all(images.map((url)=>{
|
|
3544
|
-
const fileName = (0,
|
|
3545
|
-
return (0,
|
|
3506
|
+
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
3507
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
3546
3508
|
}));
|
|
3547
3509
|
for(let index = 0; index < images.length; index++){
|
|
3548
3510
|
const image = localImages[index];
|
|
3549
|
-
const fileState = (
|
|
3511
|
+
const fileState = getFileState(image);
|
|
3550
3512
|
const formData = new __WEBPACK_EXTERNAL_MODULE_form_data_cf000082__["default"]();
|
|
3551
3513
|
formData.append("id", `WU_FILE_${index + 1}`);
|
|
3552
3514
|
formData.append("name", fileState.name);
|
|
3553
3515
|
formData.append("type", fileState.type);
|
|
3554
3516
|
formData.append("lastModifiedDate", fileState.lastModifiedDate);
|
|
3555
3517
|
formData.append("size", fileState.size);
|
|
3556
|
-
formData.append("file",
|
|
3518
|
+
formData.append("file", __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].createReadStream(image));
|
|
3557
3519
|
const response = await http.api({
|
|
3558
3520
|
method: "post",
|
|
3559
3521
|
url: `https://mp.weixin.qq.com/cgi-bin/filetransfer?action=upload_material&f=json&writetype=doublewrite&token=${params.token}&lang=zh_CN`,
|
|
@@ -3564,9 +3526,9 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3564
3526
|
}
|
|
3565
3527
|
return cloudImages;
|
|
3566
3528
|
};
|
|
3567
|
-
const originContentImages = (
|
|
3529
|
+
const originContentImages = extractImgTag(params.content);
|
|
3568
3530
|
const targetContentImages = await uploadImages(originContentImages);
|
|
3569
|
-
const content = (
|
|
3531
|
+
const content = replaceImgSrc(params.content, (dom)=>{
|
|
3570
3532
|
if (dom.attribs.src) {
|
|
3571
3533
|
const idx = originContentImages.findIndex((it)=>it === dom.attribs.src);
|
|
3572
3534
|
dom.attribs.src = targetContentImages[idx].cdn_url;
|
|
@@ -3683,13 +3645,13 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3683
3645
|
defaultErrorMsg: GET_QRCODE_DEFAULT_ERROR
|
|
3684
3646
|
});
|
|
3685
3647
|
const rewardBuffer = Buffer.from(rewardbind.qrcode_base64, 'base64');
|
|
3686
|
-
const rewardFilePath =
|
|
3687
|
-
|
|
3648
|
+
const rewardFilePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, "weixin_reward.jpg");
|
|
3649
|
+
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(rewardFilePath, new Uint8Array(rewardBuffer));
|
|
3688
3650
|
params.safeQrcodeCallback?.(rewardFilePath);
|
|
3689
3651
|
const task_id = rewardbind.task_id;
|
|
3690
3652
|
let code = null;
|
|
3691
3653
|
for(let i = 0; i < scanRetryMaxCount; i++){
|
|
3692
|
-
await (0,
|
|
3654
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.sleep)(2000);
|
|
3693
3655
|
const checkScanResult = await http.api({
|
|
3694
3656
|
method: "get",
|
|
3695
3657
|
url: "https://mp.weixin.qq.com/acct/writermgr",
|
|
@@ -3950,7 +3912,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3950
3912
|
appmsgid: appMsgId
|
|
3951
3913
|
};
|
|
3952
3914
|
for(let i = 0; i < 10; i++){
|
|
3953
|
-
await (0,
|
|
3915
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.sleep)(1000);
|
|
3954
3916
|
const lastData = {
|
|
3955
3917
|
...copyrightStatData,
|
|
3956
3918
|
first_check: 0 === i ? 1 : 0
|
|
@@ -3958,7 +3920,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3958
3920
|
const checkCopyrightStatRes = await checkCopyrightStat(http, params, lastData);
|
|
3959
3921
|
if (checkCopyrightStatRes.open_ad_reprint_status) break;
|
|
3960
3922
|
}
|
|
3961
|
-
await (0,
|
|
3923
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.sleep)(300);
|
|
3962
3924
|
await http.api({
|
|
3963
3925
|
method: "post",
|
|
3964
3926
|
url: "https://mp.weixin.qq.com/cgi-bin/masssend",
|
|
@@ -3979,7 +3941,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3979
3941
|
random: Math.random().toString()
|
|
3980
3942
|
})
|
|
3981
3943
|
});
|
|
3982
|
-
await (0,
|
|
3944
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.sleep)(300);
|
|
3983
3945
|
await http.api({
|
|
3984
3946
|
method: "post",
|
|
3985
3947
|
url: "https://mp.weixin.qq.com/cgi-bin/masssend",
|
|
@@ -3997,7 +3959,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
3997
3959
|
random: Math.random().toString()
|
|
3998
3960
|
})
|
|
3999
3961
|
});
|
|
4000
|
-
await (0,
|
|
3962
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.sleep)(300);
|
|
4001
3963
|
const getTicketResult = await http.api({
|
|
4002
3964
|
method: "post",
|
|
4003
3965
|
url: "https://mp.weixin.qq.com/misc/safeassistant",
|
|
@@ -4017,7 +3979,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
4017
3979
|
}),
|
|
4018
3980
|
defaultErrorMsg: GET_QRCODE_DEFAULT_ERROR
|
|
4019
3981
|
});
|
|
4020
|
-
await (0,
|
|
3982
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.sleep)(300);
|
|
4021
3983
|
const getUuidResult = await http.api({
|
|
4022
3984
|
method: "post",
|
|
4023
3985
|
url: "https://mp.weixin.qq.com/safe/safeqrconnect",
|
|
@@ -4040,14 +4002,14 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
4040
4002
|
}),
|
|
4041
4003
|
defaultErrorMsg: GET_QRCODE_DEFAULT_ERROR
|
|
4042
4004
|
});
|
|
4043
|
-
await (0,
|
|
4005
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.sleep)(1000);
|
|
4044
4006
|
if (0 !== getUuidResult.genuuid_res) return {
|
|
4045
4007
|
code: 200,
|
|
4046
4008
|
message: GET_QRCODE_DEFAULT_ERROR,
|
|
4047
4009
|
data: ""
|
|
4048
4010
|
};
|
|
4049
4011
|
const uuid = getUuidResult.uuid;
|
|
4050
|
-
await (0,
|
|
4012
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.sleep)(1000);
|
|
4051
4013
|
const qrcodeResult = await http.api({
|
|
4052
4014
|
method: "get",
|
|
4053
4015
|
url: "https://mp.weixin.qq.com/safe/safeqrcode",
|
|
@@ -4067,12 +4029,12 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
4067
4029
|
responseType: "arraybuffer"
|
|
4068
4030
|
});
|
|
4069
4031
|
const qrcodeBuffer = Buffer.from(qrcodeResult);
|
|
4070
|
-
const qrcodeFilePath =
|
|
4071
|
-
|
|
4032
|
+
const qrcodeFilePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, "weixin_qrcode.jpg");
|
|
4033
|
+
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(qrcodeFilePath, new Uint8Array(qrcodeBuffer));
|
|
4072
4034
|
params.safeQrcodeCallback?.(qrcodeFilePath);
|
|
4073
4035
|
let code = "";
|
|
4074
4036
|
for(let i = 0; i < scanRetryMaxCount; i++){
|
|
4075
|
-
await (0,
|
|
4037
|
+
await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.sleep)(2000);
|
|
4076
4038
|
const checkScanResult = await http.api({
|
|
4077
4039
|
method: "post",
|
|
4078
4040
|
url: "https://mp.weixin.qq.com/safe/safeuuid",
|
|
@@ -4159,7 +4121,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
4159
4121
|
share_page: "1",
|
|
4160
4122
|
synctxweibo: "0",
|
|
4161
4123
|
operation_seq,
|
|
4162
|
-
req_id: (0,
|
|
4124
|
+
req_id: (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.randomString)(32),
|
|
4163
4125
|
req_time: new Date().getTime() + 1e3 * client_time_diff,
|
|
4164
4126
|
sync_version: "1",
|
|
4165
4127
|
isFreePublish: params.masssend ? "false" : "true",
|
|
@@ -4171,9 +4133,8 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
4171
4133
|
}),
|
|
4172
4134
|
defaultErrorMsg: params.masssend ? "文章群发异常,请尝试关闭群发或稍后重试。" : "文章发布异常,请稍后重试。"
|
|
4173
4135
|
});
|
|
4174
|
-
return (0,
|
|
4136
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(appMsgId, params.settingInfo.timer ? "微信公众号文章定时发布成功。" : "微信公众号发布完成。");
|
|
4175
4137
|
};
|
|
4176
|
-
var external_axios_ = __webpack_require__("axios");
|
|
4177
4138
|
const waitQrcodeResultMaxTime = 2000 * scanRetryMaxCount;
|
|
4178
4139
|
const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
4179
4140
|
const tmpCachePath = task.getTmpPath();
|
|
@@ -4221,8 +4182,8 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
4221
4182
|
const qrcodeSrc = await reward_page.locator(".invite-qrcode").getAttribute('src');
|
|
4222
4183
|
if (qrcodeSrc) {
|
|
4223
4184
|
const rewardBuffer = Buffer.from(qrcodeSrc.replace(/^data:image\/\w+;base64,/, ''), 'base64');
|
|
4224
|
-
const rewardFilePath =
|
|
4225
|
-
|
|
4185
|
+
const rewardFilePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, "weixin_reward.jpg");
|
|
4186
|
+
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(rewardFilePath, new Uint8Array(rewardBuffer));
|
|
4226
4187
|
params.safeQrcodeCallback?.(rewardFilePath);
|
|
4227
4188
|
}
|
|
4228
4189
|
} catch (error) {
|
|
@@ -4289,11 +4250,11 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
4289
4250
|
await page.waitForSelector("#editor_pannel", {
|
|
4290
4251
|
state: "visible"
|
|
4291
4252
|
});
|
|
4292
|
-
(
|
|
4253
|
+
PopupListener(page, '[v-transfer-dom="#vue_app"] .weui-desktop-dialog', "更新", '[v-transfer-dom="#vue_app"] .weui-desktop-icon-btn.weui-desktop-dialog__close-btn', {
|
|
4293
4254
|
checkInterval: 1000,
|
|
4294
4255
|
stopAfterClick: false
|
|
4295
4256
|
});
|
|
4296
|
-
(
|
|
4257
|
+
PopupListener(page, '[extclass="weui-desktop-dialog_simple"] .weui-desktop-dialog', "小店", '[extclass="weui-desktop-dialog_simple"] .weui-desktop-icon-btn.weui-desktop-dialog__close-btn', {
|
|
4297
4258
|
checkInterval: 1000,
|
|
4298
4259
|
stopAfterClick: true
|
|
4299
4260
|
});
|
|
@@ -4305,7 +4266,7 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
4305
4266
|
await titleInstance.click();
|
|
4306
4267
|
await titleInstance.fill(params.settingInfo.wxAuthor);
|
|
4307
4268
|
}
|
|
4308
|
-
await (
|
|
4269
|
+
await copyHtmlToClipboard(page, params.content);
|
|
4309
4270
|
await page.click(".js_editor_area .ProseMirror");
|
|
4310
4271
|
await page.keyboard.press("Control+V");
|
|
4311
4272
|
await page.locator("#article_setting_area").evaluate((node)=>node.scrollIntoView());
|
|
@@ -4315,8 +4276,8 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
4315
4276
|
await titleInstance.fill(params.settingInfo.wxAbstract);
|
|
4316
4277
|
}
|
|
4317
4278
|
if (params.settingInfo.wxCover) {
|
|
4318
|
-
const fileName = (0,
|
|
4319
|
-
const cover = await (0,
|
|
4279
|
+
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(params.settingInfo.wxCover);
|
|
4280
|
+
const cover = await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(params.settingInfo.wxCover, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
4320
4281
|
await page.locator("#article_setting_area #js_cover_area .select-cover__btn").hover();
|
|
4321
4282
|
await page.locator("#article_setting_area #js_cover_area .pop-opr__group-select-cover .pop-opr__list .pop-opr__item").filter({
|
|
4322
4283
|
hasText: "从图片库选择"
|
|
@@ -4502,7 +4463,7 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
4502
4463
|
const articleId = await new Promise(async (resolve)=>{
|
|
4503
4464
|
const handleResponse = async (response)=>{
|
|
4504
4465
|
const url = response.url();
|
|
4505
|
-
const query = (
|
|
4466
|
+
const query = parseUrlQueryString(url);
|
|
4506
4467
|
if (url.includes("/cgi-bin/operate_appmsg") && query?.t === "ajax-response") {
|
|
4507
4468
|
const jsonResponse = await response.json();
|
|
4508
4469
|
page.off("response", handleResponse);
|
|
@@ -4516,15 +4477,15 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
4516
4477
|
await page.locator(".mass-send .mass-send__td-setting", {
|
|
4517
4478
|
hasText: "定时发表"
|
|
4518
4479
|
}).locator(".weui-desktop-switch__box").check();
|
|
4519
|
-
let dateD = Number(
|
|
4520
|
-
let nowD = Number(
|
|
4480
|
+
let dateD = Number(TimeFormatter.format(params.settingInfo.timer, "d"));
|
|
4481
|
+
let nowD = Number(TimeFormatter.format(Date.now(), "d"));
|
|
4521
4482
|
await page.locator(".mass-send__timer .weui-desktop-form__dropdown__dt").click();
|
|
4522
4483
|
const dropMenu = page.locator(".mass-send__timer .weui-desktop-dropdown-menu").locator(".weui-desktop-dropdown__list-ele");
|
|
4523
4484
|
await dropMenu.filter({
|
|
4524
|
-
hasText: dateD == nowD ? "今天" : dateD == nowD + 1 ? "明天" :
|
|
4485
|
+
hasText: dateD == nowD ? "今天" : dateD == nowD + 1 ? "明天" : TimeFormatter.format(params.settingInfo.timer, "M月d日")
|
|
4525
4486
|
}).click();
|
|
4526
4487
|
const timeDropMenu = page.locator(".mass-send__timer .weui-desktop-picker__time:visible");
|
|
4527
|
-
await timeDropMenu.locator(".weui-desktop-form__input").fill(
|
|
4488
|
+
await timeDropMenu.locator(".weui-desktop-form__input").fill(TimeFormatter.format(params.settingInfo.timer, "hh:mm"));
|
|
4528
4489
|
await timeDropMenu.locator("i.weui-desktop-icon__time").click();
|
|
4529
4490
|
}
|
|
4530
4491
|
});
|
|
@@ -4582,13 +4543,13 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
4582
4543
|
const qrcodeSrc = await page.locator(".dialog .js_wxchecks.safe_check img.qrcode.js_qrcode").first().getAttribute("src");
|
|
4583
4544
|
if (qrcodeSrc) {
|
|
4584
4545
|
const imgUrl = new URL(qrcodeSrc, page.url()).href;
|
|
4585
|
-
const response = await (0,
|
|
4546
|
+
const response = await (0, __WEBPACK_EXTERNAL_MODULE_axios__["default"])({
|
|
4586
4547
|
method: "get",
|
|
4587
4548
|
url: imgUrl,
|
|
4588
4549
|
responseType: "arraybuffer"
|
|
4589
4550
|
});
|
|
4590
|
-
const qrcodeFilePath =
|
|
4591
|
-
|
|
4551
|
+
const qrcodeFilePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, "weixin_qrcode.jpg");
|
|
4552
|
+
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(qrcodeFilePath, response.data);
|
|
4592
4553
|
params.safeQrcodeCallback?.(qrcodeFilePath);
|
|
4593
4554
|
} else throw new Error("qrcodeSrc is empty");
|
|
4594
4555
|
});
|
|
@@ -4602,15 +4563,15 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
4602
4563
|
}
|
|
4603
4564
|
await page.waitForTimeout(3000);
|
|
4604
4565
|
await page.close();
|
|
4605
|
-
return (0,
|
|
4566
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(articleId);
|
|
4606
4567
|
};
|
|
4607
4568
|
const weixinPublish = async (task, _params)=>{
|
|
4608
|
-
const params = (
|
|
4569
|
+
const params = defaultParams(_params, {
|
|
4609
4570
|
masssend: true
|
|
4610
4571
|
});
|
|
4611
4572
|
if ("rpa" === params.actionType) return weixinPublish_rpa_rpaAction(task, params);
|
|
4612
4573
|
if ("mockApi" === params.actionType) return weixinPublish_mock_mockAction(task, params);
|
|
4613
|
-
return (
|
|
4574
|
+
return executeAction(weixinPublish_mock_mockAction, weixinPublish_rpa_rpaAction)(task, params);
|
|
4614
4575
|
};
|
|
4615
4576
|
const saveDraft = (http, params, data)=>{
|
|
4616
4577
|
const formData = new __WEBPACK_EXTERNAL_MODULE_form_data_cf000082__["default"]();
|
|
@@ -4630,7 +4591,7 @@ const saveDraft = (http, params, data)=>{
|
|
|
4630
4591
|
};
|
|
4631
4592
|
const weixinmpPublish_mock_mockAction = async (task, params)=>{
|
|
4632
4593
|
const tmpCachePath = task.getTmpPath();
|
|
4633
|
-
const http = new
|
|
4594
|
+
const http = new Http({
|
|
4634
4595
|
headers: {
|
|
4635
4596
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
4636
4597
|
origin: "https://mp.weixin.qq.com",
|
|
@@ -4641,19 +4602,19 @@ const weixinmpPublish_mock_mockAction = async (task, params)=>{
|
|
|
4641
4602
|
const cropResult = {};
|
|
4642
4603
|
if (params.banners && params.banners.length > 0) {
|
|
4643
4604
|
const images = await Promise.all(params.banners.map((url)=>{
|
|
4644
|
-
const fileName = (0,
|
|
4645
|
-
return (0,
|
|
4605
|
+
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
4606
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
4646
4607
|
}));
|
|
4647
4608
|
for(let index = 0; index < images.length; index++){
|
|
4648
4609
|
const image = images[index];
|
|
4649
|
-
const fileState = (
|
|
4610
|
+
const fileState = getFileState(image);
|
|
4650
4611
|
const formData = new __WEBPACK_EXTERNAL_MODULE_form_data_cf000082__["default"]();
|
|
4651
4612
|
formData.append("id", `WU_FILE_${index + 1}`);
|
|
4652
4613
|
formData.append("name", fileState.name);
|
|
4653
4614
|
formData.append("type", fileState.type);
|
|
4654
4615
|
formData.append("lastModifiedDate", fileState.lastModifiedDate);
|
|
4655
4616
|
formData.append("size", fileState.size);
|
|
4656
|
-
formData.append("file",
|
|
4617
|
+
formData.append("file", __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].createReadStream(image));
|
|
4657
4618
|
const response = await http.api({
|
|
4658
4619
|
method: "post",
|
|
4659
4620
|
url: `https://mp.weixin.qq.com/cgi-bin/filetransfer?action=upload_material&f=json&writetype=doublewrite&token=${params.token}&lang=zh_CN`,
|
|
@@ -4701,7 +4662,7 @@ const weixinmpPublish_mock_mockAction = async (task, params)=>{
|
|
|
4701
4662
|
];
|
|
4702
4663
|
cropFormData.append("size_count", cropRatios.length);
|
|
4703
4664
|
const cropCoordinates = cropRatios.map((r, idx)=>{
|
|
4704
|
-
const cropCoordinate = (
|
|
4665
|
+
const cropCoordinate = calculateCropCoordinates(colorResponseData.width, colorResponseData.height, r);
|
|
4705
4666
|
cropFormData.append(`size${idx}_x1`, cropCoordinate.x1);
|
|
4706
4667
|
cropFormData.append(`size${idx}_y1`, cropCoordinate.y1);
|
|
4707
4668
|
cropFormData.append(`size${idx}_x2`, cropCoordinate.x2);
|
|
@@ -4754,7 +4715,7 @@ const weixinmpPublish_mock_mockAction = async (task, params)=>{
|
|
|
4754
4715
|
content0: params.content,
|
|
4755
4716
|
share_imageinfo0: JSON.stringify(shareImageInfos)
|
|
4756
4717
|
});
|
|
4757
|
-
return (0,
|
|
4718
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(res);
|
|
4758
4719
|
};
|
|
4759
4720
|
const sourceText = {
|
|
4760
4721
|
ai: "内容由AI生成",
|
|
@@ -4791,8 +4752,8 @@ const weixinmpPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
4791
4752
|
const container = page.locator("#editor_pannel");
|
|
4792
4753
|
if (params.banners && params.banners.length > 0) {
|
|
4793
4754
|
const images = await Promise.all(params.banners.map((url)=>{
|
|
4794
|
-
const fileName = (0,
|
|
4795
|
-
return (0,
|
|
4755
|
+
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
4756
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
4796
4757
|
}));
|
|
4797
4758
|
const fileChooserPromise = page.waitForEvent("filechooser");
|
|
4798
4759
|
await container.locator(".image-selector__add").hover();
|
|
@@ -4817,12 +4778,12 @@ const weixinmpPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
4817
4778
|
if (params.banners && params.banners.length > 0) await page.waitForSelector("#editor_pannel .image-selector .image-selector__preview");
|
|
4818
4779
|
if (params.draft) await container.locator("#bottom_main #js_submit button").click();
|
|
4819
4780
|
else await container.locator("#bottom_main #js_send button").click();
|
|
4820
|
-
return (0,
|
|
4781
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)("");
|
|
4821
4782
|
};
|
|
4822
4783
|
const weixinmpPublish = async (task, params)=>{
|
|
4823
4784
|
if ("rpa" === params.actionType) return weixinmpPublish_rpa_rpaAction(task, params);
|
|
4824
4785
|
if ("mockApi" === params.actionType) return weixinmpPublish_mock_mockAction(task, params);
|
|
4825
|
-
return (
|
|
4786
|
+
return executeAction(weixinmpPublish_mock_mockAction, weixinmpPublish_rpa_rpaAction)(task, params);
|
|
4826
4787
|
};
|
|
4827
4788
|
const xiaohongshuPublish_mock_errnoMap = {
|
|
4828
4789
|
915: "所属C端账号手机号被修改,请重新登录",
|
|
@@ -4839,7 +4800,7 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
4839
4800
|
message: "账号数据异常,请重新绑定账号后重试。",
|
|
4840
4801
|
data: ""
|
|
4841
4802
|
};
|
|
4842
|
-
const http = new
|
|
4803
|
+
const http = new Http({
|
|
4843
4804
|
headers: {
|
|
4844
4805
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
4845
4806
|
origin: "https://creator.xiaohongshu.com",
|
|
@@ -4879,10 +4840,10 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
4879
4840
|
data: ""
|
|
4880
4841
|
};
|
|
4881
4842
|
const uploadFile = async (url, index)=>{
|
|
4882
|
-
const fileName = (0,
|
|
4883
|
-
const localUrl = await (0,
|
|
4843
|
+
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
4844
|
+
const localUrl = await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
4884
4845
|
const ossFileId = coverIds[index];
|
|
4885
|
-
const fileBuffer =
|
|
4846
|
+
const fileBuffer = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(localUrl);
|
|
4886
4847
|
await http.api({
|
|
4887
4848
|
method: "put",
|
|
4888
4849
|
url: `https://ros-upload.xiaohongshu.com/${ossFileId}`,
|
|
@@ -5017,7 +4978,7 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
5017
4978
|
},
|
|
5018
4979
|
defaultErrorMsg: "文章发布异常,请稍后重试。"
|
|
5019
4980
|
});
|
|
5020
|
-
return (0,
|
|
4981
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(publishResult.data?.id);
|
|
5021
4982
|
};
|
|
5022
4983
|
const rpa_xsEncrypt = new XsEncrypt();
|
|
5023
4984
|
const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
|
|
@@ -5128,8 +5089,8 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
5128
5089
|
hasText: /^上传图文$/
|
|
5129
5090
|
}).click();
|
|
5130
5091
|
const images = await Promise.all(params.banners.map((url)=>{
|
|
5131
|
-
const fileName = (0,
|
|
5132
|
-
return (0,
|
|
5092
|
+
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
5093
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
5133
5094
|
}));
|
|
5134
5095
|
const fileChooserPromise = page.waitForEvent("filechooser");
|
|
5135
5096
|
await page.getByRole("textbox").click();
|
|
@@ -5227,14 +5188,14 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
5227
5188
|
page.locator(".submit .publishBtn").click();
|
|
5228
5189
|
});
|
|
5229
5190
|
await page.close();
|
|
5230
|
-
return (0,
|
|
5191
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(response);
|
|
5231
5192
|
};
|
|
5232
5193
|
const xiaohongshuPublish = async (task, params)=>{
|
|
5233
5194
|
if ("rpa" === params.actionType) return xiaohongshuPublish_rpa_rpaAction(task, params);
|
|
5234
5195
|
if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
|
|
5235
|
-
return (
|
|
5196
|
+
return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
|
|
5236
5197
|
};
|
|
5237
|
-
var package_namespaceObject = JSON.parse('{"i8":"1.2.14-beta.
|
|
5198
|
+
var package_namespaceObject = JSON.parse('{"i8":"1.2.14-beta.3"}');
|
|
5238
5199
|
class Action {
|
|
5239
5200
|
constructor(task){
|
|
5240
5201
|
this.task = task;
|
|
@@ -5246,11 +5207,11 @@ class Action {
|
|
|
5246
5207
|
try {
|
|
5247
5208
|
responseData = await func(this.task, params);
|
|
5248
5209
|
} catch (error) {
|
|
5249
|
-
responseData =
|
|
5210
|
+
responseData = Http.handleApiError(error);
|
|
5250
5211
|
}
|
|
5251
5212
|
if (200 === responseData.code) this.task.logger.info(`${func.name} action params error`, responseData);
|
|
5252
5213
|
else if (0 !== responseData.code) {
|
|
5253
|
-
this.task.logger.error(responseData.message || `${func.name} 执行失败`, (
|
|
5214
|
+
this.task.logger.error(responseData.message || `${func.name} 执行失败`, stringifyError(responseData.data), responseData.extra);
|
|
5254
5215
|
this.task.logger.info(`${func.name} action failed`);
|
|
5255
5216
|
} else this.task.logger.info(`${func.name} action success`);
|
|
5256
5217
|
return responseData;
|