Twitter: view more replies and remove useless sections

View more replies and remove shit from twitter

当前为 2021-12-28 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name          Twitter: view more replies and remove useless sections
// @description   View more replies and remove shit from twitter
// @author        MK
// @namespace     max44
// @homepage      https://greasyfork.org/en/users/309172-max44
// @include       https://twitter.com/*
// @include       https://mobile.twitter.com/*
// @icon          https://www.google.com/s2/favicons?domain=twitter.com
// @version       1.5
// @license       MIT
// @require       https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @grant         none
// @run-at        document-idle
// ==/UserScript==

(function () {
  'use strict';

  const config = {childList: true, subtree: true};

  /*setTimeout(function () {
    if (preview != null) {
    }
  }, 3000);*/

  const rootCallback = function (mutationsList, observer) {
    //Show more
    $( "div[role='button'][tabindex='0'] > div > div > span:contains('Show more replies')" ).click(); //"Show more replies" button
    $( "div[role='button'][tabindex='0'] > div > span > span:contains('Show')" ).click(); //"Show additional replies, including those that may contain offensive content" button

    //Hide useless sections
    $( "aside[aria-label='Who to follow']" ).parent().hide(); //At the newsfeed
    $( "div[style='-webkit-line-clamp: 3;'] > span:contains('Who to follow')" ).parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //At anybody's profile - hide header "Who to follow", then 3 suggestions, "Show more" and divider
    $( "div[aria-label='Timeline: Trending now']" ).parent().parent().parent().parent().hide(); //At the newsfeed
    $( "div[style='-webkit-line-clamp: 3;'] > span:contains('Topics to follow')" ).parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide(); //At anybody's profile
    $( "div[style='-webkit-line-clamp: 3;'] > span:contains('Discover new Lists')" ).parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().hide(); //At the newsfeed
    $( "div[aria-label='Open app']" ).parent().hide(); //At any tweet on mobile browser

    //$( "article span:contains('Promoted')" ).parent().parent().parent().parent().parent().hide().next().hide().next().hide();
    //$( "span:contains('Promoted by')" ).parent().parent().parent().parent().hide().next().hide().next().hide();
    //$( "span:contains('Promoted Tweet')" ).parent().parent().parent().hide();
    //$( "span:contains('Promoted')" ).parent().parent().parent().parent().hide();
    //$( "span:contains('Expand your timeline with Topics')" ).parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().hide();
    //$( "div[aria-label='Set as not interested']" ).parent().parent().parent().parent().parent().parent().parent().hide();
  };

  const rootNode = document.querySelector("#react-root");
  if (rootNode != null) {
    const rootObserver = new MutationObserver(rootCallback);
    rootObserver.observe(rootNode, config);
  }

})();