Greasy Fork

Greasy Fork is available in English.

Media only mode for Twitter X & Bluesky

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

当前为 2025-04-07 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Media only mode for Twitter X & Bluesky
// @namespace    https://github.com/xcloudx01
// @version      1.02
// @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/*
// @match        https://bsky.app/*
// @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==


function get_deletable_elements() {
  let postTextelements = document.querySelectorAll('[data-testid="tweetText"], [data-testid="tweet-text-show-more-link"], [data-testid="postText"]');
  let postQuoteelements = Array.from(
    document.querySelectorAll('.css-146c3p1.r-8akbws.r-krxsd3.r-dnmrzs.r-1udh08x.r-1udbk01')
  ).filter(element => element.textContent.trim() !== '') // Bluesky
  return [...postTextelements, ...postQuoteelements]
}


function delete_target_elements() {
  let deletable_elements = get_deletable_elements()
  if (deletable_elements.length > 0) {
    for(let i=0; i<deletable_elements.length; i++) {
        deletable_elements[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") && !currentUrl.includes("messages")) {
          delete_target_elements()
        }
        mainLoop()
    }, 50) // <- too high causes scrolling down to stutter back upwards.
}

mainLoop()