FB 預設使用所有留言

FB default set all comment

目前为 2022-07-27 提交的版本。查看 最新版本

// ==UserScript==
// @name         FB 預設使用所有留言
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  FB default set all comment
// @description:zh-tw  FB 預設開啟所有留言
// @author       You
// @match        https://www.facebook.com/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=facebook.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    console.log("FB 預設開啟所有留言 開始作業")
    document.body.addEventListener('mousedown', async function () {
        console.log("click")
        let a
        let has=false

        await new Promise(r => setTimeout(r, 300));
        let timeOut=0;
        while(!has){
            a = document.querySelectorAll("span:not([fb_doac])")
            for (let i = 0; i < a.length; i++) {
                var b=a[i];
                let c=b.closest("div[aria-posinset]")
                if(c==null) continue;
                if(c.getAttribute("fb_doac")=="true"){
                    //console.log("jump")
                    continue;
                }
                //this line is show the possible menu text, you can change to your language
                if((b.innerText.indexOf("最舊")==0||b.innerText.indexOf("最相關")==0||b.innerText.indexOf("最新")==0) && b.querySelector("[data-ad-preview]")==null && b.closest("[data-ad-preview]") ==null ){
                    b.click()
                    //b.innerText="-"+b.innerText
                    b.closest("div[aria-posinset]").setAttribute("fb_doac",true);
                    has=true
                    //console.log("發現 所有留言的存在")
                }
            }
            await new Promise(r => setTimeout(r, 100));
            timeOut+=100
            if(timeOut>5000) return;
        }
        if(!has) return

        timeOut=0
        while(has){
            a = document.querySelectorAll("span:not([fb_doac])")
            for (let i = 0; i < a.length; i++) {
                b=a[i];
                //this line is show the possible menu text's under explain, you can change to your language
                if((b.innerText.indexOf("顯示所有留言,包含可能是垃圾訊息的內容。最相關的留言會顯示在最上方。")!=-1|| b.innerText.indexOf("依時間順序顯示所有留言,包括可能是垃圾訊息的留言。")!=-1) && b.querySelector("[data-ad-preview]")==null && b.closest("[data-ad-preview]") ==null ){
                    //console.log(b)
                    b.click()
                    //b.innerText="-"+b.innerText
                    //console.log("自動按所有留言")
                    has=false
                }
            }
            await new Promise(r => setTimeout(r, 100));
            timeOut+=100
            if(timeOut>5000) return;
        }
        //console.log("完成任務")
    })
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址