Skip to content

Commit ecfb557

Browse files
committed
fix: Utilisation du style.css lors d'un problème API
1 parent 3dfa19b commit ecfb557

File tree

1 file changed

+9
-37
lines changed

1 file changed

+9
-37
lines changed

src/theme.js

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,16 @@ async function applyCustomBackgroundCSS() {
281281
}
282282
} catch (error) {
283283
console.error("[Better IUT RCC] Erreur lors de la récupération du CSS pour fond personnalisé", error);
284+
284285
// En cas d'erreur, utiliser un CSS minimal de secours
285-
injectCustomBackgroundCSS(getMinimalCustomBackgroundCSS());
286+
const cssURL = browser.runtime.getURL('style.css');
287+
console.log("Fetching CSS from:", cssURL);
288+
const cssResponse = await fetch(cssURL);
289+
const cssContent = await cssResponse.text();
290+
291+
await browser.storage.local.set({ [fallbackCSSKey]: cssContent });
292+
console.info("[Better IUT RCC] CSS local enregistré en cache");
293+
injectCSS(cssContent);
286294
}
287295
}
288296

@@ -349,42 +357,6 @@ function filterBackgroundImageRules(cssContent) {
349357
return filtered;
350358
}
351359

352-
/**
353-
* Injecte un CSS minimal de secours en cas d'inaccessibilité de l'API de Paul
354-
*
355-
* @returns {string}
356-
*/
357-
function getMinimalCustomBackgroundCSS() {
358-
const isDarkTheme = document.querySelector('body').classList.contains('dark-theme');
359-
const themePrefix = isDarkTheme ? 'body.rcc.dark-theme' : 'body.rcc:not(.dark-theme)';
360-
361-
return `
362-
.new-note {
363-
background-color: #ea9d34 !important;
364-
}
365-
366-
.new-note td {
367-
background-color: #ea9d34 !important;
368-
}
369-
370-
${themePrefix} .card,
371-
${themePrefix} .media-list,
372-
${themePrefix} .code-preview {
373-
background-color: ${isDarkTheme ? 'rgba(0, 0, 0, 0.5)' : 'rgba(255, 255, 255, 0.8)'} !important;
374-
border-radius: 10px !important;
375-
box-shadow: -5px 5px 5px ${isDarkTheme ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.1)'} !important;
376-
}
377-
378-
${themePrefix} .header {
379-
background-color: ${isDarkTheme ? 'rgba(0, 0, 0, 0.4)' : 'rgba(255, 255, 255, 0.3)'} !important;
380-
}
381-
382-
${themePrefix} .site-footer {
383-
background-color: ${isDarkTheme ? 'rgba(0, 0, 0, 0.5)' : 'rgba(255, 255, 255, 0.8)'} !important;
384-
}
385-
`;
386-
}
387-
388360
export async function getAvailableThemes() {
389361
return await fetch('https://betteriutrcc.bayfield.dev/v1/themes').then(response => response.json());
390362
}

0 commit comments

Comments
 (0)