@yashwant.dharmdas/elementor-mcp 3.2.5 → 3.2.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/dist/index.js +42 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1090,28 +1090,56 @@ function createMcpServer(sites) {
|
|
|
1090
1090
|
await page.setViewport({ width: vpWidth, height: vpHeight, deviceScaleFactor: 1 });
|
|
1091
1091
|
// Navigate and wait for network to go idle
|
|
1092
1092
|
await page.goto(pageUrl, { waitUntil: "networkidle2", timeout: 45_000 });
|
|
1093
|
-
// ── Auto-scroll
|
|
1093
|
+
// ── Auto-scroll with multi-pass stabilization ────────────────────
|
|
1094
|
+
// Many Elementor pages lazy-load content on scroll (images, Swiper
|
|
1095
|
+
// carousels, reveal animations). A single scroll pass is not enough —
|
|
1096
|
+
// the page can grow as content loads. We keep scrolling until the
|
|
1097
|
+
// total page height stops increasing between passes.
|
|
1094
1098
|
if (auto_scroll !== false) {
|
|
1095
1099
|
await page.evaluate(async () => {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1100
|
+
const getHeight = () => Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight);
|
|
1101
|
+
const scrollOnce = () => new Promise((resolve) => {
|
|
1102
|
+
let y = 0;
|
|
1103
|
+
const step = 300;
|
|
1099
1104
|
const timer = setInterval(() => {
|
|
1100
|
-
const
|
|
1101
|
-
window.scrollBy(0,
|
|
1102
|
-
|
|
1103
|
-
if (
|
|
1105
|
+
const h = getHeight();
|
|
1106
|
+
window.scrollBy(0, step);
|
|
1107
|
+
y += step;
|
|
1108
|
+
if (y >= h) {
|
|
1104
1109
|
clearInterval(timer);
|
|
1105
1110
|
resolve();
|
|
1106
1111
|
}
|
|
1107
|
-
},
|
|
1112
|
+
}, 60);
|
|
1108
1113
|
});
|
|
1114
|
+
// Repeat until height stabilizes (max 4 passes)
|
|
1115
|
+
let lastHeight = 0;
|
|
1116
|
+
for (let i = 0; i < 4; i++) {
|
|
1117
|
+
window.scrollTo(0, 0);
|
|
1118
|
+
await new Promise(r => setTimeout(r, 150));
|
|
1119
|
+
await scrollOnce();
|
|
1120
|
+
// Wait at the bottom for lazy content to trigger
|
|
1121
|
+
await new Promise(r => setTimeout(r, 800));
|
|
1122
|
+
const h = getHeight();
|
|
1123
|
+
if (h === lastHeight)
|
|
1124
|
+
break;
|
|
1125
|
+
lastHeight = h;
|
|
1126
|
+
}
|
|
1127
|
+
// Back to top for the capture
|
|
1128
|
+
window.scrollTo(0, 0);
|
|
1109
1129
|
});
|
|
1110
|
-
// Scroll back to top for the capture
|
|
1111
|
-
await page.evaluate(() => window.scrollTo(0, 0));
|
|
1112
1130
|
}
|
|
1113
|
-
// ──
|
|
1131
|
+
// ── Force-load all <img> tags (including data-src / loading=lazy) ─
|
|
1114
1132
|
await page.evaluate(async () => {
|
|
1133
|
+
// Strip loading="lazy" so the browser loads everything eagerly
|
|
1134
|
+
document.querySelectorAll('img[loading="lazy"]').forEach((img) => {
|
|
1135
|
+
img.setAttribute("loading", "eager");
|
|
1136
|
+
});
|
|
1137
|
+
// Resolve data-src → src for libraries that defer loading
|
|
1138
|
+
document.querySelectorAll("img[data-src]").forEach((img) => {
|
|
1139
|
+
const ds = img.getAttribute("data-src");
|
|
1140
|
+
if (ds && !img.getAttribute("src"))
|
|
1141
|
+
img.setAttribute("src", ds);
|
|
1142
|
+
});
|
|
1115
1143
|
const images = Array.from(document.querySelectorAll("img"));
|
|
1116
1144
|
await Promise.all(images.map((img) => {
|
|
1117
1145
|
if (img.complete && img.naturalWidth > 0)
|
|
@@ -1119,13 +1147,12 @@ function createMcpServer(sites) {
|
|
|
1119
1147
|
return new Promise((resolve) => {
|
|
1120
1148
|
img.addEventListener("load", () => resolve(), { once: true });
|
|
1121
1149
|
img.addEventListener("error", () => resolve(), { once: true });
|
|
1122
|
-
// Safety timeout per image
|
|
1123
1150
|
setTimeout(() => resolve(), 5000);
|
|
1124
1151
|
});
|
|
1125
1152
|
}));
|
|
1126
1153
|
});
|
|
1127
|
-
// Extra settle time for fonts, animations,
|
|
1128
|
-
await new Promise(resolve => setTimeout(resolve, wait ??
|
|
1154
|
+
// Extra settle time for fonts, CSS animations, video posters
|
|
1155
|
+
await new Promise(resolve => setTimeout(resolve, wait ?? 2500));
|
|
1129
1156
|
const fmt = format ?? "jpeg";
|
|
1130
1157
|
const baseOptions = { type: fmt, fullPage: !max_height && (full_page ?? true) };
|
|
1131
1158
|
if (max_height)
|
package/package.json
CHANGED