yz-yuki-plugin 2.0.4-8 → 2.0.5-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.puppeteerrc.cjs +1 -1
- package/CHANGELOG.md +3 -0
- package/README.md +19 -3
- package/defaultConfig/bilibili/config.yaml +2 -2
- package/defaultConfig/help/help.yaml +51 -51
- package/defaultConfig/weibo/config.yaml +2 -2
- package/lib/apps/bilibili.js +88 -84
- package/lib/apps/help.js +3 -3
- package/lib/apps/version.js +4 -4
- package/lib/apps/weibo.js +47 -47
- package/lib/components/dynamic/Account.js +3 -3
- package/lib/components/dynamic/Content.js +5 -5
- package/lib/components/dynamic/Footer.js +3 -3
- package/lib/components/dynamic/LogoText.js +2 -2
- package/lib/components/dynamic/MainPage.js +3 -3
- package/lib/components/loginQrcode/Page.js +1 -1
- package/lib/index.js +7 -9
- package/lib/models/bilibili/bilibili.api.d.ts +4 -4
- package/lib/models/bilibili/bilibili.api.js +13 -13
- package/lib/models/bilibili/bilibili.get.web.data.js +32 -18
- package/lib/models/bilibili/bilibili.models.d.ts +9 -9
- package/lib/models/bilibili/bilibili.models.js +248 -192
- package/lib/models/bilibili/bilibili.query.d.ts +5 -5
- package/lib/models/bilibili/bilibili.query.js +135 -114
- package/lib/models/bilibili/bilibili.task.d.ts +1 -1
- package/lib/models/bilibili/bilibili.task.js +41 -36
- package/lib/models/bilibili/bilibili.ticket.js +3 -3
- package/lib/models/bilibili/bilibili.wbi.js +10 -12
- package/lib/models/help/help.js +2 -2
- package/lib/models/weibo/weibo.api.js +2 -2
- package/lib/models/weibo/weibo.get.web.data.js +6 -7
- package/lib/models/weibo/weibo.query.d.ts +4 -4
- package/lib/models/weibo/weibo.query.js +66 -69
- package/lib/models/weibo/weibo.task.d.ts +1 -1
- package/lib/models/weibo/weibo.task.js +43 -38
- package/lib/utils/config.d.ts +2 -2
- package/lib/utils/config.js +8 -8
- package/lib/utils/paths.js +1 -1
- package/lib/utils/puppeteer.render.js +20 -22
- package/package.json +8 -4
- package/resources/css/dynamic/Account.css +1 -1
- package/resources/css/dynamic/Content.box.grid.4.css +2 -2
- package/resources/css/dynamic/Content.box.grid.9.css +2 -2
- package/resources/css/dynamic/Content.css +1 -1
- package/resources/css/dynamic/Footer.css +1 -1
- package/resources/css/dynamic/ForwardContent.css +1 -1
- package/resources/css/dynamic/LogoText.css +2 -2
- package/resources/css/dynamic/MainPage.css +4 -5
- package/resources/css/help/help.css +18 -11
- package/resources/css/loginQrcode/Page.css +7 -11
- package/resources/css/version/version.css +8 -6
|
@@ -30,30 +30,26 @@ class YukiPuppeteerRender {
|
|
|
30
30
|
try {
|
|
31
31
|
const browser = this.puppeteerInstance.browser;
|
|
32
32
|
const page = await browser?.newPage().catch(err => {
|
|
33
|
-
|
|
33
|
+
console.error(err);
|
|
34
34
|
});
|
|
35
35
|
if (!page)
|
|
36
36
|
return false;
|
|
37
|
-
await page.setViewport({
|
|
38
|
-
width: Options?.pageWidth ?? 900,
|
|
39
|
-
height: 7500
|
|
40
|
-
});
|
|
41
37
|
// 设置请求 Header
|
|
42
38
|
if (Options?.header) {
|
|
43
39
|
await page.setExtraHTTPHeaders(Options.header);
|
|
44
40
|
}
|
|
45
|
-
await page.goto(`file://${htmlPath}`, { timeout: Options?.timeout ?? 120000, waitUntil: [
|
|
41
|
+
await page.goto(`file://${htmlPath}`, { timeout: Options?.timeout ?? 120000, waitUntil: ['load', 'networkidle0'] });
|
|
46
42
|
const element = await page.$(Options?.tab ?? 'body');
|
|
47
43
|
if (!element)
|
|
48
44
|
return false;
|
|
45
|
+
// 根据 style 的值来修改 CSS 样式
|
|
46
|
+
if (Options?.addStyle) {
|
|
47
|
+
await page.addStyleTag({ content: Options.addStyle });
|
|
48
|
+
}
|
|
49
49
|
const boundingBox = await element.boundingBox(); // 获取内容区域的边界框信息
|
|
50
50
|
const num = Options?.isSplit ? Math.ceil(boundingBox.height / pageHeight) : 1; // 根据是否需要分片,计算分片数量,默认为 1
|
|
51
51
|
pageHeight = Math.round(boundingBox.height / num); //动态调整分片高度,防止过短影响观感。
|
|
52
52
|
await page.setViewport({ width: boundingBox.width + 50, height: pageHeight + 100 });
|
|
53
|
-
// 根据 style 的值来修改 CSS 样式
|
|
54
|
-
if (Options?.addStyle) {
|
|
55
|
-
await page.addStyleTag({ content: Options.addStyle, });
|
|
56
|
-
}
|
|
57
53
|
// 禁止 GIF 动图播放
|
|
58
54
|
await page.addStyleTag({ content: `img[src$=".gif"] {animation-play-state: paused !important;}` });
|
|
59
55
|
// 是否保存 html 文件
|
|
@@ -65,13 +61,15 @@ class YukiPuppeteerRender {
|
|
|
65
61
|
}
|
|
66
62
|
fs__default.writeFileSync(`${Dir}${Date.now()}.html`, htmlContent);
|
|
67
63
|
}
|
|
68
|
-
|
|
64
|
+
console.info('[puppeteer] success');
|
|
69
65
|
let start = Date.now();
|
|
70
66
|
const ret = new Array();
|
|
71
67
|
for (let i = 1; i <= num; i++) {
|
|
72
68
|
if (i > 1) {
|
|
73
|
-
await page.evaluate(pageHeight => {
|
|
74
|
-
|
|
69
|
+
await page.evaluate(pageHeight => {
|
|
70
|
+
window.scrollBy(0, pageHeight);
|
|
71
|
+
}, pageHeight); // 在页面上下文中执行滚动操作
|
|
72
|
+
await new Promise(resolve => setTimeout(resolve, 500)); // 等待一段时间,确保页面加载完成
|
|
75
73
|
}
|
|
76
74
|
let renderOptions = Options?.SOptions ?? { type: 'png' };
|
|
77
75
|
const screenshotOptions = {
|
|
@@ -80,34 +78,34 @@ class YukiPuppeteerRender {
|
|
|
80
78
|
x: 0,
|
|
81
79
|
y: pageHeight * (i - 1), // 根据分片序号计算截图区域的起始位置
|
|
82
80
|
width: Math.round(boundingBox.width), // 截图区域的宽度与内容区域宽度一致
|
|
83
|
-
height: Math.min(pageHeight, boundingBox.height - pageHeight * (i - 1))
|
|
84
|
-
}
|
|
81
|
+
height: Math.min(pageHeight, boundingBox.height - pageHeight * (i - 1)) // 截图区域的高度取决于内容区域剩余的高度或者默认的分片高度
|
|
82
|
+
}
|
|
85
83
|
};
|
|
86
84
|
const buff = await element.screenshot(screenshotOptions).catch(err => {
|
|
87
|
-
|
|
85
|
+
console.error('[puppeteer]', 'screenshot', err);
|
|
88
86
|
return false;
|
|
89
87
|
}); // 对指定区域进行截图
|
|
90
88
|
if (buff !== false) {
|
|
91
89
|
const imgBuff = !Buffer.isBuffer(buff) ? Buffer.from(buff) : buff;
|
|
92
90
|
/** 计算图片大小 */
|
|
93
|
-
const kb = (imgBuff?.length / 1024).toFixed(2) +
|
|
94
|
-
|
|
91
|
+
const kb = (imgBuff?.length / 1024).toFixed(2) + 'kb'; // 计算图片大小
|
|
92
|
+
console.warn(`[图片生成][${name}][${i}次] ${kb} ${`${Date.now() - start}ms`}`); // 记录日志
|
|
95
93
|
ret.push(imgBuff); // 将截图结果添加到数组中
|
|
96
94
|
}
|
|
97
95
|
else {
|
|
98
|
-
|
|
96
|
+
console.error(`[puppeteer]`, '截图失败');
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
99
|
if (ret.length === 0 || !ret[0]) {
|
|
102
|
-
|
|
100
|
+
console.error(`[图片生成][${name}] 图片生成为空`);
|
|
103
101
|
return false;
|
|
104
102
|
}
|
|
105
103
|
// 关闭页面
|
|
106
|
-
await page.close().catch(err =>
|
|
104
|
+
await page.close().catch(err => console.error(err));
|
|
107
105
|
return { img: ret }; // 返回图像数组
|
|
108
106
|
}
|
|
109
107
|
catch (err) {
|
|
110
|
-
|
|
108
|
+
console.error('[puppeteer] newPage', err);
|
|
111
109
|
return false;
|
|
112
110
|
}
|
|
113
111
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yz-yuki-plugin",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5-0",
|
|
4
4
|
"description": "优纪插件,yunzaijs 关于 微博推送、B站推送 等功能的拓展插件",
|
|
5
5
|
"author": "snowtafir",
|
|
6
6
|
"type": "module",
|
|
@@ -13,12 +13,14 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"app": "npx tsx src/main.ts",
|
|
15
15
|
"img-dev": "npx tsx watch --clear-screen=false routes.server.ts",
|
|
16
|
+
"render-test": "npx tsx ./render.test.ts",
|
|
16
17
|
"build": "npm run css-m && rollup --config rollup.config.js",
|
|
17
18
|
"css-app": "tailwindcss -i ./src/input.css -o ./public/output.css",
|
|
18
19
|
"css-dev": "tailwindcss -i ./src/input.css -o ./public/output.css --watch",
|
|
19
20
|
"css-m": "tailwindcss -i ./src/input.css -o ./public/output.css -m",
|
|
20
21
|
"format": "prettier --write .",
|
|
21
|
-
"check-format": "git diff --exit-code"
|
|
22
|
+
"check-format": "git diff --exit-code",
|
|
23
|
+
"prepare": "husky"
|
|
22
24
|
},
|
|
23
25
|
"dependencies": {
|
|
24
26
|
"axios": "^1.7.7",
|
|
@@ -27,6 +29,7 @@
|
|
|
27
29
|
"debug": "^4.3.6",
|
|
28
30
|
"jsdom": "^24.1.1",
|
|
29
31
|
"json5": "^2.2.3",
|
|
32
|
+
"lodash": "^4.17.21",
|
|
30
33
|
"md5": "^2.3.0",
|
|
31
34
|
"moment": "^2.30.1",
|
|
32
35
|
"node-fetch": "^3.3.2",
|
|
@@ -66,11 +69,12 @@
|
|
|
66
69
|
"axios": "^1.7.7",
|
|
67
70
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
68
71
|
"chokidar": "^3.6.0",
|
|
72
|
+
"husky": "^9.1.6",
|
|
69
73
|
"jsdom": "^24.1.1",
|
|
70
74
|
"json5": "^2.2.3",
|
|
75
|
+
"lodash": "^4.17.21",
|
|
71
76
|
"md5": "^2.3.0",
|
|
72
77
|
"node-fetch": "^3.3.2",
|
|
73
|
-
"nodemon": "^3.1.4",
|
|
74
78
|
"prettier": "^3.3.3",
|
|
75
79
|
"puppeteer": "^23.3.1",
|
|
76
80
|
"qrcode": "^1.5.4",
|
|
@@ -117,4 +121,4 @@
|
|
|
117
121
|
"engines": {
|
|
118
122
|
"node": ">=16.14.0"
|
|
119
123
|
}
|
|
120
|
-
}
|
|
124
|
+
}
|
|
@@ -19,14 +19,14 @@ body::-webkit-scrollbar {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
@font-face {
|
|
22
|
-
font-family:
|
|
23
|
-
src: url(
|
|
22
|
+
font-family: 'OPSans';
|
|
23
|
+
src: url('./../../fonts/OPSans.woff2');
|
|
24
24
|
font-weight: normal;
|
|
25
25
|
font-style: normal;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
body {
|
|
29
|
-
font-family:
|
|
29
|
+
font-family: 'OPSans', Arial, sans-serif;
|
|
30
30
|
background-color: #f9f9f9;
|
|
31
31
|
margin: 0;
|
|
32
32
|
padding: 0;
|
|
@@ -37,7 +37,6 @@ body {
|
|
|
37
37
|
width: 100%;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
40
|
.outside-border {
|
|
42
41
|
/*限制页面内收缩*/
|
|
43
42
|
width: 100%;
|
|
@@ -90,4 +89,4 @@ body {
|
|
|
90
89
|
box-sizing: border-box;
|
|
91
90
|
/**禁止选中文本*/
|
|
92
91
|
user-select: none;
|
|
93
|
-
}
|
|
92
|
+
}
|
|
@@ -19,8 +19,8 @@ body::-webkit-scrollbar {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
@font-face {
|
|
22
|
-
font-family:
|
|
23
|
-
src: url(
|
|
22
|
+
font-family: 'OPSans';
|
|
23
|
+
src: url('./../../fonts/OPSans.woff2');
|
|
24
24
|
font-weight: normal;
|
|
25
25
|
font-style: normal;
|
|
26
26
|
}
|
|
@@ -33,7 +33,7 @@ body::-webkit-scrollbar {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
body {
|
|
36
|
-
font-family:
|
|
36
|
+
font-family: 'OPSans';
|
|
37
37
|
font-size: 16px;
|
|
38
38
|
color: #1e1f20;
|
|
39
39
|
transform: scale(1.5);
|
|
@@ -41,7 +41,6 @@ body {
|
|
|
41
41
|
width: 788px;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
45
44
|
.container {
|
|
46
45
|
width: 788px;
|
|
47
46
|
padding: 15px 15px 15px 15px;
|
|
@@ -50,12 +49,14 @@ body {
|
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
.head_box {
|
|
53
|
-
font-family:
|
|
52
|
+
font-family: 'OPSans';
|
|
54
53
|
border-radius: 10px;
|
|
55
54
|
padding: 10px 20px;
|
|
56
55
|
position: relative;
|
|
57
56
|
color: #ff69b4;
|
|
58
|
-
box-shadow:
|
|
57
|
+
box-shadow:
|
|
58
|
+
0 0 1px 0 #ccc,
|
|
59
|
+
2px 2px 4px 0 rgb(238 160 236 / 80%);
|
|
59
60
|
border: 0.5px solid #ff69b4;
|
|
60
61
|
backdrop-filter: blur(10px);
|
|
61
62
|
}
|
|
@@ -87,7 +88,9 @@ body {
|
|
|
87
88
|
padding: 20px 0px 5px 0px;
|
|
88
89
|
background: transparent;
|
|
89
90
|
background-color: rgba(255 241 255 / 35%);
|
|
90
|
-
box-shadow:
|
|
91
|
+
box-shadow:
|
|
92
|
+
0 0 1px 0 #ccc,
|
|
93
|
+
2px 2px 4px 0 rgb(238 160 236 / 80%);
|
|
91
94
|
border: 0.5px solid #ff69b4;
|
|
92
95
|
position: relative;
|
|
93
96
|
}
|
|
@@ -98,7 +101,9 @@ body {
|
|
|
98
101
|
left: -8px;
|
|
99
102
|
background-color: rgb(187 187 187 / 0%);
|
|
100
103
|
backdrop-filter: blur(15px);
|
|
101
|
-
box-shadow:
|
|
104
|
+
box-shadow:
|
|
105
|
+
0 0 1px 0 #ccc,
|
|
106
|
+
2px 2px 4px 0 rgba(225 166 231 / 80%);
|
|
102
107
|
color: #ff004c;
|
|
103
108
|
font-size: 14px;
|
|
104
109
|
padding: 3px 10px;
|
|
@@ -142,7 +147,9 @@ body {
|
|
|
142
147
|
align-items: center;
|
|
143
148
|
color: #151215;
|
|
144
149
|
background: transparent;
|
|
145
|
-
box-shadow:
|
|
150
|
+
box-shadow:
|
|
151
|
+
0 0 1px 0 #ccc,
|
|
152
|
+
2px 2px 4px 0 rgb(255 213 254 / 80%);
|
|
146
153
|
padding: 8px 6px 8px 6px;
|
|
147
154
|
border-radius: 8px;
|
|
148
155
|
margin: 0 0px 10px 10px;
|
|
@@ -178,5 +185,5 @@ body {
|
|
|
178
185
|
text-align: center;
|
|
179
186
|
font-size: 14px;
|
|
180
187
|
color: rgb(0, 0, 0);
|
|
181
|
-
font-family:
|
|
182
|
-
}
|
|
188
|
+
font-family: 'OPSans';
|
|
189
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
@font-face {
|
|
2
|
-
font-family:
|
|
3
|
-
src: url(
|
|
2
|
+
font-family: 'OPSans';
|
|
3
|
+
src: url('./../../fonts/OPSans.woff2');
|
|
4
4
|
font-weight: normal;
|
|
5
5
|
font-style: normal;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
body {
|
|
9
9
|
width: 463px !important;
|
|
10
|
-
font-family:
|
|
10
|
+
font-family: 'OPSans';
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
.main-container{
|
|
13
|
+
.main-container {
|
|
14
14
|
width: 463px;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -18,12 +18,8 @@ body {
|
|
|
18
18
|
width: 380px;
|
|
19
19
|
max-height: 40rem;
|
|
20
20
|
margin: auto;
|
|
21
|
-
font-size: 1.125rem
|
|
22
|
-
|
|
23
|
-
;
|
|
24
|
-
line-height: 1.75rem
|
|
25
|
-
/* 28px */
|
|
26
|
-
;
|
|
21
|
+
font-size: 1.125rem /* 18px */;
|
|
22
|
+
line-height: 1.75rem /* 28px */;
|
|
27
23
|
padding: 20px;
|
|
28
24
|
background-color: #fff;
|
|
29
25
|
box-shadow: 0px 1px 9px 12px rgb(246 140 224 / 20%);
|
|
@@ -64,4 +60,4 @@ body {
|
|
|
64
60
|
margin-left: 2.8rem;
|
|
65
61
|
border-radius: 8px;
|
|
66
62
|
border: 1.5px dashed #fb8bc3;
|
|
67
|
-
}
|
|
63
|
+
}
|
|
@@ -19,8 +19,8 @@ body::-webkit-scrollbar {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
@font-face {
|
|
22
|
-
font-family:
|
|
23
|
-
src: url(
|
|
22
|
+
font-family: 'OPSans';
|
|
23
|
+
src: url('./../../fonts/OPSans.woff2');
|
|
24
24
|
font-weight: normal;
|
|
25
25
|
font-style: normal;
|
|
26
26
|
}
|
|
@@ -34,7 +34,7 @@ body::-webkit-scrollbar {
|
|
|
34
34
|
|
|
35
35
|
body {
|
|
36
36
|
font-size: 16px;
|
|
37
|
-
font-family:
|
|
37
|
+
font-family: 'OPSans', Arial, sans-serif;
|
|
38
38
|
transform: scale(1.5);
|
|
39
39
|
transform-origin: 0 0;
|
|
40
40
|
color: white;
|
|
@@ -52,7 +52,9 @@ body {
|
|
|
52
52
|
background: transparent;
|
|
53
53
|
margin: 5px 10px 8px 10px;
|
|
54
54
|
position: relative;
|
|
55
|
-
box-shadow:
|
|
55
|
+
box-shadow:
|
|
56
|
+
0 0 0.5px 0 #ffd1f8,
|
|
57
|
+
2px 2px 4px 0 rgb(238 160 236 / 80%);
|
|
56
58
|
border: 0.5px solid #ff69b4;
|
|
57
59
|
overflow: hidden;
|
|
58
60
|
color: #fff;
|
|
@@ -78,7 +80,7 @@ body {
|
|
|
78
80
|
padding: 10px 15px;
|
|
79
81
|
font-size: 12px;
|
|
80
82
|
font-weight: normal;
|
|
81
|
-
font-family:
|
|
83
|
+
font-family: 'OPSans';
|
|
82
84
|
background: transparent;
|
|
83
85
|
color: rgba(0, 0, 0);
|
|
84
86
|
}
|
|
@@ -113,4 +115,4 @@ body {
|
|
|
113
115
|
font-size: 14px;
|
|
114
116
|
color: rgb(15, 15, 15);
|
|
115
117
|
font-family: 'OPSans';
|
|
116
|
-
}
|
|
118
|
+
}
|