debug: add console logging to CSS inlining for translated pages

- Add logging to see how many CSS links are found
- Log each CSS file being inlined and success/failure
- Help diagnose why translated pages may not have modal styling
This commit is contained in:
Russell Ballestrini 2025-07-09 16:21:40 -04:00
parent c65bde327c
commit 761c4ec259

View file

@ -379,10 +379,12 @@ export async function translateCurrentPage(targetLanguage) {
doc.body.innerHTML = translatedContent;
// Inline any external CSS that might be needed for the new window
const cssLinks = doc.querySelectorAll('link[rel="stylesheet"][href*="uncloseai"]');
const cssLinks = doc.querySelectorAll('link[rel="stylesheet"][href*="uncloseai-modal"]');
console.log('Found CSS links to inline:', cssLinks.length);
for (const link of cssLinks) {
try {
console.log('Inlining CSS:', link.href);
const response = await fetch(link.href);
const cssContent = await response.text();
@ -392,6 +394,7 @@ export async function translateCurrentPage(targetLanguage) {
// Replace the link with the inline style
link.parentNode.replaceChild(styleElement, link);
console.log('Successfully inlined CSS:', link.href);
} catch (error) {
console.warn('Failed to inline CSS:', link.href, error);
// Keep the original link if fetching fails