@yashwant.dharmdas/elementor-mcp 3.2.1 → 3.2.2
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/dist/index.js +41 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1000,8 +1000,10 @@ function createMcpServer(sites) {
|
|
|
1000
1000
|
format: z.enum(["jpeg", "png"]).optional().describe("Image format — jpeg is much smaller and recommended (default: jpeg)"),
|
|
1001
1001
|
quality: z.number().min(1).max(100).optional().describe("JPEG quality 1–100 (default: 82). Lower = smaller file size."),
|
|
1002
1002
|
max_height: z.number().optional().describe("Cap the captured height in pixels (e.g. 4000). Useful for very long pages to stay under size limits."),
|
|
1003
|
+
wait: z.number().optional().describe("Extra milliseconds to wait after page load + auto-scroll before capturing (default: 2000). Increase for heavy animations/videos."),
|
|
1004
|
+
auto_scroll: z.boolean().optional().describe("Scroll through the page to trigger lazy-loaded images and content (default: true). Disable only for pages with infinite scroll."),
|
|
1003
1005
|
site: siteParam,
|
|
1004
|
-
}, async ({ page_id, full_page, width, format, quality, max_height, site }) => {
|
|
1006
|
+
}, async ({ page_id, full_page, width, format, quality, max_height, wait, auto_scroll, site }) => {
|
|
1005
1007
|
try {
|
|
1006
1008
|
const { wpUrl, authHeader } = resolveSite(sites, site);
|
|
1007
1009
|
// ── 1. Resolve the page's public URL ─────────────────────────────
|
|
@@ -1054,8 +1056,44 @@ function createMcpServer(sites) {
|
|
|
1054
1056
|
const vpWidth = width ?? 1440;
|
|
1055
1057
|
const vpHeight = max_height ?? 900;
|
|
1056
1058
|
await page.setViewport({ width: vpWidth, height: vpHeight, deviceScaleFactor: 1 });
|
|
1057
|
-
|
|
1058
|
-
await
|
|
1059
|
+
// Navigate and wait for network to go idle
|
|
1060
|
+
await page.goto(pageUrl, { waitUntil: "networkidle2", timeout: 45_000 });
|
|
1061
|
+
// ── Auto-scroll: trigger lazy-loaded images/content ─────────────
|
|
1062
|
+
if (auto_scroll !== false) {
|
|
1063
|
+
await page.evaluate(async () => {
|
|
1064
|
+
await new Promise((resolve) => {
|
|
1065
|
+
let totalHeight = 0;
|
|
1066
|
+
const distance = 200;
|
|
1067
|
+
const timer = setInterval(() => {
|
|
1068
|
+
const scrollHeight = document.body.scrollHeight;
|
|
1069
|
+
window.scrollBy(0, distance);
|
|
1070
|
+
totalHeight += distance;
|
|
1071
|
+
if (totalHeight >= scrollHeight) {
|
|
1072
|
+
clearInterval(timer);
|
|
1073
|
+
resolve();
|
|
1074
|
+
}
|
|
1075
|
+
}, 80);
|
|
1076
|
+
});
|
|
1077
|
+
});
|
|
1078
|
+
// Scroll back to top for the capture
|
|
1079
|
+
await page.evaluate(() => window.scrollTo(0, 0));
|
|
1080
|
+
}
|
|
1081
|
+
// ── Wait for all <img> tags to finish loading ──────────────────
|
|
1082
|
+
await page.evaluate(async () => {
|
|
1083
|
+
const images = Array.from(document.querySelectorAll("img"));
|
|
1084
|
+
await Promise.all(images.map((img) => {
|
|
1085
|
+
if (img.complete && img.naturalWidth > 0)
|
|
1086
|
+
return Promise.resolve();
|
|
1087
|
+
return new Promise((resolve) => {
|
|
1088
|
+
img.addEventListener("load", () => resolve(), { once: true });
|
|
1089
|
+
img.addEventListener("error", () => resolve(), { once: true });
|
|
1090
|
+
// Safety timeout per image
|
|
1091
|
+
setTimeout(() => resolve(), 5000);
|
|
1092
|
+
});
|
|
1093
|
+
}));
|
|
1094
|
+
});
|
|
1095
|
+
// Extra settle time for fonts, animations, videos
|
|
1096
|
+
await new Promise(resolve => setTimeout(resolve, wait ?? 2000));
|
|
1059
1097
|
const fmt = format ?? "jpeg";
|
|
1060
1098
|
const screenshotOptions = { type: fmt, fullPage: !max_height && (full_page ?? true) };
|
|
1061
1099
|
if (fmt === "jpeg")
|
package/package.json
CHANGED