您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
FB default set all comment
当前为
// ==UserScript== // @name FB 預設使用所有留言 // @namespace http://tampermonkey.net/ // @version 2.72 // @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,b let has=false let originAll=false await new Promise(r => setTimeout(r, 300)); let timeOut=0; let article=[] while(!has){ a = document.querySelectorAll("span:not([fb_doac]), div:not([fb_doac])") let top= window.scrollTop for (let i = 0; i < a.length; i++) { b=a[i]; let c=b.closest("div[aria-posinset]") if(c==null) continue; if(c.getAttribute("fb_doac")=="true"){ //console.log("jump") continue; } if(getInnerDepth(b)>5) continue; let text=b.innerText //this line is show the possible menu text, you can change to your language if((text.indexOf("與星星一同傳送的留言")==0||text.indexOf("即時留言")==0||text.indexOf("最舊")==0||text.indexOf("最相關")==0||text.indexOf("最新")==0) && b.querySelector("[data-ad-preview]")==null && b.closest("[data-ad-preview]") ==null ){ b.click() window.scrollTop=top //b.innerText="-"+b.innerText let topElement=b.closest("div[aria-posinset]") topElement.setAttribute("fb_doac",true); article.push(topElement) has=true //console.log("發現 所有留言的存在") } if(text.indexOf("所有留言")==0){ has=true originAll=true let topElement=b.closest("div[aria-posinset]") topElement.setAttribute("fb_doac",true); article.push(topElement) } } await new Promise(r => setTimeout(r, 100)); timeOut+=100 if(timeOut>5000) return; } if(!has) return //console.log(article) timeOut=0 /*if(originAll){ has=false }*/ let second=[] while(has){ a = document.querySelectorAll("span:not([fb_doac]), div:not([fb_doac])") let top= window.scrollTop for (let i = 0; i < a.length; i++) { b=a[i]; if(getInnerDepth(b)>3) continue; let text=b.innerText //this line is show the possible menu text's under explain, you can change to your language if((text.indexOf("顯示所有留言,從舊到新排序。")!=-1||text.indexOf("留言出現在影片中的時候便會同步顯示。")!=-1||text.indexOf("顯示所有留言,包含可能是垃圾訊息的內容。最相關的留言會顯示在最上方。")!=-1|| text.indexOf("依時間順序顯示所有留言,包括可能是垃圾訊息的留言。")!=-1) && b.querySelector("[data-ad-preview]")==null && b.closest("[data-ad-preview]") ==null ){ //console.log(b) b.click() window.scrollTop=top //b.innerText="-"+b.innerText //console.log("自動按所有留言") has=false } else if(second==null && (text.indexOf("顯示所有留言,且最新的留言顯示在最上方。")!=-1 ) && b.querySelector("[data-ad-preview]")==null && b.closest("[data-ad-preview]") ==null ){ second.push(b) } } await new Promise(r => setTimeout(r, 100)); timeOut+=50 if(has && timeOut>1000){ if(second.length>0){ second.foreach(x=>x.click()) window.scrollTop=top has=false } } } has=false while(!has){ timeOut=0 let top= window.scrollTop for(let i=0;i<article.length;i++){ let item=article[i] let c= item.querySelectorAll("span:not([fb_doac]), div:not([fb_doac])") for(let j=0;j<c.length;j++){ b=c[j] let text=b.innerText if(getInnerDepth(b)>3) continue //this line is show the possible menu text's under explain, you can change to your language if(text.indexOf("顯示先前的留言")!=-1 || text.indexOf("檢視另")!=-1 || text.indexOf("查看")!=-1) { b.click() window.scrollTop=top has=true } } } await new Promise(r => setTimeout(r, 100)); timeOut+=100 if(timeOut>5000) return; } //console.log("完成任務") }) function getInnerDepth(node) { if (node.children.length) { var depths = Array.prototype.map.call(node.children, getInnerDepth); return 1 + Math.max.apply(Math, depths); } else { return 1; } } })();