2021-07-22 ,

Feedly Open All Unread Button Jul.2021

久しぶりにFeedlyを使ってみているのですが、未読のページ(全文)を一括で開く機能が無いととても使う気になれないので以前作っていたスクリプトを修正しました。

ChromeのTampermonkeyで確認。

// ==UserScript==
// @name         Feedly Open All Unread
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://feedly.com/i/*
// @icon         https://www.google.com/s2/favicons?domain=feedly.com
// @grant        GM_openInTab
// ==/UserScript==

(function() {
    'use strict';

    function openUnreadEntries(limit){
        const unreads = document.querySelectorAll(".entry--unread");
        const count = Math.min(unreads.length, limit || 5);
        console.log("count="+count);
        for(let i = 0; i < count; ++i){
            const entry = unreads[i];
            const url = entry && entry.dataset.alternateLink;
            //window.open(url, "_blank");
            //browser.tabs.create({url, active: false});
            GM_openInTab(url, {active:false});
            console.log("open " + url);

            // mark as read and hide
            const readAndHideButton = entry && (
                entry.querySelector(".EntryHideButton") || //Title Only
                    entry.querySelector(".EntryMarkAsReadButton") //Magazine, Card
            );
            if(readAndHideButton){
                readAndHideButton.click();
            }
        };
    }
    function createButton(){
        const div = document.createElement("div");
        div.style.display = "inline-block";
        div.style.verticalAlign = "top";
        div.className = "button-dropdown OpenUnreadButton";

        const button = document.createElement("button");
        div.appendChild(button);
        button.type = "button";
        button.innerText = "Open Unread";
        button.style = "padding-right:0px; margin-right:0px;";
        button.addEventListener("click", function(e){
            openUnreadEntries(parseInt(inputCount.value, 10));
        }, false);

        const inputCount = document.createElement("input");
        div.appendChild(inputCount);
        inputCount.type = "number";
        inputCount.value = "5";
        inputCount.style = "width:4em; padding:12px 5px 10px 5px; border:1px solid transparent; appearance: normal;";

        return div;
    }
    function updatePageUI(){
        for(const bar of document.getElementsByClassName("actions-container")){
            if(!bar.querySelector(".OpenUnreadButton")){
                bar.insertBefore(createButton(), bar.firstChild);
            }
        }
    }
    setInterval(updatePageUI, 1000);

})();

Inoreaderというのも使ってみたのですが、どっちみち全文を一気に読むには拡張機能が必要なことに変わりないのでとりあえずFeedlyでいいやと思いました。