Greasy Fork镜像 支持简体中文。

Hide Reposts on Twitter/X

Automatically hide forwarded content and hide forwarded content when first loaded

目前為 2025-03-11 提交的版本,檢視 最新版本

// ==UserScript==
// @name Hide Reposts on Twitter/X
// @description	Automatically hide forwarded content and hide forwarded content when first loaded
// @name:zh-CN Twitter/X 隐藏转发的帖子
// @description:zh-CN 自动隐藏转发转发内容,并且在首次加载时隐藏转发内容,移除烦人的广告
// @author             Owyn,人民的勤务员 <[email protected]>
// @namespace    https://github.com/ChinaGodMan/UserScripts
// @supportURL    https://github.com/ChinaGodMan/UserScripts/issues
// @homepageURL   https://github.com/ChinaGodMan/UserScripts
// @license      MIT
// @icon https://raw.githubusercontent.com/ChinaGodMan/UserScriptsHistory/main/scriptsIcon/x.svg
// @compatible     chrome
// @compatible     firefox
// @compatible     edge
// @compatible     opera
// @compatible     safari
// @compatible     kiwi
// @compatible     qq
// @compatible     via
// @compatible      brave
// @grant		GM_registerMenuCommand
// @noframes
// @run-at		document-end
// @sandbox		JavaScript
// @match		https://x.com/*
// @match		https://twitter.com/*
// @version         2025.03.11.0654
// @created         2025-03-11 06:54:32
// @modified        2025-03-11 06:54:32
// ==/UserScript==
/**
 * File: twitter-hide-reposts.user.js
 * Project: UserScripts
 * File Created: 2025/03/11,Tuesday 06:55:14
 * Author: 人民的勤务员@ChinaGodMan ([email protected])
 * -----
 * Last Modified: 2025/03/11,Tuesday 08:28:39
 * Modified By: 人民的勤务员@ChinaGodMan ([email protected])
 * -----
 * License: MIT License
 * Copyright © 2024 - 2025 ChinaGodMan,Inc
 */
'use strict'

const tweetCSS = '[data-testid="cellInnerDiv"]'
const repostCSS = '[data-testid="socialContext"]'
const alreadyHiddenCSS = '[style*="display: none;"]'

function hideReposts() {
    var n = document.querySelectorAll(tweetCSS + ':has(' + repostCSS + '):not(' + alreadyHiddenCSS + ')')
    for (let i = 0; i < n.length; i++) {
        n[i].style.display = 'none'
        console.debug('hid a repost')
    }
    setTimeout(hideReposts, 500)
}
hideReposts()
window.addEventListener('scroll', hideReposts)

if (typeof GM_registerMenuCommand !== 'undefined') {
    GM_registerMenuCommand('Disable (this once for this page)', () => window.removeEventListener('scroll', hideReposts), 'h')
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址