social-agent-cli 5.0.5 → 5.0.6
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/screenshot.ts +10 -6
- package/package.json +1 -1
package/core/screenshot.ts
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import { execSync } from "node:child_process";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* Kullanım:
|
|
4
|
+
* Screenshot al - URL veya HTML dosyasından
|
|
5
|
+
* Kullanım: social-agent screenshot <url-or-html> <output-path> [width] [height]
|
|
6
6
|
*/
|
|
7
|
-
const [, , htmlPath, outputPath
|
|
7
|
+
const [, , htmlPath, outputPath] = process.argv;
|
|
8
8
|
|
|
9
9
|
if (!htmlPath || !outputPath) {
|
|
10
|
-
console.error("Kullanım: social-agent screenshot <
|
|
10
|
+
console.error("Kullanım: social-agent screenshot <url-or-html> <output-path>");
|
|
11
11
|
process.exit(1);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const url = htmlPath.startsWith("http") ? htmlPath : `file://${htmlPath}`;
|
|
15
|
+
const format = outputPath.endsWith(".png") ? "png" : "jpeg";
|
|
15
16
|
|
|
16
17
|
try {
|
|
17
18
|
execSync(`agent-browser open "${url}"`, { stdio: "pipe", timeout: 15000 });
|
|
18
19
|
execSync(`agent-browser wait 2000`, { stdio: "pipe" });
|
|
19
|
-
|
|
20
|
+
// Scrollbar'ı gizle
|
|
21
|
+
execSync(`agent-browser eval "document.documentElement.style.overflow='hidden'; document.body.style.overflow='hidden'; document.documentElement.style.scrollbarWidth='none';"`, { stdio: "pipe", timeout: 5000 });
|
|
22
|
+
execSync(`agent-browser wait 500`, { stdio: "pipe" });
|
|
23
|
+
execSync(`agent-browser screenshot --screenshot-format ${format} --screenshot-quality 100 "${outputPath}"`, { stdio: "pipe", timeout: 10000 });
|
|
20
24
|
console.log(outputPath);
|
|
21
25
|
} catch (err: any) {
|
|
22
|
-
console.error(err.message);
|
|
26
|
+
console.error(err.stderr?.toString() || err.message);
|
|
23
27
|
process.exit(1);
|
|
24
28
|
}
|