// ==UserScript== // @name Facebook All Comments Helper // @name:zh-TW FB全部留言小幫手 // @name:zh-CN FB全部留言小帮手 // @namespace http://tampermonkey.net/ // @version 1.3 // @description Easy way to show all comments. // @description:zh-tw 讓您更快打開全部留言 // @description:zh-cn 让您更快打开全部留言 // @author Xuitty // @match https://www.facebook.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=facebook.com // @grant none // @license MIT // @downloadURL none // ==/UserScript== const langs = { de: ["Relevanteste", "Top-Kommentare", "Am zutreffendsten"], en: ["Top comments", "Most relevant", "Most applicable"], es: ["Comentarios destacados", "Más relevantes", "Más pertinentes"], ja: ["トップコメント", "関連度の高い順", "最も適切"], ko: ["관련성 높은 댓글", "참여도 높은 댓글", "적합성 높은 순"], fr: ["Plus pertinents", "Les meilleurs commentaires", "Les plus pertinents"], "zh-Hans": ["热门评论", "最相关", "最合适"], "zh-Hant": ["最熱門留言", "最相關", "最相關"], }; function execute(e) { if (e.code !== "Insert" && e.type === "keydown") return; let node1; let fblang = document.getElementById("facebook").getAttribute("lang"); let lang = langs[fblang] || langs.en; var headings = document.evaluate( "//span[text()='" + lang[0] + "' or text()='" + lang[1] + "' or text()='" + lang[2] + "']", document, null, XPathResult.ANY_TYPE, null ); while ((node1 = headings.iterateNext())) { node1.click(); setTimeout(() => { document.querySelectorAll('*[role="menuitem"]')[document.querySelectorAll('*[role="menuitem"]').length - 1].click(); }, 100); } } (function () { "use strict"; document.addEventListener("dblclick", execute); document.addEventListener("keydown", execute); })();