@yashwant.dharmdas/elementor-mcp 3.2.6 → 3.2.7
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 +43 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1128,18 +1128,57 @@ function createMcpServer(sites) {
|
|
|
1128
1128
|
window.scrollTo(0, 0);
|
|
1129
1129
|
});
|
|
1130
1130
|
}
|
|
1131
|
-
// ── Force-load all <img> tags
|
|
1131
|
+
// ── Force-load all <img> tags + Elementor lazy backgrounds ────────
|
|
1132
1132
|
await page.evaluate(async () => {
|
|
1133
|
-
// Strip loading="lazy" so the browser loads everything eagerly
|
|
1133
|
+
// 1. Strip loading="lazy" so the browser loads everything eagerly
|
|
1134
1134
|
document.querySelectorAll('img[loading="lazy"]').forEach((img) => {
|
|
1135
1135
|
img.setAttribute("loading", "eager");
|
|
1136
1136
|
});
|
|
1137
|
-
// Resolve data-src → src for libraries that defer loading
|
|
1137
|
+
// 2. Resolve data-src → src for libraries that defer image loading
|
|
1138
1138
|
document.querySelectorAll("img[data-src]").forEach((img) => {
|
|
1139
1139
|
const ds = img.getAttribute("data-src");
|
|
1140
1140
|
if (ds && !img.getAttribute("src"))
|
|
1141
1141
|
img.setAttribute("src", ds);
|
|
1142
1142
|
});
|
|
1143
|
+
// 3. Force-load Elementor's lazy background images
|
|
1144
|
+
// Elementor uses class .elementor-element-bg-lazyload + sets a
|
|
1145
|
+
// CSS variable --e-bg-lazyload, OR data-bg / data-background-image
|
|
1146
|
+
const bgEls = document.querySelectorAll(".elementor-element-bg-lazyload, [data-bg], [data-background-image]");
|
|
1147
|
+
bgEls.forEach((el) => {
|
|
1148
|
+
const url = el.getAttribute("data-bg") ||
|
|
1149
|
+
el.getAttribute("data-background-image") ||
|
|
1150
|
+
getComputedStyle(el).getPropertyValue("--e-bg-lazyload").trim().replace(/^url\(["']?|["']?\)$/g, "");
|
|
1151
|
+
if (url && url !== "none" && !el.style.backgroundImage) {
|
|
1152
|
+
el.style.backgroundImage = `url("${url}")`;
|
|
1153
|
+
}
|
|
1154
|
+
el.classList.remove("elementor-element-bg-lazyload");
|
|
1155
|
+
});
|
|
1156
|
+
// 4. Force-show Elementor reveal-animation elements that are still
|
|
1157
|
+
// hidden (opacity:0 / .elementor-invisible) waiting for scroll trigger
|
|
1158
|
+
document.querySelectorAll(".elementor-invisible").forEach((el) => {
|
|
1159
|
+
el.classList.remove("elementor-invisible");
|
|
1160
|
+
el.style.opacity = "1";
|
|
1161
|
+
el.style.visibility = "visible";
|
|
1162
|
+
el.style.transform = "none";
|
|
1163
|
+
});
|
|
1164
|
+
// 5. Disable CSS animations / transitions during capture so nothing
|
|
1165
|
+
// is mid-flight when the screenshot fires
|
|
1166
|
+
const style = document.createElement("style");
|
|
1167
|
+
style.id = "__mcp_screenshot_overrides__";
|
|
1168
|
+
style.textContent = `
|
|
1169
|
+
*, *::before, *::after {
|
|
1170
|
+
animation-duration: 0s !important;
|
|
1171
|
+
animation-delay: 0s !important;
|
|
1172
|
+
transition-duration: 0s !important;
|
|
1173
|
+
transition-delay: 0s !important;
|
|
1174
|
+
}
|
|
1175
|
+
.elementor-invisible { opacity: 1 !important; visibility: visible !important; }
|
|
1176
|
+
`;
|
|
1177
|
+
document.head.appendChild(style);
|
|
1178
|
+
// 6. Wake up any IntersectionObserver-based loaders one more time
|
|
1179
|
+
window.dispatchEvent(new Event("scroll"));
|
|
1180
|
+
window.dispatchEvent(new Event("resize"));
|
|
1181
|
+
// 7. Wait for ALL <img> tags (now eager) to finish loading
|
|
1143
1182
|
const images = Array.from(document.querySelectorAll("img"));
|
|
1144
1183
|
await Promise.all(images.map((img) => {
|
|
1145
1184
|
if (img.complete && img.naturalWidth > 0)
|
|
@@ -1151,7 +1190,7 @@ function createMcpServer(sites) {
|
|
|
1151
1190
|
});
|
|
1152
1191
|
}));
|
|
1153
1192
|
});
|
|
1154
|
-
// Extra settle time for fonts,
|
|
1193
|
+
// Extra settle time for fonts, video posters, and bg image decoding
|
|
1155
1194
|
await new Promise(resolve => setTimeout(resolve, wait ?? 2500));
|
|
1156
1195
|
const fmt = format ?? "jpeg";
|
|
1157
1196
|
const baseOptions = { type: fmt, fullPage: !max_height && (full_page ?? true) };
|
package/package.json
CHANGED