Feedly 优化

一些优化

目前為 2025-02-26 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Feedly 优化
// @homepage     https://greasyfork.org/zh-CN/scripts/488038-feedly-%E4%BC%98%E5%8C%96
// @namespace    https://feedly.com
// @version      2025.02.27
// @description  一些优化
// @author       Ejin
// @match        https://feedly.com/*
// @grant        none
// ==/UserScript==

// 2025.02.25 消灭新特性提醒窗口(What's new,并且为漂浮状态)
// 2024.08.10 优化左侧UI,将上方无用导航链接移至下方
// 2024.07.14 弱化存档分类的加粗,隐藏未读数。
// 2024.02.23 First-read,跳转到第一个已读项
(function () {
    'use strict';

    setInterval(() => {//1.route

        // 1.1 First-read
        if (location.href.indexOf("feedly.com/i/subscription/feed") != -1) {
            if (document.querySelector(".count-followers") != null
                && document.querySelector(".count-followers").parentElement.parentElement.innerHTML.indexOf("First-read") == -1) {
                document.querySelector(".count-followers").parentElement.parentElement.innerHTML
                    += "<span class='detail'> <a href='javascript:;' id='First-read' style='color:#9e9e9e;'>First-read</a></span>";
                document.getElementById("First-read").addEventListener('click', () => {
                    var FunID = setInterval(() => {//First-read Function
                        document.getElementById("First-read").style.display = "none";

                        if (document.querySelector("html").getAttribute("FunURL") != null) {
                            if (document.querySelector("html").getAttribute("FunURL") != location.href) {
                                clearInterval(document.querySelector("html").getAttribute("FunID"));
                                document.querySelector("html").removeAttribute("FunID");
                                document.querySelector("html").removeAttribute("FunURL");
                                return;
                            }
                        }

                        if (document.querySelectorAll(".EntryTitleLink").length > 0 || document.querySelectorAll(".entry--read").length > 0) {
                            if (!document.querySelector(".entry--read")) {
                                document.querySelectorAll(".EntryTitleLink")[document.querySelectorAll(".EntryTitleLink").length - 1].scrollIntoView();
                            } else {
                                document.querySelector('#feedlyFrame').scrollBy(0, -1000);//预先向上滚,让元素显示时出现在最上方
                                document.querySelector(".entry--read").scrollIntoView();
                                clearInterval(document.querySelector("html").getAttribute("FunID"));
                                document.querySelector("html").removeAttribute("FunID");
                                document.querySelector("html").removeAttribute("FunURL");
                                document.querySelector('#feedlyFrame').scrollBy(0,
                                    200 - document.querySelector('#feedlyFrame').clientHeight
                                );//元素显示后,稍微向上滚动一点
                            }
                        }

                    }, 1000);//setInterval
                    document.querySelector("html").setAttribute("FunID", FunID);
                    document.querySelector("html").setAttribute("FunURL", location.href);
                });
            }
        } //end 1.1

    }, 500);//end 1.route

    // 2.弱化存档分类的加粗,隐藏未读数。
    setInterval(() => {
        if (document.querySelector('button[aria-label^="Mark 存档"')) {
            if (document.querySelector('button[aria-label^="Mark 存档"').style.opacity == "") {
                // 寻找存档文件夹的最上层元素,目的是设置透明,鼠标移动过去时取消透明
                var parEle = document.querySelector('button[aria-label^="Mark 存档"]');
                while (parEle.parentElement.querySelectorAll('button').length <= 3) {
                    // length可能性:1=没找到未读数本身(是个按钮),3=找到了本栏所有按钮,4+=找到了4+个(超过本文件夹最上层DOM)
                    parEle = parEle.parentElement;
                }

                //通过透明隐藏未读数
                parEle.onmouseover = () => {
                    document.querySelector('button[aria-label^="Mark 存档"').style.opacity = "1";
                };
                parEle.onmouseout = () => {
                    document.querySelector('button[aria-label^="Mark 存档"').style.opacity = "0.2";
                };
                parEle.onmouseout();

                //取消加粗
                //document.querySelectorAll(".LeftnavListRow__text--bold").forEach(item=>{
                //    if(item.innerHTML=="存档"){
                //        item.className=item.className.replace("LeftnavListRow__text--bold","");
                //    }
                //});

                // 顺便帮忙处理returnALL类别的加粗和未读数
                document.querySelectorAll(".LeftnavListRow__text--bold").forEach(item => {
                    if (item.innerHTML == "returnALL") {
                        item.className = item.className.replace("LeftnavListRow__text--bold", "");
                    }
                });
                document.querySelector('button[aria-label^="Mark returnALL"').style.display = "none";
            }
        }
    }, 10000);// end

    // 3.点击、标记已读自动跳到returnALL后返回ALL页面
    setInterval(() => {
        if (document.querySelector("#header-title") && document.querySelector("#header-title").innerText == "returnALL") {
            //文件夹和RSS有区别,如果进的是RSS会有一个链接,所以用innerText获取是通用的
            document.querySelectorAll("span").forEach(ele => {
                if (ele.innerHTML == "All") {
                    ele.click();
                }
            });
        }
    }, 1500);// end

    // 优化左侧 UI,将上方无用导航链接移至下方
    var optimizetimeid = setInterval(() => {
        // 检查必要的导航元素是否存在
        if (document.querySelector('div[title="Today"]') && document.querySelector('div[title="Integrations & API"]')) {
            const navTitles = ["Today", "Read Later", "Recently Read"]; // 需要移动的导航标题列表
            const navFoot = document.querySelector('div[title="Integrations & API"]').parentElement; // 定位左边栏下方
            let insertIndex = 0; // 记录插入位置
            navFoot.children[0].style.borderTop = '1px solid #ccc'; // 原下方导航栏最上面加一个横线

            navTitles.forEach(title => {
                const navTop = document.querySelector(`div[title="${title}"]`).parentElement; // 定位左边栏上方

                // 将上方导航元素移动到下方
                while (navTop.children.length > 0) {
                    navFoot.insertBefore(navTop.children[0], navFoot.children[insertIndex]);
                    insertIndex++;
                }

                // 清理空父元素
                let parent = navTop.parentElement;
                while (parent && parent.innerText.trim() === "") {
                    const temp = parent.parentElement;
                    parent.remove();
                    parent = temp;
                }
            });

            clearInterval(optimizetimeid); // 清除定时器
        }
    }, 1000);

    //5.消灭新特性提醒窗口(What's new,并且为漂浮状态)
    ((/*setInterval*/ timeindex, timecount = 1) => {
        timeindex = setInterval(() => {
            if (document.querySelector(".AppDockedPopups")) {
                if (document.querySelector(".AppDockedPopups").innerHTML.indexOf("What's new") != -1) {
                    document.querySelector(".AppDockedPopups").querySelector("button").click();
                }
            }

            if (timecount == 100) { clearInterval(timeindex); } timecount++;
        }, 300);
    })(); //end

})(); //end all