Greasy Fork is available in English.
Removes all text from tweets, leaving only the pictures & videos.
当前为
// ==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()