Feedly 优化

一些优化

当前为 2024-12-13 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Feedly 优化
// @namespace    https://feedly.com
// @version      2024.12.13
// @description  一些优化
// @author       Ejin
// @match        https://feedly.com/*
// @grant        none
// ==/UserScript==

// 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.innerHTML.indexOf("First-read") == -1 ){
				document.querySelector(".count-followers").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,
                                    100-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('div[aria-label^="Mark 存档"')){
            if(document.querySelector('div[aria-label^="Mark 存档"').style.opacity==""){
                // 寻找存档文件夹的最上层元素,目的是设置透明,鼠标移动过去时取消透明
                var parEle = document.querySelector('div[aria-label^="Mark 存档"]');
                while (parEle.parentElement.querySelectorAll('button').length <= 1) {
                    // length可能性:0=没找到展开按钮,1=找到了1个,2+=找到了2+个(超过本文件夹最上层DOM)
                    parEle = parEle.parentElement;
                }

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

    // 4.优化左侧UI,将上方无用导航链接移至下方
    var optimizetimeid=setInterval(() => {
        if(document.querySelector('div[title="Today"]')
        && document.querySelector('div[title="Recently Read"]')){
            //判断存在上方导航链接和下方导航链接
            var nav_top=document.querySelector('div[title="Today"]').parentElement;
            var nav_foot=document.querySelector('div[title="Recently Read"]').parentElement;
            var j=0;
            nav_foot.children[0].style.borderTop = '1px solid #ccc';//原下方导航栏最上面加一个横线
            for(var i=nav_top.children.length-1;i > -1;i--){
                nav_foot.insertBefore(nav_top.children[0],nav_foot.children[j]);
                j++;
            }
            nav_top.remove();
            clearInterval(optimizetimeid);
        }
    }, 1000);

})(); //end all