diff --git a/miniflux_scripts/feed_classifier.js b/miniflux_scripts/feed_classifier.js new file mode 100644 index 0000000..68d40ff --- /dev/null +++ b/miniflux_scripts/feed_classifier.js @@ -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); +})();