Greasy Fork is available in English.

twitter text comments only

Twitter script to curate and display only text comments that are relevant and meaningful, filtering out unrelated memes and nonsensical content.

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

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

Tendrás que instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Tendrás que instalar una extensión como Tampermonkey antes de poder instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         twitter text comments only
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Twitter script to curate and display only text comments that are relevant and meaningful, filtering out unrelated memes and nonsensical content.
// @author       You
// @match https://twitter.com/*/status/*

// ==/UserScript==

(function () {
    'use strict';
    function injectCss() {
        // Create a <style> element
        var styleElement = document.createElement('style');
        styleElement.id = "text-comments-only";
        // Define your CSS rules
        var cssCode = `
            [data-testid="cellInnerDiv"]:nth-child(1) {
            display: unset !important;
            }
        `;
        // Add your CSS rules to the <style> element
        styleElement.textContent = cssCode;
        document.head.appendChild(styleElement);
    }


    // Select the node that will be observed for mutations
    const targetNode = document.body;

    // Options for the observer (which mutations to observe)
    const config = { attributes: true, childList: true, subtree: true };

    // Create an observer instance linked to the callback
    const observer = new MutationObserver(callback);

    // Start observing the target node for configured mutations
    observer.observe(targetNode, config);

    // Callback function to execute when mutations are observed
    function callback(mutationList) {
        for (const mutation of mutationList) {
            const isNewNodeAdded = mutation.addedNodes && mutation.addedNodes?.length > 0;
            const isStyleInjected = document.getElementById("text-comments-only");

            if (isNewNodeAdded && /^https?:\/\/(www\.)?twitter\.com\/.*\/status\/\d{19}$/.test(location.href)) {
                const node = mutation.addedNodes[0];
                if (node.classList?.length > 0) {
                    const tweetPosts = document.querySelectorAll(`.${node.classList[0]} [data-testid="cellInnerDiv"]:not([textonly])`)
                    if (tweetPosts.length > 0) {
                        tweetPosts.forEach(el => {
                            const isValidVideo = el.querySelectorAll('[aria-label="Embedded video"]').length > 0;
                            const isValidImg = el.querySelectorAll('[alt="Image"]').length > 0;
                            const isValidGif = el.querySelectorAll('[aria-label="Play this GIF"]').length > 0;

                            if (isValidVideo) {
                                el.style.display = "none";
                                el.setAttribute("textonly", "true");
                                return;
                            }
                            if (isValidImg) {
                                el.style.display = "none";
                                el.setAttribute("textonly", "true");
                                return;
                            }
                            if (isValidGif) {
                                el.style.display = "none";
                                el.setAttribute("textonly", "true");
                                return;
                            }
                        })
                    }
                }

                if (!isStyleInjected) {
                    // Append the <style> element to the <head> of the document
                    injectCss();
                }
                
            }
            
        }
    };
})();