yz-yuki-plugin 2.0.6-15 → 2.0.6-16

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/CHANGELOG.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # 2.0.6
2
+ * 新增 weibo User-Agent 配置项
2
3
  * 优化api请求
3
4
  * 优化消息发送
4
5
  * 优化文字动态图片资源的发送
@@ -7,7 +8,7 @@
7
8
 
8
9
  # 2.0.5
9
10
  * 优化ck
10
- * 新增 User-Agent 配置项
11
+ * 新增 bili User-Agent 配置项
11
12
  * 优化获取动态数据
12
13
  * 新增获取B站up数据的随机延迟配置项
13
14
  * 新增puppeteer渲染图片测试脚本
@@ -11,6 +11,13 @@ pushStatus: 1
11
11
  # ❀请勿设置周期过短比如小于10分钟,以免触发访问限制。
12
12
  checkDynamicCD: '*/23 * * * *'
13
13
 
14
+ # 请求头 User-Agent 列表。请根据需要自行添加或修改。
15
+ # 可设置多个请求头,每次重启后会随机选择一个。获取方法请浏览器自行搜索。
16
+ userAgentList:
17
+ - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
18
+ #- Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:134.0) Gecko/20100101 Firefox/134.0
19
+ #- Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 Edg/132.0.0.0
20
+
14
21
  # 筛选何时发布的动态,单位为秒,默认7200秒即2小时,即以当前时间为基准,筛选过去2小时内发布的动态,并推送。
15
22
  # 取值范围:3600-36000秒,即过去的1-10h。应大于checkDynamicCD的周期。
16
23
  dynamicTimeRange: 7200
@@ -1,21 +1,47 @@
1
+ import Config from '../../utils/config.js';
2
+
1
3
  class WeiboApi {
2
- static WEIBO_API = {
3
- weiboGetIndex: 'https://m.weibo.cn/api/container/getIndex',
4
- //通过关键词${upKeyword}搜索博主 parama = { q: 'Keyword'},
5
- weiboAjaxSearch: 'https://weibo.com/ajax/side/search'
6
- };
4
+ weiboConfigData;
5
+ USER_AGENT;
6
+ constructor() {
7
+ this.weiboConfigData = Config.getUserConfig('weibo', 'config');
8
+ this.USER_AGENT = WeiboApi.WEIBO_USER_AGENT;
9
+ this.initialize();
10
+ }
11
+ static WEIBO_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36';
12
+ //初始化User-Agent
13
+ async initialize() {
14
+ await this.initUserAgent();
15
+ }
16
+ async initUserAgent() {
17
+ const userAgentList = await this.weiboConfigData.userAgentList;
18
+ if (userAgentList && userAgentList.length > 0) {
19
+ const randomIndex = Math.floor(Math.random() * userAgentList.length);
20
+ this.USER_AGENT = String(userAgentList[randomIndex]);
21
+ }
22
+ }
23
+ get WEIBO_API() {
24
+ return {
25
+ weiboGetIndex: 'https://m.weibo.cn/api/container/getIndex',
26
+ //通过关键词${upKeyword}搜索博主 parama = { q: 'Keyword'},
27
+ weiboAjaxSearch: 'https://weibo.com/ajax/side/search'
28
+ };
29
+ }
7
30
  /**统一设置header */
8
- static WEIBO_HEADERS = {
9
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
10
- 'Accept-language': 'zh-CN,zh;q=0.9',
11
- 'Authority': 'm.weibo.cn',
12
- 'Cache-control': 'max-age=0',
13
- 'Sec-fetch-dest': 'empty',
14
- 'Sec-fetch-mode': 'same-origin',
15
- 'Sec-fetch-site': 'same-origin',
16
- 'Upgrade-insecure-requests': '1',
17
- 'User-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0'
18
- };
31
+ get WEIBO_HEADERS() {
32
+ return {
33
+ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
34
+ 'Accept-language': 'zh-CN,zh;q=0.9',
35
+ 'Authority': 'm.weibo.cn',
36
+ 'Cache-control': 'max-age=0',
37
+ 'Sec-fetch-dest': 'empty',
38
+ 'Sec-fetch-mode': 'same-origin',
39
+ 'Sec-fetch-site': 'same-origin',
40
+ 'Upgrade-insecure-requests': '1',
41
+ 'User-agent': this.USER_AGENT
42
+ };
43
+ }
19
44
  }
45
+ var WeiboApi$1 = new WeiboApi();
20
46
 
21
- export { WeiboApi };
47
+ export { WeiboApi$1 as default };
@@ -1,5 +1,5 @@
1
1
  import axios from 'axios';
2
- import { WeiboApi } from './weibo.main.api.js';
2
+ import WeiboApi from './weibo.main.api.js';
3
3
  import { WeiboQuery } from './weibo.main.query.js';
4
4
 
5
5
  class WeiboWebDataFetcher {
@@ -1,6 +1,6 @@
1
1
  import moment from 'moment';
2
2
  import fetch from 'node-fetch';
3
- import { WeiboApi } from './weibo.main.api.js';
3
+ import WeiboApi from './weibo.main.api.js';
4
4
  import { Segment } from 'yunzaijs';
5
5
  import { JSDOM } from 'jsdom';
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yz-yuki-plugin",
3
- "version": "2.0.6-15",
3
+ "version": "2.0.6-16",
4
4
  "description": "优纪插件,yunzaijs 关于 微博推送、B站推送 等功能的拓展插件",
5
5
  "author": "snowtafir",
6
6
  "type": "module",
@@ -36,7 +36,7 @@
36
36
  "md5": "^2.3.0",
37
37
  "moment": "^2.30.1",
38
38
  "node-fetch": "^3.3.2",
39
- "puppeteer": "^24.1.0",
39
+ "puppeteer": "^24.4.0",
40
40
  "qrcode": "^1.5.4",
41
41
  "react": "^18.3.1",
42
42
  "react-dom": "^18.3.1",
@@ -70,7 +70,7 @@
70
70
  "node-fetch": "^3.3.2",
71
71
  "postcss": "^8.4.47",
72
72
  "prettier": "^3.4.2",
73
- "puppeteer": "^24.1.0",
73
+ "puppeteer": "^24.4.0",
74
74
  "qrcode": "^1.5.4",
75
75
  "react": "^18.3.1",
76
76
  "react-dom": "^18.3.1",