Patreon: Load and show all comments

On a post's page, this automates loading all the comments instead of requiring the user to click for each batch

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Patreon: Load and show all comments
// @namespace    http://tampermonkey.net/
// @version      2024.08.12
// @description  On a post's page, this automates loading all the comments instead of requiring the user to click for each batch
// @author       You
// @match        https://www.patreon.com/posts/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=patreon.com
// @grant        none
// ==/UserScript==

(function() {
    function loaded(){
        let lmc = Array.from(document.querySelectorAll("div[data-tag='post-card'] button")).find(x=>x.innerText == "Load more comments");
        if(lmc){
            lmc.innerHTML = "Load ALL comments";
            let obs = new MutationObserver(mut => { if(mut[0].addedNodes.length>0 && lmc){lmc.click();} }); //auto click button after a batch of comments added
            obs.observe(lmc.parentElement.parentElement, { childList: true, subtree: true }); //each comment is a sibling of the parent div of the lmc button
        }
    }
    window.addEventListener('load', function() {
        setTimeout(loaded, 2000);
    })
})();