Add(Miniflux): share my feed classifier

This commit is contained in:
SansGuidon 2024-11-18 11:52:47 +00:00
parent d1a8d07b09
commit 1e83165361

View File

@ -0,0 +1,55 @@
(function() {
'use strict';
// Check if the URL matches the specific pattern
if (!window.location.href.match(/\/feed\/\d+\/entries\/all$/)) {
return; // Exit if the URL does not match
}
function calculateAndDisplayStatus() {
const entries = Array.from(document.querySelectorAll('article.item.entry-item'));
const totalEntries = entries.length;
if (totalEntries === 0) return;
let starredCount = 0;
entries.forEach(entry => {
const isStarred = entry.querySelector('li.item-meta-icons-star button[data-value="star"]') !== null;
if (isStarred) {
starredCount++;
}
});
const percentageStarred = (starredCount / totalEntries) * 100;
let statusEmoji = '';
let statusText = '';
if (totalEntries < 10) {
statusEmoji = '💭';
statusText = 'Thinking';
} else if (percentageStarred > 40) {
statusEmoji = '😍';
statusText = 'Interesting';
} else if (percentageStarred > 20) {
statusEmoji = '🤔';
statusText = 'Thinking';
} else {
statusEmoji = '🥱';
statusText = 'Boring';
}
// Calculate the score as a ratio
const score = `${starredCount}/${totalEntries}`;
const feedHeader = document.querySelector('section.page-header');
const statusElement = document.createElement('span');
statusElement.style.fontSize = '1.5em';
statusElement.style.marginLeft = '10px';
statusElement.textContent = `${statusEmoji} ${score} - ${statusText}`;
feedHeader.appendChild(statusElement);
}
window.addEventListener('load', calculateAndDisplayStatus);
})();