Twitter: expand tweets automaticly

For Tweets which have the "show more" Button this Script will click this button automaticly & it will remove the lineclamp on quoted tweets

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Twitter: expand tweets automaticly
// @version      0.1
// @description  For Tweets which have the "show more" Button this Script will click this button automaticly & it will remove the lineclamp on quoted tweets
// @author       Schubsi
// @license      MIT
// @match        https://twitter.com/*
// @match        https://x.com/*
// @namespace https://greasyfork.org/users/1493523
// ==/UserScript==

(function () {
  "use strict";

  const autoShowMore = (tweet) => {
    const showMoreBtn = tweet.querySelector(
      "button[data-testid='tweet-text-show-more-link']"
    );
    if (showMoreBtn) showMoreBtn.click();

    const quotedTweet = tweet.querySelector("div[id^='id__'][aria-labelledby^='id__']");
    if (!quotedTweet) return;
    const quotedText = quotedTweet.querySelector(
      "div[data-testid='tweetText']"
    );
    if (!quotedText) return;
    quotedText.style.removeProperty("-webkit-line-clamp");
  };

  const processTweets = () => {
    document.querySelectorAll("article").forEach((tweet) => {
      autoShowMore(tweet);
    });
  };

  const observer = new MutationObserver(() => {
    processTweets();
  });

  window.addEventListener("load", () => {
    processTweets();
    observer.observe(document.body, { childList: true, subtree: true });
  });
})();