feat: style auto-summary blocks with Mistral result formatting

Detects "--- RÉSUMÉ AUTO ---" blocks and applies green styling consistent with existing Mistral script results
This commit is contained in:
2025-08-21 13:03:02 +00:00
parent 3bbdfec9ec
commit 87aade6243

View File

@@ -0,0 +1,65 @@
(function() {
'use strict';
// Only run on entry pages
if (!window.location.href.match(/\/entry\//)) return;
function styleAutoSummaries() {
const content = document.querySelector('.entry-content');
if (!content) return;
// Find text nodes containing "--- RÉSUMÉ AUTO ---"
const walker = document.createTreeWalker(
content,
NodeFilter.SHOW_TEXT,
null,
false
);
let node;
while (node = walker.nextNode()) {
const text = node.nodeValue;
if (text.includes('--- RÉSUMÉ AUTO ---')) {
// Find the paragraph or container
let container = node.parentElement;
while (container && !['P', 'DIV', 'ARTICLE'].includes(container.tagName)) {
container = container.parentElement;
}
if (container) {
// Apply the same styling as Mistral results
Object.assign(container.style, {
margin: '12px 0',
padding: '10px',
background: 'rgb(51 85 67)',
borderLeft: '3px solid rgb(71 180 103)',
fontFamily: 'Geist Mono',
whiteSpace: 'pre-wrap'
});
// Add header
const header = document.createElement('div');
header.textContent = 'RÉSUMÉ AUTO';
Object.assign(header.style, {
fontWeight: 'bold',
marginBottom: '8px',
color: 'rgb(71 180 103)',
fontSize: '0.9em'
});
container.insertBefore(header, container.firstChild);
// Clean up the content text
container.innerHTML = container.innerHTML.replace(/--- RÉSUMÉ AUTO ---/g, '');
}
}
}
}
// Run when page loads
if (document.readyState === 'complete') {
styleAutoSummaries();
} else {
window.addEventListener('load', styleAutoSummaries);
}
})();