diff --git a/miniflux_scripts/shorter_entries_filter.js b/miniflux_scripts/shorter_entries_filter.js new file mode 100644 index 0000000..af00761 --- /dev/null +++ b/miniflux_scripts/shorter_entries_filter.js @@ -0,0 +1,47 @@ +(function() { + 'use strict'; + + // Style short reading time entries with user-preferred style + document.querySelectorAll('article.item.entry-item').forEach(entry => { + const readingTimeElement = entry.querySelector('.item-meta-info-reading-time span'); + if (readingTimeElement && (readingTimeElement.textContent.includes('1 minute') || readingTimeElement.textContent.includes('2 minutes'))) { + entry.style.backgroundColor = 'rgb(37, 44, 39)'; // Dark muted greenish-gray + entry.style.border = '1px solid rgb(79, 194, 20)'; // Subtle green border + entry.style.borderRadius = '4px'; // Smooth corners + entry.style.padding = '5px'; // Comfortable padding + } + }); + + // Add a filter for short reading times + function addShortReadingTimeFilter() { + const pageHeader = document.querySelector('.page-header nav ul'); + if (!pageHeader) return; + + const filterButton = document.createElement('button'); + filterButton.textContent = 'Filter: Short Reads'; + filterButton.style.marginLeft = '10px'; + filterButton.style.padding = '5px 10px'; + filterButton.style.border = '1px solid rgb(79, 194, 20)'; + filterButton.style.borderRadius = '5px'; + filterButton.style.backgroundColor = 'rgb(37, 44, 39)'; + filterButton.style.color = '#fff'; + filterButton.style.cursor = 'pointer'; + + filterButton.onclick = () => { + document.querySelectorAll('article.item.entry-item').forEach(entry => { + const readingTimeElement = entry.querySelector('.item-meta-info-reading-time span'); + if (readingTimeElement && + (readingTimeElement.textContent.includes('1 minute') || readingTimeElement.textContent.includes('2 minutes'))) { + entry.style.display = ''; // Show entry + } else { + entry.style.display = 'none'; // Hide non-matching entries + } + }); + }; + + pageHeader.appendChild(filterButton); + } + + // Add the filter button after DOM is fully loaded + document.addEventListener('DOMContentLoaded', addShortReadingTimeFilter); +})(); \ No newline at end of file