fix: sort feeds by total entries after Miniflux DOM change
This commit is contained in:
@@ -3,8 +3,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
if (!window.location.href.match(/\/feeds$/)) return;
|
if (!window.location.href.match(/\/feeds$/)) return;
|
||||||
function parseTotal(feed) {
|
function parseTotal(feed) {
|
||||||
const spans = feed.querySelectorAll('.feed-entries-counter span[aria-hidden="true"]');
|
const counter = feed.querySelector('.feed-entries-counter');
|
||||||
return spans[3] ? parseInt(spans[3].textContent, 10) : 0;
|
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) {
|
function sortFeeds(desc) {
|
||||||
const feeds = Array.from(document.querySelectorAll('article.item.feed-item'));
|
const feeds = Array.from(document.querySelectorAll('article.item.feed-item'));
|
||||||
@@ -29,4 +34,4 @@
|
|||||||
li.appendChild(btn);
|
li.appendChild(btn);
|
||||||
navList.appendChild(li);
|
navList.appendChild(li);
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
Reference in New Issue
Block a user