Feedly 优化

一些优化

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

// ==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.25
// @description  一些优化
// @author       Ejin
// @match        https://feedly.com/*
// @grant        none
// ==/UserScript==

// 2025.02.25 
// 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

    // 4.优化左侧UI,将上方无用导航链接移至下方
    var optimizetimeid=setInterval(() => {
        if(document.querySelector('div[title="Today"]')
        && document.querySelector('div[title="Recently Read"]')){
            //判断存在上方导航链接和下方导航链接
			var nav_foot=document.querySelector('div[title="Blog"]').parentElement;//定位左边栏下方
			var j=0;

            //通过Today定位上面的区域
			var nav_top=document.querySelector('div[title="Today"]').parentElement;//定位左边栏上方
            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++;
            }
			//清理元素移走后仍然占位的问题
			while(nav_top.parentElement.innerText==""){
				nav_top=nav_top.parentElement;
			}
			nav_top.remove();

			//通过Read Later定位上面的第2个区域,后面代码是一样的
			nav_top=document.querySelector('div[title="Read Later"]').parentElement;//定位左边栏上方
            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++;
            }
			//清理元素移走后仍然占位的问题
			while(nav_top.parentElement.innerText==""){
				nav_top=nav_top.parentElement;
			}
			nav_top.remove();

			//通过Recently Read定位上面的第3个区域,后面代码是一样的
			nav_top=document.querySelector('div[title="Recently Read"]').parentElement;//定位左边栏上方
            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++;
            }
			//清理元素移走后仍然占位的问题
			while(nav_top.parentElement.innerText==""){
				nav_top=nav_top.parentElement;
			}
			nav_top.remove();

            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