FB全部留言小帮手

让您更快打开全部留言

目前为 2024-04-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Facebook All Comments Helper
  3. // @name:zh-TW FB全部留言小幫手
  4. // @name:zh-CN FB全部留言小帮手
  5. // @namespace http://tampermonkey.net/
  6. // @version 1.6
  7. // @description Easy way to show all comments.
  8. // @description:zh-tw 讓您更快打開全部留言
  9. // @description:zh-cn 让您更快打开全部留言
  10. // @author Xuitty
  11. // @match https://www.facebook.com/*
  12. // @icon https://www.google.com/s2/favicons?sz=64&domain=facebook.com
  13. // @grant none
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17. const langs = {
  18. de: ["Relevanteste", "Top-Kommentare", "Am zutreffendsten"],
  19. en: ["Top comments", "Most relevant", "Most applicable"],
  20. es: ["Comentarios destacados", "Más relevantes", "Más pertinentes"],
  21. hu: ["A legfontosabb hozzászólások", "A legrelevánsabbak", "A témához leginkább illők"],
  22. ja: ["トップコメント", "関連度の高い順", "最も適切"],
  23. ko: ["관련성 높은 댓글", "참여도 높은 댓글", "적합성 높은 순"],
  24. fr: ["Plus pertinents", "Les meilleurs commentaires", "Les plus pertinents"],
  25. sk: ["Top komentáre", "Najrelevantnejšie", "Najvhodnejšie"],
  26. sl: ["Najbolj priljubljeni komentarji", "Najustreznejši", "Najustreznejše"],
  27. "zh-Hans": ["热门评论", "最相关", "最合适"],
  28. "zh-Hant": ["最熱門留言", "最相關", "最相關"],
  29. };
  30.  
  31. function execute(e) {
  32. if (e.code !== "Insert" && e.type === "keydown") return;
  33. let node1;
  34. let fblang = document.getElementById("facebook").getAttribute("lang");
  35. let lang = langs[fblang] || langs.en;
  36. var headings = document.evaluate(
  37. "//span[text()='" + lang[0] + "' or text()='" + lang[1] + "' or text()='" + lang[2] + "']",
  38. document,
  39. null,
  40. XPathResult.ANY_TYPE,
  41. null
  42. );
  43. while ((node1 = headings.iterateNext())) {
  44. node1.click();
  45. setTimeout(() => {
  46. document.querySelectorAll('*[role="menuitem"]')[document.querySelectorAll('*[role="menuitem"]').length - 1].click();
  47. }, 100);
  48. }
  49. }
  50.  
  51. (function () {
  52. "use strict";
  53.  
  54. document.addEventListener("dblclick", execute);
  55. document.addEventListener("keydown", execute);
  56. })();
  57.  
  58.  
  59. // Just forgot to add version comment, v1.6 is totally the same code as v1.5