@xkwdstore/agent 2.0.1 → 2.0.3
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/README.md +251 -244
- package/package.json +54 -54
- package/src/actions/comment.js +137 -137
- package/src/actions/dbc.js +149 -149
- package/src/actions/follow.js +82 -82
- package/src/actions/helpers.js +753 -753
- package/src/actions/index.js +94 -94
- package/src/actions/like.js +244 -244
- package/src/actions/session.js +1610 -1610
- package/src/actions/tweet.js +90 -90
- package/src/challengeCodec.js +31 -31
- package/src/chromeDetector.js +154 -154
- package/src/cli.js +664 -528
- package/src/configStore.js +97 -97
- package/src/deviceKeyStore.js +947 -700
- package/src/enrollmentClient.js +588 -445
- package/src/fingerprint.js +261 -261
- package/src/fingerprintStore.js +125 -125
- package/src/leaseClient.js +84 -84
- package/src/processLock.js +148 -148
- package/src/profilePath.js +1116 -1116
- package/src/proxyEgress.js +338 -338
- package/src/proxyPolicy.js +76 -76
- package/src/secretStore.js +132 -132
- package/src/sessionHandler.js +618 -452
- package/src/stealth.js +1250 -1250
- package/src/wsClient.js +233 -233
package/src/actions/follow.js
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Follow action — follow a user on X.
|
|
5
|
-
* Ported from backend/routes/browser.js doFollow().
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const { sleep, humanDelay, randDelay, naturalNavigate, humanPreAction, humanClick, detectStage } = require('./helpers');
|
|
9
|
-
|
|
10
|
-
// Follow button labels in multiple languages
|
|
11
|
-
const FOLLOW_LABELS = [
|
|
12
|
-
'follow', 'seguir', 'suivre', 'folgen', 'تابع', 'フォロー',
|
|
13
|
-
'segui', 'volgen', 'śledź', 'seguir', '关注', '팔로우',
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
const FOLLOWING_LABELS = [
|
|
17
|
-
'following', 'siguiendo', 'abonné', 'folgt', 'يتابعك', 'フォロー中',
|
|
18
|
-
'following', 'volgend', 'obserwujesz', 'seguindo', '已关注', '팔로잉',
|
|
19
|
-
'unfollow', 'dejar de seguir', 'ne plus suivre', 'entfolgen', 'إلغاء المتابعة',
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
async function follow(page, payload) {
|
|
23
|
-
const { username } = payload;
|
|
24
|
-
if (!username) throw new Error('username required');
|
|
25
|
-
|
|
26
|
-
const cleanUsername = String(username).replace(/^@/, '').replace(/^.*x\.com\//, '');
|
|
27
|
-
await naturalNavigate(page, `https://x.com/${cleanUsername}`);
|
|
28
|
-
await humanPreAction(page);
|
|
29
|
-
|
|
30
|
-
// Check if page loaded properly
|
|
31
|
-
if (page.url().includes('/login') || page.url().includes('/i/flow')) {
|
|
32
|
-
throw new Error('Not logged in — open browser and login first');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Check for suspended/not-found
|
|
36
|
-
const title = await page.title().catch(() => '');
|
|
37
|
-
const bodyText = await page.evaluate(() => document.body.innerText).catch(() => '');
|
|
38
|
-
if (/account suspended|doesn't exist|page doesn't exist/i.test(title + bodyText)) {
|
|
39
|
-
throw new Error(`Account @${cleanUsername} is suspended or not found`);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Strategy 1: data-testid selectors
|
|
43
|
-
const testIdSelectors = [
|
|
44
|
-
`[data-testid="${cleanUsername}-follow"]`,
|
|
45
|
-
'[data-testid="follow"]',
|
|
46
|
-
];
|
|
47
|
-
for (const sel of testIdSelectors) {
|
|
48
|
-
const btn = page.locator(sel).first();
|
|
49
|
-
if (await btn.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
50
|
-
await humanClick(page, btn);
|
|
51
|
-
await sleep(3000);
|
|
52
|
-
return { success: true, message: `Following @${cleanUsername}` };
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Strategy 2: scan buttons for follow labels
|
|
57
|
-
const buttons = page.locator('[role="button"], button');
|
|
58
|
-
const count = await buttons.count();
|
|
59
|
-
for (let i = 0; i < count; i++) {
|
|
60
|
-
const btn = buttons.nth(i);
|
|
61
|
-
const text = (await btn.innerText().catch(() => '')).toLowerCase().trim();
|
|
62
|
-
if (FOLLOW_LABELS.some(label => text === label || text.includes(label))) {
|
|
63
|
-
// Check if it's actually "following" (already following)
|
|
64
|
-
if (FOLLOWING_LABELS.some(label => text.includes(label))) continue;
|
|
65
|
-
await humanClick(page, btn);
|
|
66
|
-
await sleep(3000);
|
|
67
|
-
return { success: true, message: `Following @${cleanUsername}` };
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Check if already following
|
|
72
|
-
for (let i = 0; i < count; i++) {
|
|
73
|
-
const btn = buttons.nth(i);
|
|
74
|
-
const text = (await btn.innerText().catch(() => '')).toLowerCase().trim();
|
|
75
|
-
if (FOLLOWING_LABELS.some(label => text.includes(label))) {
|
|
76
|
-
return { success: true, message: `Already following @${cleanUsername}`, status: 'already_following' };
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
throw new Error(`Could not find follow button for @${cleanUsername}`);
|
|
81
|
-
}
|
|
82
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Follow action — follow a user on X.
|
|
5
|
+
* Ported from backend/routes/browser.js doFollow().
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const { sleep, humanDelay, randDelay, naturalNavigate, humanPreAction, humanClick, detectStage } = require('./helpers');
|
|
9
|
+
|
|
10
|
+
// Follow button labels in multiple languages
|
|
11
|
+
const FOLLOW_LABELS = [
|
|
12
|
+
'follow', 'seguir', 'suivre', 'folgen', 'تابع', 'フォロー',
|
|
13
|
+
'segui', 'volgen', 'śledź', 'seguir', '关注', '팔로우',
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const FOLLOWING_LABELS = [
|
|
17
|
+
'following', 'siguiendo', 'abonné', 'folgt', 'يتابعك', 'フォロー中',
|
|
18
|
+
'following', 'volgend', 'obserwujesz', 'seguindo', '已关注', '팔로잉',
|
|
19
|
+
'unfollow', 'dejar de seguir', 'ne plus suivre', 'entfolgen', 'إلغاء المتابعة',
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
async function follow(page, payload) {
|
|
23
|
+
const { username } = payload;
|
|
24
|
+
if (!username) throw new Error('username required');
|
|
25
|
+
|
|
26
|
+
const cleanUsername = String(username).replace(/^@/, '').replace(/^.*x\.com\//, '');
|
|
27
|
+
await naturalNavigate(page, `https://x.com/${cleanUsername}`);
|
|
28
|
+
await humanPreAction(page);
|
|
29
|
+
|
|
30
|
+
// Check if page loaded properly
|
|
31
|
+
if (page.url().includes('/login') || page.url().includes('/i/flow')) {
|
|
32
|
+
throw new Error('Not logged in — open browser and login first');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Check for suspended/not-found
|
|
36
|
+
const title = await page.title().catch(() => '');
|
|
37
|
+
const bodyText = await page.evaluate(() => document.body.innerText).catch(() => '');
|
|
38
|
+
if (/account suspended|doesn't exist|page doesn't exist/i.test(title + bodyText)) {
|
|
39
|
+
throw new Error(`Account @${cleanUsername} is suspended or not found`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Strategy 1: data-testid selectors
|
|
43
|
+
const testIdSelectors = [
|
|
44
|
+
`[data-testid="${cleanUsername}-follow"]`,
|
|
45
|
+
'[data-testid="follow"]',
|
|
46
|
+
];
|
|
47
|
+
for (const sel of testIdSelectors) {
|
|
48
|
+
const btn = page.locator(sel).first();
|
|
49
|
+
if (await btn.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
50
|
+
await humanClick(page, btn);
|
|
51
|
+
await sleep(3000);
|
|
52
|
+
return { success: true, message: `Following @${cleanUsername}` };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Strategy 2: scan buttons for follow labels
|
|
57
|
+
const buttons = page.locator('[role="button"], button');
|
|
58
|
+
const count = await buttons.count();
|
|
59
|
+
for (let i = 0; i < count; i++) {
|
|
60
|
+
const btn = buttons.nth(i);
|
|
61
|
+
const text = (await btn.innerText().catch(() => '')).toLowerCase().trim();
|
|
62
|
+
if (FOLLOW_LABELS.some(label => text === label || text.includes(label))) {
|
|
63
|
+
// Check if it's actually "following" (already following)
|
|
64
|
+
if (FOLLOWING_LABELS.some(label => text.includes(label))) continue;
|
|
65
|
+
await humanClick(page, btn);
|
|
66
|
+
await sleep(3000);
|
|
67
|
+
return { success: true, message: `Following @${cleanUsername}` };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Check if already following
|
|
72
|
+
for (let i = 0; i < count; i++) {
|
|
73
|
+
const btn = buttons.nth(i);
|
|
74
|
+
const text = (await btn.innerText().catch(() => '')).toLowerCase().trim();
|
|
75
|
+
if (FOLLOWING_LABELS.some(label => text.includes(label))) {
|
|
76
|
+
return { success: true, message: `Already following @${cleanUsername}`, status: 'already_following' };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
throw new Error(`Could not find follow button for @${cleanUsername}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
83
|
module.exports = { follow };
|