diff --git a/miniflux_scripts/feed_count_sort_controls.js b/miniflux_scripts/feed_count_sort_controls.js index 668af62..e579353 100644 --- a/miniflux_scripts/feed_count_sort_controls.js +++ b/miniflux_scripts/feed_count_sort_controls.js @@ -3,8 +3,13 @@ 'use strict'; if (!window.location.href.match(/\/feeds$/)) return; function parseTotal(feed) { - const spans = feed.querySelectorAll('.feed-entries-counter span[aria-hidden="true"]'); - return spans[3] ? parseInt(spans[3].textContent, 10) : 0; + const counter = feed.querySelector('.feed-entries-counter'); + if (!counter) return 0; + const spans = counter.querySelectorAll('span[aria-hidden="true"]'); + if (!spans.length) return 0; + const txt = spans[spans.length - 1].textContent || ''; + const m = txt.match(/\d+/); + return m ? parseInt(m[0], 10) : 0; } function sortFeeds(desc) { const feeds = Array.from(document.querySelectorAll('article.item.feed-item')); @@ -29,4 +34,4 @@ li.appendChild(btn); navList.appendChild(li); }); -})(); \ No newline at end of file +})();