From 85a9aebc58c290935268a16863a47744ce9e104d Mon Sep 17 00:00:00 2001 From: SansGuidon Date: Thu, 21 Aug 2025 13:19:20 +0000 Subject: [PATCH] fix(miniflux_styling_resumes): add auto-resume without separators --- miniflux_scripts/auto-summary-styler.js | 38 +++++++++++-------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/miniflux_scripts/auto-summary-styler.js b/miniflux_scripts/auto-summary-styler.js index f19f6eb..7b284dd 100644 --- a/miniflux_scripts/auto-summary-styler.js +++ b/miniflux_scripts/auto-summary-styler.js @@ -1,33 +1,27 @@ (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; + // Find all paragraphs that contain RÉSUMÉ AUTO + const allElements = content.querySelectorAll('*'); + + allElements.forEach(element => { + if (element.textContent.includes('RÉSUMÉ AUTO') && !element.dataset.processed) { + // Find the actual container (could be this element or a parent) + let container = element; while (container && !['P', 'DIV', 'ARTICLE'].includes(container.tagName)) { container = container.parentElement; } if (container) { - // Apply the same styling as Mistral results + container.dataset.processed = 'true'; + + // Style the whole fucking container Object.assign(container.style, { margin: '12px 0', padding: '10px', @@ -37,7 +31,11 @@ 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'); header.textContent = 'RÉSUMÉ AUTO'; Object.assign(header.style, { @@ -48,15 +46,11 @@ }); 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 {