Greasy Fork

Greasy Fork is available in English.

Twitter & X - Media only mode

Removes all text from tweets, leaving only the pictures & videos.

当前为 2025-03-15 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Twitter & X - Media only mode
// @namespace    https://github.com/xcloudx01
// @version      1
// @description  Removes all text from tweets, leaving only the pictures & videos.
// @author       xcloudx01
// @match        https://twitter.com/*
// @match        https://twitter.com/i/timeline
// @match        https://twitter.com/*/status/*
// @match        https://x.com/*
// @match        https://x.com/i/timeline
// @match        https://x.com/*/status/*
// @exclude      https://twitter.com/messages/*
// @exclude      https://x.com/messages/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant        none
// @license MIT
// ==/UserScript==

const tweetClass = 'article.css-175oi2r.r-18u37iz.r-1udh08x.r-1c4vpko.r-1c7gwzm.r-o7ynqc.r-6416eg.r-1ny4l3l.r-1loqt21[data-testid="tweet"]'
const expandTweetClass = '.css-146c3p1.r-bcqeeo.r-1ttztb7.r-qvutc0.r-1qd0xha.r-a023e6.r-rjixqe.r-16dba41.r-1loqt21[data-testid="tweet-text-show-more-link"]' // "Show More" link on tweets.

function remove_tweet_text(tweet) {
  let textElement = tweet.querySelector('[data-testid="tweetText"]')
  if (textElement == null)
    return
  else
    textElement.remove()
}


function remove_elements() {
  let tweets = document.querySelectorAll(tweetClass)
  if (tweets.length > 0) {
    for(let i=0; i<tweets.length; i++) {
        remove_tweet_text(tweets[i])
      }
  }

  let expandTweetElements = document.querySelectorAll(expandTweetClass)
  if (expandTweetElements.length > 0) {
    for(let i=0; i<expandTweetElements.length; i++) {
        expandTweetElements[i].remove()
      }
  }
}

// MAIN
// TODO: Make this an observer instead of a loop for optomization.
function mainLoop() {
    setTimeout(function() {
        let currentUrl = window.location.href
        if (!currentUrl.includes("notifications") && !currentUrl.includes("status")) {
          remove_elements()
        }
        mainLoop()
    }, 50) // <- too high causes scrolling down to stutter back upwards.
}

mainLoop()