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:
65
miniflux_scripts/auto-summary-styler.js
Normal file
65
miniflux_scripts/auto-summary-styler.js
Normal 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);
|
||||
}
|
||||
})();
|
Reference in New Issue
Block a user