Feedly 优化

一些优化

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

// ==UserScript==
// @name         Feedly 优化
// @homepage     https://greasyfork.org/zh-CN/scripts/488038-feedly-%E4%BC%98%E5%8C%96
// @namespace    https://feedly.com
// @version      2025.03.04
// @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*/ timeindex,timecount=1)=>{timeindex=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();

                // 顺便帮忙处理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";

				clearInterval(timeindex);
            }
        }

		if(timecount==30){clearInterval(timeindex);}timecount++;
    },2000);})(); //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 跳到returnALL后返回ALL页面

    // 优化左侧 UI,将上方无用导航链接移至下方
    ((/*setInterval*/ timeindex, timecount = 1) => {
        // 检查必要的导航元素是否存在
        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;
                }
            });//forEach

            clearInterval(timeindex);
        }
		if (timecount == 120) { clearInterval(timeindex); } timecount++;
    }, 500);//end 优化左侧 UI

    //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 == 200) { clearInterval(timeindex); } timecount++;
        }, 300);
    })(); //end

    //清理右侧内容标题列表中绿色的广告,一直重复运行
	setInterval(() => {
		//删除广告
		if(document.querySelector('.InterestingMetadataWrapper--separator-right')){
			document.querySelector('.InterestingMetadataWrapper--separator-right').remove();
		}
		//删除跟随在广告后的小圆点
		if(document.querySelector('.EntryMetadataSeparator')){
			document.querySelector('.EntryMetadataSeparator').remove();
		}
	}, 4000);//end 右侧标题中的绿色广告
	//清理右侧顶栏的升级按钮。
	((/*setInterval*/ timeindex,timecount=1)=>{timeindex=setInterval(()=>{
		if(document.querySelector("#topHeaderBarFX")){
			if(document.querySelector("#topHeaderBarFX").querySelector("button").innerHTML.indexOf("Upgrade") != -1){
				document.querySelector("#topHeaderBarFX").querySelector("button").remove();
				clearInterval(timeindex);
			}
		}

		if(timecount==30){clearInterval(timeindex);}timecount++;
	},2000);})(); //end 顶部升级按钮

})(); //end all