social-agent-cli 4.2.0 → 4.2.1
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/core/upload-helper.ts +15 -38
- package/maps/linkedin.json +2 -1
- package/maps/x.json +2 -1
- package/package.json +1 -1
package/core/upload-helper.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Upload helper -
|
|
3
|
-
* LinkedIn gibi native file dialog kullanan platformlar için
|
|
4
|
-
*
|
|
2
|
+
* Upload helper - Playwright fileChooser ile dosya yükler
|
|
5
3
|
* Kullanım: npx tsx core/upload-helper.ts <cdp-port> <click-selector> <file-path>
|
|
6
4
|
*/
|
|
7
5
|
import { chromium } from "playwright";
|
|
@@ -9,49 +7,28 @@ import { chromium } from "playwright";
|
|
|
9
7
|
const [, , port, selector, filePath] = process.argv;
|
|
10
8
|
|
|
11
9
|
if (!port || !selector || !filePath) {
|
|
12
|
-
console.error("Kullanım: npx tsx core/upload-helper.ts <port> <selector> <file-path>");
|
|
13
10
|
process.exit(1);
|
|
14
11
|
}
|
|
15
12
|
|
|
16
13
|
async function upload() {
|
|
17
14
|
const browser = await chromium.connectOverCDP(`http://127.0.0.1:${port}`);
|
|
18
15
|
const pages = browser.contexts()[0].pages();
|
|
19
|
-
|
|
16
|
+
// LinkedIn sayfasını bul
|
|
17
|
+
const page = pages.find(p => p.url().includes("linkedin.com")) || pages[0];
|
|
20
18
|
|
|
21
|
-
// fileChooser
|
|
22
|
-
let resolved = false;
|
|
19
|
+
// fileChooser promise'ı ÖNCE başlat
|
|
23
20
|
const fcPromise = page.waitForEvent("filechooser", { timeout: 10000 });
|
|
24
21
|
|
|
25
|
-
// Butona tıkla
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const el = page.locator(sel).first();
|
|
36
|
-
if (await el.isVisible({ timeout: 2000 })) {
|
|
37
|
-
await el.click();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
} catch {}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
const fc = await fcPromise;
|
|
45
|
-
await fc.setFiles(filePath);
|
|
46
|
-
resolved = true;
|
|
47
|
-
console.log("OK");
|
|
48
|
-
} catch (e: any) {
|
|
49
|
-
console.error("FAIL:", e.message.substring(0, 100));
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
22
|
+
// Butona tıkla
|
|
23
|
+
try { await page.click(selector, { timeout: 5000 }); } catch {}
|
|
24
|
+
|
|
25
|
+
// fileChooser'ı yakala ve dosya set et
|
|
26
|
+
const fc = await fcPromise;
|
|
27
|
+
await fc.setFiles(filePath);
|
|
28
|
+
console.log("OK");
|
|
29
|
+
|
|
30
|
+
// Hemen çık - beklemeden
|
|
31
|
+
process.exit(0);
|
|
52
32
|
}
|
|
53
33
|
|
|
54
|
-
upload().catch((
|
|
55
|
-
console.error(e.message);
|
|
56
|
-
process.exit(1);
|
|
57
|
-
});
|
|
34
|
+
upload().catch(() => process.exit(1));
|
package/maps/linkedin.json
CHANGED
package/maps/x.json
CHANGED