@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.
Files changed (2) hide show
  1. package/dist/index.js +42 -15
  2. 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: trigger lazy-loaded images/content ─────────────
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
- await new Promise((resolve) => {
1097
- let totalHeight = 0;
1098
- const distance = 200;
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 scrollHeight = document.body.scrollHeight;
1101
- window.scrollBy(0, distance);
1102
- totalHeight += distance;
1103
- if (totalHeight >= scrollHeight) {
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
- }, 80);
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
- // ── Wait for all <img> tags to finish loading ──────────────────
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, videos
1128
- await new Promise(resolve => setTimeout(resolve, wait ?? 2000));
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yashwant.dharmdas/elementor-mcp",
3
- "version": "3.2.5",
3
+ "version": "3.2.6",
4
4
  "description": "MCP server for controlling Elementor via Claude — supports multiple WordPress sites",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",