Fix: Remove inline styles from Open Graph and Twitter image meta tags and simplify JSON-LD navigation data.
This commit is contained in:
@@ -116,24 +116,45 @@ async function run() {
|
||||
});
|
||||
|
||||
try {
|
||||
console.log('🌐 Loading page...');
|
||||
await page.goto(targetUrl, { waitUntil: 'domcontentloaded', timeout: 60000 });
|
||||
console.log('🌐 Loading page (Waiting for Network Idle)...');
|
||||
await page.goto(targetUrl, { waitUntil: 'networkidle', timeout: 90000 });
|
||||
|
||||
console.log('<EFBFBD> Expanding Viewport to "Giant Mode" to force-trigger lazy loaders...');
|
||||
// Measure content height and resize viewport to display EVERYTHING at once
|
||||
console.log('🌊 Executing "Scroll Wave" to trigger all lazy loaders naturally...');
|
||||
await page.evaluate(async () => {
|
||||
await new Promise((resolve) => {
|
||||
let totalHeight = 0;
|
||||
const distance = 400;
|
||||
const timer = setInterval(() => {
|
||||
const scrollHeight = document.body.scrollHeight;
|
||||
window.scrollBy(0, distance);
|
||||
totalHeight += distance;
|
||||
|
||||
if (totalHeight >= scrollHeight) {
|
||||
clearInterval(timer);
|
||||
window.scrollTo(0, 0); // Reset to top
|
||||
resolve(true);
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
|
||||
console.log('📐 Expanding Viewport to "Giant Mode" for final asset capture...');
|
||||
const fullHeight = await page.evaluate(() => document.body.scrollHeight);
|
||||
await page.setViewportSize({ width: 1920, height: fullHeight + 2000 });
|
||||
await page.setViewportSize({ width: 1920, height: fullHeight + 1000 });
|
||||
|
||||
// Wait a moment for IntersectionObservers to fire
|
||||
await page.waitForTimeout(2000);
|
||||
// Final settlement wait
|
||||
await page.waitForTimeout(3000);
|
||||
|
||||
console.log('💧 Hydrating attributes and cleaning DOM...');
|
||||
console.log('💧 Final DOM Hydration & Sanitization...');
|
||||
await page.evaluate(() => {
|
||||
// A. Deterministic Attribute Hydration
|
||||
// A. Deterministic Attribute Hydration (Generic)
|
||||
// Scours every element for attributes that look like asset URLs and promotes them
|
||||
const assetPattern = /\.(jpg|jpeg|png|gif|svg|webp|mp4|webm|woff2?|ttf|otf)/i;
|
||||
|
||||
document.querySelectorAll('*').forEach(el => {
|
||||
// 0. Skip Meta/Head/Script/Style/SVG tags for attribute promotion
|
||||
if (['META', 'LINK', 'HEAD', 'SCRIPT', 'STYLE', 'SVG', 'PATH'].includes(el.tagName)) return;
|
||||
|
||||
// 1. Force Visibility (Anti-Flicker)
|
||||
const style = window.getComputedStyle(el);
|
||||
if (style.opacity === '0' || style.visibility === 'hidden') {
|
||||
@@ -160,7 +181,6 @@ async function run() {
|
||||
}
|
||||
|
||||
// Background Image Promotion
|
||||
// Common patterns: data-bg, data-image-src, style="...url(...)..."
|
||||
if (val.match(/^(https?:\/\/|\/\/|\/)/) && !name.includes('href')) {
|
||||
const bg = el.style.backgroundImage;
|
||||
if (!bg || bg === 'none') {
|
||||
@@ -170,11 +190,21 @@ async function run() {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// B. Ensure basic structural elements are visible post-scroll
|
||||
const body = document.body;
|
||||
if (body) {
|
||||
body.style.setProperty('opacity', '1', 'important');
|
||||
body.style.setProperty('visibility', 'visible', 'important');
|
||||
}
|
||||
});
|
||||
|
||||
console.log('⏳ Waiting for network idle...');
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// 1.5 FINAL SETTLEMENT: Let any scroll-triggered JS finish
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// 2. Static Snapshot
|
||||
let content = await page.content();
|
||||
|
||||
@@ -284,7 +314,7 @@ async function run() {
|
||||
if (headEnd > -1) {
|
||||
const stabilityCss = `
|
||||
<style>
|
||||
/* INDUSTRIAL CLONE STABILIZATION */
|
||||
/* UNIVERSAL CLONE STABILIZATION */
|
||||
* {
|
||||
transition: none !important;
|
||||
animation: none !important;
|
||||
@@ -296,6 +326,7 @@ async function run() {
|
||||
transform: none !important;
|
||||
clip-path: none !important;
|
||||
}
|
||||
|
||||
img, video, iframe {
|
||||
max-width: 100%;
|
||||
display: block;
|
||||
|
||||
Reference in New Issue
Block a user