fix(miniflux_styling_resumes): add auto-resume without separators

This commit is contained in:
2025-08-21 13:19:20 +00:00
parent 87aade6243
commit 85a9aebc58

View File

@@ -1,33 +1,27 @@
(function() { (function() {
'use strict'; 'use strict';
// Only run on entry pages
if (!window.location.href.match(/\/entry\//)) return; if (!window.location.href.match(/\/entry\//)) return;
function styleAutoSummaries() { function styleAutoSummaries() {
const content = document.querySelector('.entry-content'); const content = document.querySelector('.entry-content');
if (!content) return; if (!content) return;
// Find text nodes containing "--- RÉSUMÉ AUTO ---" // Find all paragraphs that contain RÉSUMÉ AUTO
const walker = document.createTreeWalker( const allElements = content.querySelectorAll('*');
content,
NodeFilter.SHOW_TEXT, allElements.forEach(element => {
null, if (element.textContent.includes('RÉSUMÉ AUTO') && !element.dataset.processed) {
false // Find the actual container (could be this element or a parent)
); let container = element;
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)) { while (container && !['P', 'DIV', 'ARTICLE'].includes(container.tagName)) {
container = container.parentElement; container = container.parentElement;
} }
if (container) { if (container) {
// Apply the same styling as Mistral results container.dataset.processed = 'true';
// Style the whole fucking container
Object.assign(container.style, { Object.assign(container.style, {
margin: '12px 0', margin: '12px 0',
padding: '10px', padding: '10px',
@@ -37,7 +31,11 @@
whiteSpace: 'pre-wrap' whiteSpace: 'pre-wrap'
}); });
// Add header // Clean and add header
container.innerHTML = container.innerHTML
.replace(/---\s*RÉSUMÉ AUTO\s*---/gi, '')
.replace(/^\s*RÉSUMÉ AUTO\s*/gi, '');
const header = document.createElement('div'); const header = document.createElement('div');
header.textContent = 'RÉSUMÉ AUTO'; header.textContent = 'RÉSUMÉ AUTO';
Object.assign(header.style, { Object.assign(header.style, {
@@ -48,15 +46,11 @@
}); });
container.insertBefore(header, container.firstChild); 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') { if (document.readyState === 'complete') {
styleAutoSummaries(); styleAutoSummaries();
} else { } else {