From c5786412ea017056d52d35a33f64c9c0371e3447 Mon Sep 17 00:00:00 2001 From: SansGuidon Date: Thu, 10 Apr 2025 10:46:09 +0000 Subject: [PATCH] feat(miniflux): hide Save button for feed 830 --- miniflux_scripts/hide_feed_save_btn.js | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 miniflux_scripts/hide_feed_save_btn.js diff --git a/miniflux_scripts/hide_feed_save_btn.js b/miniflux_scripts/hide_feed_save_btn.js new file mode 100644 index 0000000..a43d33b --- /dev/null +++ b/miniflux_scripts/hide_feed_save_btn.js @@ -0,0 +1,49 @@ +(function() { + // Hide Save button if the feed link contains "/feed/830/entries" + function hideSaveButtonInArticle(article) { + const feedLink = article.querySelector("li.item-meta-info-title a"); + if (feedLink && feedLink.href.indexOf("/feed/830/entries") !== -1) { + const btn = article.querySelector("button[data-save-entry]"); + if (btn) btn.style.display = "none"; + } + } + + // Process list articles + function processArticles() { + document.querySelectorAll("article.item.entry-item").forEach(hideSaveButtonInArticle); + } + + // Observe mutations in the container of articles (for dynamic content) + const itemsContainer = document.querySelector(".items"); + if (itemsContainer) { + // Process articles already in the DOM + processArticles(); + + const observer = new MutationObserver(mutations => { + mutations.forEach(mutation => { + mutation.addedNodes.forEach(node => { + if (node.nodeType === Node.ELEMENT_NODE && node.matches("article.item.entry-item")) { + hideSaveButtonInArticle(node); + } + }); + }); + }); + observer.observe(itemsContainer, { childList: true, subtree: true }); + } else { + // Fallback if container is not found + window.addEventListener("load", processArticles); + } + + // Hide the Save button on the open article page + function hideSaveButtonInEntry() { + const entryPage = document.querySelector("section.entry"); + if (entryPage) { + const websiteAnchor = entryPage.querySelector(".entry-meta .entry-website a"); + if (websiteAnchor && websiteAnchor.href.indexOf("/feed/830/entries") !== -1) { + const btn = entryPage.querySelector("button[data-save-entry]"); + if (btn) btn.style.display = "none"; + } + } + } + window.addEventListener("load", hideSaveButtonInEntry); +})();