From 1e831653617e6579d2bc624e5013e316f40d4e78 Mon Sep 17 00:00:00 2001 From: SansGuidon Date: Mon, 18 Nov 2024 11:52:47 +0000 Subject: [PATCH] Add(Miniflux): share my feed classifier --- miniflux_scripts/feed_classifier.js | 55 +++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 miniflux_scripts/feed_classifier.js 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); +})();