round-robin sort for miniflux
One of the things I liked about fraidyc.at when I was using it was that sources that posted more didn’t get more room in The Feed than sources that posted less. For various reasons, I’m using Miniflux now, and I wanted to replicate that. Here is a Tampermonkey script that will take your unread page and reorder the entries on it. It’s not particularly fast because I am not a Web Professional so be warned if you have your page length set to something long.
// ==UserScript==
// @name Round Robin Sort
// @namespace http://tampermonkey.net/
// @version 0.1
// @description take Miniflux entries and interleave them by source
// @author maya
// @homepage https://maya.land
// @match https://<YOUR MINIFLUX INSTANCE GOES HERE>/news/unread
// @grant none
// ==/UserScript==
(function() {
'use strict';
function getSource(x) {
return x.querySelector(".item-meta-info li:nth-child(1)").innerText;
};
var list = document.querySelector(".items");
var items = Array.from(list.children);
var counts = new Map();
var priorities = new Map();
items.forEach(function(x){
var source = getSource(x);
if (! counts.has(source)) {counts.set(source, 0);}
var newCount = counts.get(source) + 1;
counts.set(source, newCount);
priorities.set(x, newCount);
});
function cmp(a, b){
return priorities.get(a) - priorities.get(b);
};
items.sort(cmp);
list.innerHTML = null;
items.forEach( x => list.appendChild(x));
})();