For updating all current Substack posts in your inbox to "Archived" - copy and paste this into the console on your browser:

let isArchiving = false;
let lastProcessedPost = null;

function archiveVisiblePosts() {
    if (isArchiving) return;
    isArchiving = true;

    const posts = document.querySelectorAll('._linkRow_1qqfh_28.reader2-post-container');
    let delay = 0;
    const delayIncrement = 300; // 300ms delay between each action

    posts.forEach((post, index) => {
        if (post === lastProcessedPost) return;

        setTimeout(() => {
            const actionsMenu = post.querySelector('.inbox-item-actions-menu');
            if (actionsMenu) {
                actionsMenu.click();
                
                setTimeout(() => {
                    const archiveButton = document.querySelector('button svg.lucide.lucide-archive').closest('button');
                    if (archiveButton) {
                        archiveButton.click();
                        console.log(`Archived post ${index + 1}`);
                    } else {
                        console.log(`Couldn't find archive button for post ${index + 1}`);
                    }
                }, 100); // Wait 100ms for the menu to open before clicking archive
            } else {
                console.log(`Couldn't find actions menu for post ${index + 1}`);
            }

            if (index === posts.length - 1) {
                lastProcessedPost = post;
                isArchiving = false;
            }
        }, delay);

        delay += delayIncrement;
    });
}

function scrollAndArchive() {
    window.scrollTo(0, document.body.scrollHeight);
    setTimeout(() => {
        archiveVisiblePosts();
        scrollAndArchive();
    }, 2000); // Wait 2 seconds before next scroll and archive
}

scrollAndArchive();