mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2026-09-25 14:55:59 +00:00
Multi-language / Translations Support (#3696) - Complete internationalization system implemented - Support for 7 languages: Czech (cs), German (de), French (fr), Italian (it), Korean (ko), Chinese Simplified (zh), Chinese Traditional (zh_TW) - Language selector with localized flags and theming - Flash message translations - Multiple translation fixes and improvements across all languages - Language setting preserved across redirects Pluggable Content Fetchers (#3653) - New architecture for extensible content fetcher system - Allows custom fetcher implementations Image / Screenshot Comparison Processor (#3680) - New processor for visual change detection (disabled for this release) - Supporting CSS/JS infrastructure added UI Improvements Design & Layout - Auto-generated tag color schemes - Simplified login form styling - Removed hard-coded CSS, moved to SCSS variables - Tag UI cleanup and improvements - Automatic tab wrapper functionality - Menu refactoring for better organization - Cleanup of offset settings - Hide sticky tabs on narrow viewports - Improved responsive layout (#3702) User Experience - Modal alerts/confirmations on delete/clear operations (#3693, #3598, #3382) - Auto-add https:// to URLs in quickwatch form if not present - Better redirect handling on login (#3699) - 'Recheck all' now returns to correct group/tag (#3673) - Language set redirect keeps hash fragment - More friendly human-readable text throughout UI Performance & Reliability Scheduler & Processing - Soft delays instead of blocking time.sleep() calls (#3710) - More resilient handling of same UUID being processed (#3700) - Better Puppeteer timeout handling - Improved Puppeteer shutdown/cleanup (#3692) - Requests cleanup now properly async History & Rendering - Faster server-side "difference" rendering on History page (#3442) - Show ignored/triggered rows in history - API: Retry watch data if watch dict changed (more reliable) API Improvements - Watch get endpoint: retry mechanism for changed watch data - WatchHistoryDiff API endpoint includes extra format args (#3703) Testing Improvements - Replace time.sleep with wait_for_notification_endpoint_output (#3716) - Test for mode switching (#3701) - Test for #3720 added (#3725) - Extract-text difference test fixes - Improved dev workflow Bug Fixes - Notification error text output (#3672, #3669, #3280) - HTML validation fixes (#3704) - Template discovery path fixes - Notification debug log now uses system locale for dates/times - Puppeteer spelling mistake in log output - Recalculation on anchor change - Queue bubble update disabled temporarily Dependency Updates - beautifulsoup4 updated (#3724) - psutil 7.1.0 → 7.2.1 (#3723) - python-engineio ~=4.12.3 → ~=4.13.0 (#3707) - python-socketio ~=5.14.3 → ~=5.16.0 (#3706) - flask-socketio ~=5.5.1 → ~=5.6.0 (#3691) - brotli ~=1.1 → ~=1.2 (#3687) - lxml updated (#3590) - pytest ~=7.2 → ~=9.0 (#3676) - jsonschema ~=4.0 → ~=4.25 (#3618) - pluggy ~=1.5 → ~=1.6 (#3616) - cryptography 44.0.1 → 46.0.3 (security) (#3589) Documentation - README updated with viewport size setup information Development Infrastructure - Dev container only built on dev branch - Improved dev workflow tooling
94 lines
3.9 KiB
JavaScript
94 lines
3.9 KiB
JavaScript
/**
|
|
* Lock Element Dimensions for Screenshot Capture
|
|
*
|
|
* THE PROBLEM:
|
|
* When taking full-page screenshots of tall pages, Chrome/Puppeteer/Playwright need to:
|
|
* 1. Temporarily change the viewport height to a large value (e.g., 800px → 3809px)
|
|
* 2. Take screenshots in chunks while scrolling
|
|
* 3. Stitch the chunks together
|
|
*
|
|
* However, changing the viewport height triggers CSS media queries like:
|
|
* @media (min-height: 860px) { .ad { height: 250px; } }
|
|
*
|
|
* This causes elements (especially ads) to resize during screenshot capture, creating a mismatch:
|
|
* - Screenshot shows element at NEW size (after media query triggered)
|
|
* - xpath element coordinates measured at OLD size (before viewport change)
|
|
* - Visual selector overlays don't align with screenshot
|
|
*
|
|
* EXAMPLE BUG:
|
|
* - Initial viewport: 1280x800, ad height: 138px, article position: 279px ✓
|
|
* - Viewport changes to 1280x3809 for screenshot
|
|
* - Media query triggers: ad expands to 250px
|
|
* - All content below shifts down by 112px (250-138)
|
|
* - Article now at position: 391px (279+112)
|
|
* - But xpath data says 279px → 112px mismatch! ✗
|
|
*
|
|
* THE SOLUTION:
|
|
* Before changing viewport, lock ALL element dimensions with !important inline styles.
|
|
* Inline styles with !important override media query CSS, preventing layout changes.
|
|
*
|
|
* WHAT THIS SCRIPT DOES:
|
|
* 1. Iterates through every element on the page
|
|
* 2. Captures current computed dimensions (width, height)
|
|
* 3. Sets inline styles with !important to freeze those dimensions
|
|
* 4. Disables ResizeObserver API (for JS-based resizing)
|
|
* 5. When viewport changes for screenshot, media queries can't resize anything
|
|
* 6. Layout remains consistent → xpath coordinates match screenshot ✓
|
|
*
|
|
* USAGE:
|
|
* Execute this script BEFORE calling capture_full_page() / screenshot functions.
|
|
* The page must be fully loaded and settled at its initial viewport size.
|
|
* No need to restore state afterward - page is closed after screenshot.
|
|
*
|
|
* PERFORMANCE:
|
|
* - Iterates all DOM elements (can be 1000s on complex pages)
|
|
* - Typically completes in 50-200ms
|
|
* - One-time cost before screenshot, well worth it for coordinate accuracy
|
|
*
|
|
* @see https://github.com/dgtlmoon/changedetection.io/issues/XXXX
|
|
*/
|
|
|
|
(() => {
|
|
// Store original styles in a global WeakMap for later restoration
|
|
window.__elementSizingRestore = new WeakMap();
|
|
|
|
// Lock ALL element dimensions to prevent media query layout changes
|
|
document.querySelectorAll('*').forEach(el => {
|
|
const computed = window.getComputedStyle(el);
|
|
const rect = el.getBoundingClientRect();
|
|
|
|
// Save original inline style values BEFORE locking
|
|
const properties = ['height', 'min-height', 'max-height', 'width', 'min-width', 'max-width'];
|
|
const originalStyles = {};
|
|
properties.forEach(prop => {
|
|
originalStyles[prop] = {
|
|
value: el.style.getPropertyValue(prop),
|
|
priority: el.style.getPropertyPriority(prop)
|
|
};
|
|
});
|
|
window.__elementSizingRestore.set(el, originalStyles);
|
|
|
|
// Lock dimensions with !important to override media queries
|
|
if (rect.height > 0) {
|
|
el.style.setProperty('height', computed.height, 'important');
|
|
el.style.setProperty('min-height', computed.height, 'important');
|
|
el.style.setProperty('max-height', computed.height, 'important');
|
|
}
|
|
if (rect.width > 0) {
|
|
el.style.setProperty('width', computed.width, 'important');
|
|
el.style.setProperty('min-width', computed.width, 'important');
|
|
el.style.setProperty('max-width', computed.width, 'important');
|
|
}
|
|
});
|
|
|
|
// Also disable ResizeObserver for JS-based resizing
|
|
window.ResizeObserver = class {
|
|
constructor() {}
|
|
observe() {}
|
|
unobserve() {}
|
|
disconnect() {}
|
|
};
|
|
|
|
console.log('✓ Element dimensions locked to prevent media query changes during screenshot');
|
|
})();
|