fix(miniflux_styling_resumes): add auto-resume without separators
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user