Facebook All Comments Helper

Easy way to show all comments.

As of 2024-02-22. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Facebook All Comments Helper
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Easy way to show all comments.
// @author       Xuitty
// @match        https://www.facebook.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=facebook.com
// @grant        none
// @license      MIT
// ==/UserScript==

const langs = {
	de: ["Relevanteste", "Top-Kommentare"],
	en: ["Top comments", "Most relevant"],
	es: ["Comentarios destacados", "Más relevantes"],
	ja: ["トップコメント", "関連度の高い順"],
	ko: ["관련성 높은 댓글", "참여도 높은 댓글"],
	fr: ["Plus pertinents", "Les meilleurs commentaires"],
	"zh-Hans": ["热门评论", "最相关"],
	"zh-Hant": ["最熱門留言", "最相關"],
};

(function () {
	"use strict";

	document.addEventListener("dblclick", execute);
	document.addEventListener("keydown", execute);
})();


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] + "']",
		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);
	}
}