@jackwener/opencli 1.0.5 → 1.1.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/CHANGELOG.md +8 -0
- package/README.md +36 -10
- package/README.zh-CN.md +3 -0
- package/SKILL.md +7 -2
- package/dist/bilibili.js +4 -2
- package/dist/cli-manifest.json +506 -6
- package/dist/cli.js +51 -1
- package/dist/clis/antigravity/serve.js +296 -47
- package/dist/clis/arxiv/paper.d.ts +1 -0
- package/dist/clis/arxiv/paper.js +21 -0
- package/dist/clis/arxiv/search.d.ts +1 -0
- package/dist/clis/arxiv/search.js +24 -0
- package/dist/clis/arxiv/utils.d.ts +18 -0
- package/dist/clis/arxiv/utils.js +49 -0
- package/dist/clis/boss/batchgreet.d.ts +1 -0
- package/dist/clis/boss/batchgreet.js +147 -0
- package/dist/clis/boss/exchange.d.ts +1 -0
- package/dist/clis/boss/exchange.js +111 -0
- package/dist/clis/boss/greet.d.ts +1 -0
- package/dist/clis/boss/greet.js +175 -0
- package/dist/clis/boss/invite.d.ts +1 -0
- package/dist/clis/boss/invite.js +158 -0
- package/dist/clis/boss/joblist.d.ts +1 -0
- package/dist/clis/boss/joblist.js +55 -0
- package/dist/clis/boss/mark.d.ts +1 -0
- package/dist/clis/boss/mark.js +141 -0
- package/dist/clis/boss/recommend.d.ts +1 -0
- package/dist/clis/boss/recommend.js +83 -0
- package/dist/clis/boss/stats.d.ts +1 -0
- package/dist/clis/boss/stats.js +116 -0
- package/dist/clis/sinafinance/news.d.ts +7 -0
- package/dist/clis/sinafinance/news.js +61 -0
- package/dist/clis/wikipedia/search.d.ts +1 -0
- package/dist/clis/wikipedia/search.js +30 -0
- package/dist/clis/wikipedia/summary.d.ts +1 -0
- package/dist/clis/wikipedia/summary.js +28 -0
- package/dist/clis/wikipedia/utils.d.ts +8 -0
- package/dist/clis/wikipedia/utils.js +18 -0
- package/dist/clis/xiaohongshu/creator-note-detail.d.ts +64 -5
- package/dist/clis/xiaohongshu/creator-note-detail.js +258 -69
- package/dist/clis/xiaohongshu/creator-note-detail.test.d.ts +1 -0
- package/dist/clis/xiaohongshu/creator-note-detail.test.js +211 -0
- package/dist/clis/xiaohongshu/creator-notes-summary.d.ts +28 -0
- package/dist/clis/xiaohongshu/creator-notes-summary.js +92 -0
- package/dist/clis/xiaohongshu/creator-notes-summary.test.d.ts +1 -0
- package/dist/clis/xiaohongshu/creator-notes-summary.test.js +49 -0
- package/dist/clis/xiaohongshu/creator-notes.d.ts +18 -5
- package/dist/clis/xiaohongshu/creator-notes.js +159 -71
- package/dist/clis/xiaohongshu/creator-notes.test.d.ts +1 -0
- package/dist/clis/xiaohongshu/creator-notes.test.js +162 -0
- package/dist/external.d.ts +20 -0
- package/dist/external.js +159 -0
- package/docs/.vitepress/config.mts +1 -0
- package/docs/public/CNAME +1 -0
- package/package.json +1 -1
- package/src/bilibili.ts +4 -2
- package/src/browser/cdp.ts +3 -3
- package/src/cli.ts +56 -1
- package/src/clis/antigravity/README.md +3 -46
- package/src/clis/antigravity/serve.ts +323 -50
- package/src/clis/arxiv/paper.ts +21 -0
- package/src/clis/arxiv/search.ts +24 -0
- package/src/clis/arxiv/utils.ts +63 -0
- package/src/clis/boss/batchgreet.ts +167 -0
- package/src/clis/boss/exchange.ts +126 -0
- package/src/clis/boss/greet.ts +198 -0
- package/src/clis/boss/invite.ts +177 -0
- package/src/clis/boss/joblist.ts +63 -0
- package/src/clis/boss/mark.ts +155 -0
- package/src/clis/boss/recommend.ts +94 -0
- package/src/clis/boss/stats.ts +130 -0
- package/src/clis/chaoxing/README.md +2 -24
- package/src/clis/chatgpt/README.md +3 -42
- package/src/clis/chatwise/README.md +3 -36
- package/src/clis/codex/README.md +3 -32
- package/src/clis/cursor/README.md +3 -31
- package/src/clis/discord-app/README.md +2 -25
- package/src/clis/feishu/README.md +2 -17
- package/src/clis/neteasemusic/README.md +3 -29
- package/src/clis/notion/README.md +2 -26
- package/src/clis/sinafinance/news.ts +76 -0
- package/src/clis/wechat/README.md +2 -25
- package/src/clis/wikipedia/search.ts +32 -0
- package/src/clis/wikipedia/summary.ts +28 -0
- package/src/clis/wikipedia/utils.ts +20 -0
- package/src/clis/xiaohongshu/creator-note-detail.test.ts +223 -0
- package/src/clis/xiaohongshu/creator-note-detail.ts +340 -72
- package/src/clis/xiaohongshu/creator-notes-summary.test.ts +54 -0
- package/src/clis/xiaohongshu/creator-notes-summary.ts +120 -0
- package/src/clis/xiaohongshu/creator-notes.test.ts +178 -0
- package/src/clis/xiaohongshu/creator-notes.ts +215 -75
- package/src/daemon.ts +3 -3
- package/src/external-clis.yaml +39 -0
- package/src/external.ts +182 -0
- package/CDP.md +0 -103
- package/CDP.zh-CN.md +0 -103
- package/CLI-ELECTRON.md +0 -125
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BOSS直聘 batchgreet — batch greet recommended candidates.
|
|
3
|
+
*
|
|
4
|
+
* Combines recommend (greetRecSortList) + greet (UI automation).
|
|
5
|
+
* Sends greeting messages to multiple candidates sequentially.
|
|
6
|
+
*/
|
|
7
|
+
import { cli, Strategy } from '../../registry.js';
|
|
8
|
+
cli({
|
|
9
|
+
site: 'boss',
|
|
10
|
+
name: 'batchgreet',
|
|
11
|
+
description: 'BOSS直聘批量向推荐候选人发送招呼',
|
|
12
|
+
domain: 'www.zhipin.com',
|
|
13
|
+
strategy: Strategy.COOKIE,
|
|
14
|
+
browser: true,
|
|
15
|
+
args: [
|
|
16
|
+
{ name: 'job_id', default: '', help: 'Filter by encrypted job ID (greet all jobs if empty)' },
|
|
17
|
+
{ name: 'limit', type: 'int', default: 5, help: 'Max candidates to greet' },
|
|
18
|
+
{ name: 'text', default: '', help: 'Custom greeting message (uses default if empty)' },
|
|
19
|
+
],
|
|
20
|
+
columns: ['name', 'status', 'detail'],
|
|
21
|
+
func: async (page, kwargs) => {
|
|
22
|
+
if (!page)
|
|
23
|
+
throw new Error('Browser page required');
|
|
24
|
+
const filterJobId = kwargs.job_id || '';
|
|
25
|
+
const limit = kwargs.limit || 5;
|
|
26
|
+
const text = kwargs.text || '你好,请问您对这个职位感兴趣吗?';
|
|
27
|
+
if (process.env.OPENCLI_VERBOSE) {
|
|
28
|
+
console.error(`[opencli:boss] Batch greeting up to ${limit} candidates...`);
|
|
29
|
+
}
|
|
30
|
+
await page.goto('https://www.zhipin.com/web/chat/index');
|
|
31
|
+
await page.wait({ time: 3 });
|
|
32
|
+
// Get recommended candidates
|
|
33
|
+
const listData = await page.evaluate(`
|
|
34
|
+
async () => {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
const xhr = new XMLHttpRequest();
|
|
37
|
+
xhr.open('GET', 'https://www.zhipin.com/wapi/zprelation/friend/greetRecSortList', true);
|
|
38
|
+
xhr.withCredentials = true;
|
|
39
|
+
xhr.timeout = 15000;
|
|
40
|
+
xhr.setRequestHeader('Accept', 'application/json');
|
|
41
|
+
xhr.onload = () => { try { resolve(JSON.parse(xhr.responseText)); } catch(e) { reject(e); } };
|
|
42
|
+
xhr.onerror = () => reject(new Error('Network Error'));
|
|
43
|
+
xhr.send();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
`);
|
|
47
|
+
if (listData.code !== 0) {
|
|
48
|
+
if (listData.code === 7 || listData.code === 37) {
|
|
49
|
+
throw new Error('Cookie 已过期!请在当前 Chrome 浏览器中重新登录 BOSS 直聘。');
|
|
50
|
+
}
|
|
51
|
+
throw new Error(`获取推荐列表失败: ${listData.message}`);
|
|
52
|
+
}
|
|
53
|
+
let candidates = listData.zpData?.friendList || [];
|
|
54
|
+
if (filterJobId) {
|
|
55
|
+
candidates = candidates.filter((f) => f.encryptJobId === filterJobId);
|
|
56
|
+
}
|
|
57
|
+
candidates = candidates.slice(0, limit);
|
|
58
|
+
if (candidates.length === 0) {
|
|
59
|
+
return [{ name: '-', status: '⚠️ 无候选人', detail: '当前没有待招呼的推荐候选人' }];
|
|
60
|
+
}
|
|
61
|
+
const results = [];
|
|
62
|
+
for (const candidate of candidates) {
|
|
63
|
+
const numericUid = candidate.uid;
|
|
64
|
+
const friendName = candidate.name || '候选人';
|
|
65
|
+
try {
|
|
66
|
+
// Click on candidate
|
|
67
|
+
const clicked = await page.evaluate(`
|
|
68
|
+
async () => {
|
|
69
|
+
const item = document.querySelector('#_${numericUid}-0') || document.querySelector('[id^="_${numericUid}"]');
|
|
70
|
+
if (item) {
|
|
71
|
+
item.click();
|
|
72
|
+
return { clicked: true };
|
|
73
|
+
}
|
|
74
|
+
const items = document.querySelectorAll('.geek-item');
|
|
75
|
+
for (const el of items) {
|
|
76
|
+
if (el.id && el.id.startsWith('_${numericUid}')) {
|
|
77
|
+
el.click();
|
|
78
|
+
return { clicked: true };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return { clicked: false };
|
|
82
|
+
}
|
|
83
|
+
`);
|
|
84
|
+
if (!clicked.clicked) {
|
|
85
|
+
results.push({ name: friendName, status: '❌ 跳过', detail: '在聊天列表中未找到' });
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
await page.wait({ time: 2 });
|
|
89
|
+
// Type message
|
|
90
|
+
const typed = await page.evaluate(`
|
|
91
|
+
async () => {
|
|
92
|
+
const selectors = [
|
|
93
|
+
'.chat-editor [contenteditable="true"]',
|
|
94
|
+
'.chat-input [contenteditable="true"]',
|
|
95
|
+
'[contenteditable="true"]',
|
|
96
|
+
'textarea',
|
|
97
|
+
];
|
|
98
|
+
for (const sel of selectors) {
|
|
99
|
+
const el = document.querySelector(sel);
|
|
100
|
+
if (el && el.offsetParent !== null) {
|
|
101
|
+
el.focus();
|
|
102
|
+
if (el.tagName === 'TEXTAREA' || el.tagName === 'INPUT') {
|
|
103
|
+
el.value = ${JSON.stringify(text)};
|
|
104
|
+
el.dispatchEvent(new Event('input', { bubbles: true }));
|
|
105
|
+
} else {
|
|
106
|
+
el.textContent = '';
|
|
107
|
+
el.focus();
|
|
108
|
+
document.execCommand('insertText', false, ${JSON.stringify(text)});
|
|
109
|
+
el.dispatchEvent(new Event('input', { bubbles: true }));
|
|
110
|
+
}
|
|
111
|
+
return { found: true };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return { found: false };
|
|
115
|
+
}
|
|
116
|
+
`);
|
|
117
|
+
if (!typed.found) {
|
|
118
|
+
results.push({ name: friendName, status: '❌ 失败', detail: '找不到消息输入框' });
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
await page.wait({ time: 0.5 });
|
|
122
|
+
// Click send
|
|
123
|
+
const sent = await page.evaluate(`
|
|
124
|
+
async () => {
|
|
125
|
+
const btn = document.querySelector('.conversation-editor .submit')
|
|
126
|
+
|| document.querySelector('.submit-content .submit')
|
|
127
|
+
|| document.querySelector('.conversation-operate .submit');
|
|
128
|
+
if (btn) {
|
|
129
|
+
btn.click();
|
|
130
|
+
return { clicked: true };
|
|
131
|
+
}
|
|
132
|
+
return { clicked: false };
|
|
133
|
+
}
|
|
134
|
+
`);
|
|
135
|
+
if (!sent.clicked) {
|
|
136
|
+
await page.pressKey('Enter');
|
|
137
|
+
}
|
|
138
|
+
await page.wait({ time: 1.5 });
|
|
139
|
+
results.push({ name: friendName, status: '✅ 已发送', detail: text });
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
results.push({ name: friendName, status: '❌ 失败', detail: e.message?.substring(0, 80) || '未知错误' });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return results;
|
|
146
|
+
},
|
|
147
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BOSS直聘 exchange — request phone/wechat exchange with a candidate.
|
|
3
|
+
*
|
|
4
|
+
* Uses POST /wapi/zpchat/exchange/request to send an exchange request.
|
|
5
|
+
*/
|
|
6
|
+
import { cli, Strategy } from '../../registry.js';
|
|
7
|
+
cli({
|
|
8
|
+
site: 'boss',
|
|
9
|
+
name: 'exchange',
|
|
10
|
+
description: 'BOSS直聘交换联系方式(请求手机/微信)',
|
|
11
|
+
domain: 'www.zhipin.com',
|
|
12
|
+
strategy: Strategy.COOKIE,
|
|
13
|
+
browser: true,
|
|
14
|
+
args: [
|
|
15
|
+
{ name: 'uid', required: true, help: 'Encrypted UID of the candidate' },
|
|
16
|
+
{ name: 'type', default: 'phone', choices: ['phone', 'wechat'], help: 'Exchange type: phone or wechat' },
|
|
17
|
+
],
|
|
18
|
+
columns: ['status', 'detail'],
|
|
19
|
+
func: async (page, kwargs) => {
|
|
20
|
+
if (!page)
|
|
21
|
+
throw new Error('Browser page required');
|
|
22
|
+
const uid = kwargs.uid;
|
|
23
|
+
const exchangeType = kwargs.type || 'phone';
|
|
24
|
+
if (process.env.OPENCLI_VERBOSE) {
|
|
25
|
+
console.error(`[opencli:boss] Requesting ${exchangeType} exchange for ${uid}...`);
|
|
26
|
+
}
|
|
27
|
+
await page.goto('https://www.zhipin.com/web/chat/index');
|
|
28
|
+
await page.wait({ time: 2 });
|
|
29
|
+
// Find candidate
|
|
30
|
+
let friend = null;
|
|
31
|
+
// Check greet list
|
|
32
|
+
const greetData = await page.evaluate(`
|
|
33
|
+
async () => {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
const xhr = new XMLHttpRequest();
|
|
36
|
+
xhr.open('GET', 'https://www.zhipin.com/wapi/zprelation/friend/greetRecSortList', true);
|
|
37
|
+
xhr.withCredentials = true;
|
|
38
|
+
xhr.timeout = 15000;
|
|
39
|
+
xhr.setRequestHeader('Accept', 'application/json');
|
|
40
|
+
xhr.onload = () => { try { resolve(JSON.parse(xhr.responseText)); } catch(e) { reject(e); } };
|
|
41
|
+
xhr.onerror = () => reject(new Error('Network Error'));
|
|
42
|
+
xhr.send();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
`);
|
|
46
|
+
if (greetData.code === 0) {
|
|
47
|
+
friend = (greetData.zpData?.friendList || []).find((f) => f.encryptUid === uid);
|
|
48
|
+
}
|
|
49
|
+
if (!friend) {
|
|
50
|
+
const friendData = await page.evaluate(`
|
|
51
|
+
async () => {
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
const xhr = new XMLHttpRequest();
|
|
54
|
+
xhr.open('GET', 'https://www.zhipin.com/wapi/zprelation/friend/getBossFriendListV2.json?page=1&status=0&jobId=0', true);
|
|
55
|
+
xhr.withCredentials = true;
|
|
56
|
+
xhr.timeout = 15000;
|
|
57
|
+
xhr.setRequestHeader('Accept', 'application/json');
|
|
58
|
+
xhr.onload = () => { try { resolve(JSON.parse(xhr.responseText)); } catch(e) { reject(e); } };
|
|
59
|
+
xhr.onerror = () => reject(new Error('Network Error'));
|
|
60
|
+
xhr.send();
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
`);
|
|
64
|
+
if (friendData.code === 0) {
|
|
65
|
+
friend = (friendData.zpData?.friendList || []).find((f) => f.encryptUid === uid);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!friend) {
|
|
69
|
+
throw new Error('未找到该候选人');
|
|
70
|
+
}
|
|
71
|
+
const numericUid = friend.uid;
|
|
72
|
+
const friendName = friend.name || '候选人';
|
|
73
|
+
const securityId = friend.securityId || '';
|
|
74
|
+
// type mapping from JS source: 1=phone, 2=wechat, 4=resume
|
|
75
|
+
const typeId = exchangeType === 'wechat' ? 2 : 1;
|
|
76
|
+
// Params from JS: {type, securityId, uniqueId, name}
|
|
77
|
+
const params = new URLSearchParams({
|
|
78
|
+
type: String(typeId),
|
|
79
|
+
securityId: securityId,
|
|
80
|
+
uniqueId: String(numericUid),
|
|
81
|
+
name: friendName,
|
|
82
|
+
});
|
|
83
|
+
// POST with form-urlencoded (discovered from 336.js bundle)
|
|
84
|
+
const data = await page.evaluate(`
|
|
85
|
+
async () => {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
const xhr = new XMLHttpRequest();
|
|
88
|
+
xhr.open('POST', 'https://www.zhipin.com/wapi/zpchat/exchange/request', true);
|
|
89
|
+
xhr.withCredentials = true;
|
|
90
|
+
xhr.timeout = 15000;
|
|
91
|
+
xhr.setRequestHeader('Accept', 'application/json');
|
|
92
|
+
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
93
|
+
xhr.onload = () => { try { resolve(JSON.parse(xhr.responseText)); } catch(e) { reject(new Error('JSON parse failed')); } };
|
|
94
|
+
xhr.onerror = () => reject(new Error('Network Error'));
|
|
95
|
+
xhr.send(${JSON.stringify(params.toString())});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
`);
|
|
99
|
+
if (data.code !== 0) {
|
|
100
|
+
if (data.code === 7 || data.code === 37) {
|
|
101
|
+
throw new Error('Cookie 已过期!请在当前 Chrome 浏览器中重新登录 BOSS 直聘。');
|
|
102
|
+
}
|
|
103
|
+
throw new Error(`交换请求失败: ${data.message} (code=${data.code})`);
|
|
104
|
+
}
|
|
105
|
+
const typeLabel = exchangeType === 'wechat' ? '微信' : '手机号';
|
|
106
|
+
return [{
|
|
107
|
+
status: '✅ 交换请求已发送',
|
|
108
|
+
detail: `已向 ${friendName} 发送${typeLabel}交换请求`,
|
|
109
|
+
}];
|
|
110
|
+
},
|
|
111
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BOSS直聘 greet — send greeting to a new candidate (initiate chat).
|
|
3
|
+
*
|
|
4
|
+
* This is different from send.ts which messages existing contacts.
|
|
5
|
+
* For new candidates (from recommend list), we navigate to their chat page
|
|
6
|
+
* and use UI automation to send the greeting message.
|
|
7
|
+
*
|
|
8
|
+
* The greetRecSortList provides candidates who have applied or been recommended.
|
|
9
|
+
* We click on them in the list and send a greeting.
|
|
10
|
+
*/
|
|
11
|
+
import { cli, Strategy } from '../../registry.js';
|
|
12
|
+
cli({
|
|
13
|
+
site: 'boss',
|
|
14
|
+
name: 'greet',
|
|
15
|
+
description: 'BOSS直聘向新候选人发送招呼(开始聊天)',
|
|
16
|
+
domain: 'www.zhipin.com',
|
|
17
|
+
strategy: Strategy.COOKIE,
|
|
18
|
+
browser: true,
|
|
19
|
+
args: [
|
|
20
|
+
{ name: 'uid', required: true, help: 'Encrypted UID of the candidate (from recommend)' },
|
|
21
|
+
{ name: 'security_id', required: true, help: 'Security ID of the candidate' },
|
|
22
|
+
{ name: 'job_id', required: true, help: 'Encrypted job ID' },
|
|
23
|
+
{ name: 'text', default: '', help: 'Custom greeting message (uses default template if empty)' },
|
|
24
|
+
],
|
|
25
|
+
columns: ['status', 'detail'],
|
|
26
|
+
func: async (page, kwargs) => {
|
|
27
|
+
if (!page)
|
|
28
|
+
throw new Error('Browser page required');
|
|
29
|
+
const uid = kwargs.uid;
|
|
30
|
+
const securityId = kwargs.security_id;
|
|
31
|
+
const jobId = kwargs.job_id;
|
|
32
|
+
const text = kwargs.text;
|
|
33
|
+
if (process.env.OPENCLI_VERBOSE) {
|
|
34
|
+
console.error(`[opencli:boss] Greeting candidate ${uid}...`);
|
|
35
|
+
}
|
|
36
|
+
// Navigate to chat page
|
|
37
|
+
await page.goto('https://www.zhipin.com/web/chat/index');
|
|
38
|
+
await page.wait({ time: 3 });
|
|
39
|
+
// Find the candidate in the greet list by encryptUid
|
|
40
|
+
const listData = await page.evaluate(`
|
|
41
|
+
async () => {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
const xhr = new XMLHttpRequest();
|
|
44
|
+
xhr.open('GET', 'https://www.zhipin.com/wapi/zprelation/friend/greetRecSortList', true);
|
|
45
|
+
xhr.withCredentials = true;
|
|
46
|
+
xhr.timeout = 15000;
|
|
47
|
+
xhr.setRequestHeader('Accept', 'application/json');
|
|
48
|
+
xhr.onload = () => { try { resolve(JSON.parse(xhr.responseText)); } catch(e) { reject(e); } };
|
|
49
|
+
xhr.onerror = () => reject(new Error('Network Error'));
|
|
50
|
+
xhr.send();
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
`);
|
|
54
|
+
if (listData.code !== 0) {
|
|
55
|
+
if (listData.code === 7 || listData.code === 37) {
|
|
56
|
+
throw new Error('Cookie 已过期!请在当前 Chrome 浏览器中重新登录 BOSS 直聘。');
|
|
57
|
+
}
|
|
58
|
+
throw new Error(`获取候选人列表失败: ${listData.message}`);
|
|
59
|
+
}
|
|
60
|
+
// Also check the regular friend list
|
|
61
|
+
let target = null;
|
|
62
|
+
const greetList = listData.zpData?.friendList || [];
|
|
63
|
+
target = greetList.find((f) => f.encryptUid === uid);
|
|
64
|
+
let numericUid = null;
|
|
65
|
+
let friendName = '候选人';
|
|
66
|
+
if (target) {
|
|
67
|
+
numericUid = target.uid;
|
|
68
|
+
friendName = target.name || friendName;
|
|
69
|
+
}
|
|
70
|
+
if (!numericUid) {
|
|
71
|
+
// Try to find in friend list
|
|
72
|
+
const friendData = await page.evaluate(`
|
|
73
|
+
async () => {
|
|
74
|
+
return new Promise((resolve, reject) => {
|
|
75
|
+
const xhr = new XMLHttpRequest();
|
|
76
|
+
xhr.open('GET', 'https://www.zhipin.com/wapi/zprelation/friend/getBossFriendListV2.json?page=1&status=0&jobId=0', true);
|
|
77
|
+
xhr.withCredentials = true;
|
|
78
|
+
xhr.timeout = 15000;
|
|
79
|
+
xhr.setRequestHeader('Accept', 'application/json');
|
|
80
|
+
xhr.onload = () => { try { resolve(JSON.parse(xhr.responseText)); } catch(e) { reject(e); } };
|
|
81
|
+
xhr.onerror = () => reject(new Error('Network Error'));
|
|
82
|
+
xhr.send();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
`);
|
|
86
|
+
if (friendData.code === 0) {
|
|
87
|
+
const allFriends = friendData.zpData?.friendList || [];
|
|
88
|
+
const found = allFriends.find((f) => f.encryptUid === uid);
|
|
89
|
+
if (found) {
|
|
90
|
+
numericUid = found.uid;
|
|
91
|
+
friendName = found.name || friendName;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (!numericUid) {
|
|
96
|
+
throw new Error('未找到该候选人,请确认 uid 是否正确(可从 recommend 命令获取)');
|
|
97
|
+
}
|
|
98
|
+
// Click on the candidate in the chat list
|
|
99
|
+
const clicked = await page.evaluate(`
|
|
100
|
+
async () => {
|
|
101
|
+
const item = document.querySelector('#_${numericUid}-0') || document.querySelector('[id^="_${numericUid}"]');
|
|
102
|
+
if (item) {
|
|
103
|
+
item.click();
|
|
104
|
+
return { clicked: true, id: item.id };
|
|
105
|
+
}
|
|
106
|
+
const items = document.querySelectorAll('.geek-item');
|
|
107
|
+
for (const el of items) {
|
|
108
|
+
if (el.id && el.id.startsWith('_${numericUid}')) {
|
|
109
|
+
el.click();
|
|
110
|
+
return { clicked: true, id: el.id };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return { clicked: false };
|
|
114
|
+
}
|
|
115
|
+
`);
|
|
116
|
+
if (!clicked.clicked) {
|
|
117
|
+
throw new Error('无法在聊天列表中找到该用户,候选人可能不在当前列表中');
|
|
118
|
+
}
|
|
119
|
+
await page.wait({ time: 2 });
|
|
120
|
+
// Type the message
|
|
121
|
+
const msgText = text || '你好,请问您对这个职位感兴趣吗?';
|
|
122
|
+
const typed = await page.evaluate(`
|
|
123
|
+
async () => {
|
|
124
|
+
const selectors = [
|
|
125
|
+
'.chat-editor [contenteditable="true"]',
|
|
126
|
+
'.chat-input [contenteditable="true"]',
|
|
127
|
+
'.message-editor [contenteditable="true"]',
|
|
128
|
+
'.chat-conversation [contenteditable="true"]',
|
|
129
|
+
'[contenteditable="true"]',
|
|
130
|
+
'textarea',
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
for (const sel of selectors) {
|
|
134
|
+
const el = document.querySelector(sel);
|
|
135
|
+
if (el && el.offsetParent !== null) {
|
|
136
|
+
el.focus();
|
|
137
|
+
if (el.tagName === 'TEXTAREA' || el.tagName === 'INPUT') {
|
|
138
|
+
el.value = ${JSON.stringify(msgText)};
|
|
139
|
+
el.dispatchEvent(new Event('input', { bubbles: true }));
|
|
140
|
+
} else {
|
|
141
|
+
el.textContent = '';
|
|
142
|
+
el.focus();
|
|
143
|
+
document.execCommand('insertText', false, ${JSON.stringify(msgText)});
|
|
144
|
+
el.dispatchEvent(new Event('input', { bubbles: true }));
|
|
145
|
+
}
|
|
146
|
+
return { found: true, selector: sel };
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return { found: false };
|
|
150
|
+
}
|
|
151
|
+
`);
|
|
152
|
+
if (!typed.found) {
|
|
153
|
+
throw new Error('找不到消息输入框');
|
|
154
|
+
}
|
|
155
|
+
await page.wait({ time: 0.5 });
|
|
156
|
+
// Click send button
|
|
157
|
+
const sent = await page.evaluate(`
|
|
158
|
+
async () => {
|
|
159
|
+
const btn = document.querySelector('.conversation-editor .submit')
|
|
160
|
+
|| document.querySelector('.submit-content .submit')
|
|
161
|
+
|| document.querySelector('.conversation-operate .submit');
|
|
162
|
+
if (btn) {
|
|
163
|
+
btn.click();
|
|
164
|
+
return { clicked: true };
|
|
165
|
+
}
|
|
166
|
+
return { clicked: false };
|
|
167
|
+
}
|
|
168
|
+
`);
|
|
169
|
+
if (!sent.clicked) {
|
|
170
|
+
await page.pressKey('Enter');
|
|
171
|
+
}
|
|
172
|
+
await page.wait({ time: 1 });
|
|
173
|
+
return [{ status: '✅ 招呼已发送', detail: `已向 ${friendName} 发送: ${msgText}` }];
|
|
174
|
+
},
|
|
175
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BOSS直聘 invite — send interview invitation to a candidate.
|
|
3
|
+
*
|
|
4
|
+
* Uses POST /wapi/zpinterview/boss/interview/invite to send interview invitations.
|
|
5
|
+
* Address and contact info come from the boss's saved settings.
|
|
6
|
+
*/
|
|
7
|
+
import { cli, Strategy } from '../../registry.js';
|
|
8
|
+
cli({
|
|
9
|
+
site: 'boss',
|
|
10
|
+
name: 'invite',
|
|
11
|
+
description: 'BOSS直聘发送面试邀请',
|
|
12
|
+
domain: 'www.zhipin.com',
|
|
13
|
+
strategy: Strategy.COOKIE,
|
|
14
|
+
browser: true,
|
|
15
|
+
args: [
|
|
16
|
+
{ name: 'uid', required: true, help: 'Encrypted UID of the candidate' },
|
|
17
|
+
{ name: 'time', required: true, help: 'Interview time (e.g. 2025-04-01 14:00)' },
|
|
18
|
+
{ name: 'address', default: '', help: 'Interview address (uses saved address if empty)' },
|
|
19
|
+
{ name: 'contact', default: '', help: 'Contact person name (uses saved contact if empty)' },
|
|
20
|
+
],
|
|
21
|
+
columns: ['status', 'detail'],
|
|
22
|
+
func: async (page, kwargs) => {
|
|
23
|
+
if (!page)
|
|
24
|
+
throw new Error('Browser page required');
|
|
25
|
+
const uid = kwargs.uid;
|
|
26
|
+
const timeStr = kwargs.time;
|
|
27
|
+
const address = kwargs.address;
|
|
28
|
+
const contact = kwargs.contact;
|
|
29
|
+
if (process.env.OPENCLI_VERBOSE) {
|
|
30
|
+
console.error(`[opencli:boss] Sending interview invitation to ${uid}...`);
|
|
31
|
+
}
|
|
32
|
+
await page.goto('https://www.zhipin.com/web/chat/index');
|
|
33
|
+
await page.wait({ time: 2 });
|
|
34
|
+
// Get candidate info
|
|
35
|
+
let friend = null;
|
|
36
|
+
// Check greet list first
|
|
37
|
+
const greetData = await page.evaluate(`
|
|
38
|
+
async () => {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
const xhr = new XMLHttpRequest();
|
|
41
|
+
xhr.open('GET', 'https://www.zhipin.com/wapi/zprelation/friend/greetRecSortList', true);
|
|
42
|
+
xhr.withCredentials = true;
|
|
43
|
+
xhr.timeout = 15000;
|
|
44
|
+
xhr.setRequestHeader('Accept', 'application/json');
|
|
45
|
+
xhr.onload = () => { try { resolve(JSON.parse(xhr.responseText)); } catch(e) { reject(e); } };
|
|
46
|
+
xhr.onerror = () => reject(new Error('Network Error'));
|
|
47
|
+
xhr.send();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
`);
|
|
51
|
+
if (greetData.code === 0) {
|
|
52
|
+
friend = (greetData.zpData?.friendList || []).find((f) => f.encryptUid === uid);
|
|
53
|
+
}
|
|
54
|
+
if (!friend) {
|
|
55
|
+
const friendData = await page.evaluate(`
|
|
56
|
+
async () => {
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
const xhr = new XMLHttpRequest();
|
|
59
|
+
xhr.open('GET', 'https://www.zhipin.com/wapi/zprelation/friend/getBossFriendListV2.json?page=1&status=0&jobId=0', true);
|
|
60
|
+
xhr.withCredentials = true;
|
|
61
|
+
xhr.timeout = 15000;
|
|
62
|
+
xhr.setRequestHeader('Accept', 'application/json');
|
|
63
|
+
xhr.onload = () => { try { resolve(JSON.parse(xhr.responseText)); } catch(e) { reject(e); } };
|
|
64
|
+
xhr.onerror = () => reject(new Error('Network Error'));
|
|
65
|
+
xhr.send();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
`);
|
|
69
|
+
if (friendData.code === 0) {
|
|
70
|
+
friend = (friendData.zpData?.friendList || []).find((f) => f.encryptUid === uid);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (!friend) {
|
|
74
|
+
throw new Error('未找到该候选人');
|
|
75
|
+
}
|
|
76
|
+
const numericUid = friend.uid;
|
|
77
|
+
const friendName = friend.name || '候选人';
|
|
78
|
+
const securityId = friend.securityId || '';
|
|
79
|
+
const encJobId = friend.encryptJobId || '';
|
|
80
|
+
// Get saved contact info
|
|
81
|
+
const contactData = await page.evaluate(`
|
|
82
|
+
async () => {
|
|
83
|
+
return new Promise((resolve, reject) => {
|
|
84
|
+
const xhr = new XMLHttpRequest();
|
|
85
|
+
xhr.open('GET', 'https://www.zhipin.com/wapi/zpinterview/boss/interview/contactInit', true);
|
|
86
|
+
xhr.withCredentials = true;
|
|
87
|
+
xhr.timeout = 10000;
|
|
88
|
+
xhr.setRequestHeader('Accept', 'application/json');
|
|
89
|
+
xhr.onload = () => { try { resolve(JSON.parse(xhr.responseText)); } catch(e) { reject(e); } };
|
|
90
|
+
xhr.onerror = () => reject(new Error('Network Error'));
|
|
91
|
+
xhr.send();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
`);
|
|
95
|
+
const contactId = contactData.zpData?.contactId || '';
|
|
96
|
+
const contactName = contact || contactData.zpData?.contactName || '';
|
|
97
|
+
const contactPhone = contactData.zpData?.contactPhone || '';
|
|
98
|
+
// Get saved address
|
|
99
|
+
const addressData = await page.evaluate(`
|
|
100
|
+
async () => {
|
|
101
|
+
return new Promise((resolve, reject) => {
|
|
102
|
+
const xhr = new XMLHttpRequest();
|
|
103
|
+
xhr.open('GET', 'https://www.zhipin.com/wapi/zpinterview/boss/interview/listAddress', true);
|
|
104
|
+
xhr.withCredentials = true;
|
|
105
|
+
xhr.timeout = 10000;
|
|
106
|
+
xhr.setRequestHeader('Accept', 'application/json');
|
|
107
|
+
xhr.onload = () => { try { resolve(JSON.parse(xhr.responseText)); } catch(e) { reject(e); } };
|
|
108
|
+
xhr.onerror = () => reject(new Error('Network Error'));
|
|
109
|
+
xhr.send();
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
`);
|
|
113
|
+
const savedAddress = addressData.zpData?.list?.[0] || {};
|
|
114
|
+
const addressText = address || savedAddress.cityAddressText || savedAddress.addressText || '';
|
|
115
|
+
// Parse interview time
|
|
116
|
+
const interviewTime = new Date(timeStr).getTime();
|
|
117
|
+
if (isNaN(interviewTime)) {
|
|
118
|
+
throw new Error(`时间格式错误: ${timeStr},请使用格式如 2025-04-01 14:00`);
|
|
119
|
+
}
|
|
120
|
+
// Send interview invitation
|
|
121
|
+
const params = new URLSearchParams({
|
|
122
|
+
uid: String(numericUid),
|
|
123
|
+
securityId: securityId,
|
|
124
|
+
encryptJobId: encJobId,
|
|
125
|
+
interviewTime: String(interviewTime),
|
|
126
|
+
contactId: contactId,
|
|
127
|
+
contactName: contactName,
|
|
128
|
+
contactPhone: contactPhone,
|
|
129
|
+
address: addressText,
|
|
130
|
+
interviewType: '1', // 1 = onsite
|
|
131
|
+
});
|
|
132
|
+
const data = await page.evaluate(`
|
|
133
|
+
async () => {
|
|
134
|
+
return new Promise((resolve, reject) => {
|
|
135
|
+
const xhr = new XMLHttpRequest();
|
|
136
|
+
xhr.open('POST', 'https://www.zhipin.com/wapi/zpinterview/boss/interview/invite.json', true);
|
|
137
|
+
xhr.withCredentials = true;
|
|
138
|
+
xhr.timeout = 15000;
|
|
139
|
+
xhr.setRequestHeader('Accept', 'application/json');
|
|
140
|
+
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
141
|
+
xhr.onload = () => { try { resolve(JSON.parse(xhr.responseText)); } catch(e) { reject(new Error('JSON parse failed')); } };
|
|
142
|
+
xhr.onerror = () => reject(new Error('Network Error'));
|
|
143
|
+
xhr.send(${JSON.stringify(params.toString())});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
`);
|
|
147
|
+
if (data.code !== 0) {
|
|
148
|
+
if (data.code === 7 || data.code === 37) {
|
|
149
|
+
throw new Error('Cookie 已过期!请在当前 Chrome 浏览器中重新登录 BOSS 直聘。');
|
|
150
|
+
}
|
|
151
|
+
throw new Error(`面试邀请发送失败: ${data.message} (code=${data.code})`);
|
|
152
|
+
}
|
|
153
|
+
return [{
|
|
154
|
+
status: '✅ 面试邀请已发送',
|
|
155
|
+
detail: `已向 ${friendName} 发送面试邀请\n时间: ${timeStr}\n地点: ${addressText}\n联系人: ${contactName}`,
|
|
156
|
+
}];
|
|
157
|
+
},
|
|
158
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BOSS直聘 job list — list my published jobs via boss API.
|
|
3
|
+
*
|
|
4
|
+
* Uses /wapi/zpjob/job/chatted/jobList to get job list with status info.
|
|
5
|
+
*/
|
|
6
|
+
import { cli, Strategy } from '../../registry.js';
|
|
7
|
+
cli({
|
|
8
|
+
site: 'boss',
|
|
9
|
+
name: 'joblist',
|
|
10
|
+
description: 'BOSS直聘查看我发布的职位列表',
|
|
11
|
+
domain: 'www.zhipin.com',
|
|
12
|
+
strategy: Strategy.COOKIE,
|
|
13
|
+
browser: true,
|
|
14
|
+
args: [],
|
|
15
|
+
columns: ['job_name', 'salary', 'city', 'status', 'encrypt_job_id'],
|
|
16
|
+
func: async (page, kwargs) => {
|
|
17
|
+
if (!page)
|
|
18
|
+
throw new Error('Browser page required');
|
|
19
|
+
if (process.env.OPENCLI_VERBOSE) {
|
|
20
|
+
console.error('[opencli:boss] Fetching job list...');
|
|
21
|
+
}
|
|
22
|
+
await page.goto('https://www.zhipin.com/web/chat/index');
|
|
23
|
+
await page.wait({ time: 2 });
|
|
24
|
+
const targetUrl = 'https://www.zhipin.com/wapi/zpjob/job/chatted/jobList';
|
|
25
|
+
const data = await page.evaluate(`
|
|
26
|
+
async () => {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
const xhr = new XMLHttpRequest();
|
|
29
|
+
xhr.open('GET', '${targetUrl}', true);
|
|
30
|
+
xhr.withCredentials = true;
|
|
31
|
+
xhr.timeout = 15000;
|
|
32
|
+
xhr.setRequestHeader('Accept', 'application/json');
|
|
33
|
+
xhr.onload = () => { try { resolve(JSON.parse(xhr.responseText)); } catch(e) { reject(new Error('JSON parse failed')); } };
|
|
34
|
+
xhr.onerror = () => reject(new Error('Network Error'));
|
|
35
|
+
xhr.ontimeout = () => reject(new Error('Timeout'));
|
|
36
|
+
xhr.send();
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
`);
|
|
40
|
+
if (data.code !== 0) {
|
|
41
|
+
if (data.code === 7 || data.code === 37) {
|
|
42
|
+
throw new Error('Cookie 已过期!请在当前 Chrome 浏览器中重新登录 BOSS 直聘。');
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`API error: ${data.message} (code=${data.code})`);
|
|
45
|
+
}
|
|
46
|
+
const jobs = data.zpData || [];
|
|
47
|
+
return jobs.map((j) => ({
|
|
48
|
+
job_name: j.jobName || '',
|
|
49
|
+
salary: j.salaryDesc || '',
|
|
50
|
+
city: j.address || '',
|
|
51
|
+
status: j.jobOnlineStatus === 1 ? '在线' : '已关闭',
|
|
52
|
+
encrypt_job_id: j.encryptJobId || '',
|
|
53
|
+
}));
|
|
54
|
+
},
|
|
55
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|