Twitter: view more replies and remove useless sections

View more replies and remove useless sections from twitter

当前为 2022-08-02 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Twitter: view more replies and remove useless sections
  3. // @description View more replies and remove useless sections from twitter
  4. // @author MK
  5. // @namespace max44
  6. // @homepage https://gf.qytechs.cn/en/users/309172-max44
  7. // @match *://twitter.com/*
  8. // @match *://mobile.twitter.com/*
  9. // @icon https://www.google.com/s2/favicons?domain=twitter.com
  10. // @version 1.7.8
  11. // @license MIT
  12. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
  13. // @grant none
  14. // @run-at document-idle
  15. // ==/UserScript==
  16.  
  17. (function () {
  18. 'use strict';
  19.  
  20. const config = {childList: true, subtree: true};
  21.  
  22. const rootCallback = function (mutationsList, observer) {
  23. // setInterval(function() { //Check page content constantly
  24. //==== ENGLISH INTERFACE
  25. //Show more
  26. $( "div[role='button'][tabindex='0'] > div > div > div > span:contains('Show replies')" ).click(); //"Show replies" button
  27. $( "div[role='button'][tabindex='0'] > div > div > span:contains('Show more replies')" ).click(); //"Show more replies" button
  28. $( "div[role='button'][tabindex='0'] > div > span > span:contains('Show')" ).click(); //"Show additional replies, including those that may contain offensive content" button
  29.  
  30. //Hide useless sections
  31. $( "aside[aria-label='Who to follow']" ).parent().hide(); //"Who to follow" - at the newsfeed (right column)
  32. $( "div > div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('Who to follow')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //"Who to follow" - at anybody's profile
  33. $( "section[role='region'] > div[aria-label='Timeline: Trending now']" ).parent().parent().hide(); //"Trends for you" - at the newsfeed (right column)
  34. $( "div > div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('What's happening')" ).parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().hide(); //"What's happening" - at the newsfeed (right column)
  35. $( "div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('Trends for you')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //"Trends for you" - at 'Explore' page
  36. $( "div > div > div > div > div > h1 > span:contains('You seem to be in a new location')" ).parent().parent().parent().parent().parent().parent().hide(); //"You seem to be in a new location" - at 'Explore' page
  37. $( "div > div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('Topics to follow')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide(); //"Topics to follow" - at anybody's profile
  38. $( "div[style='-webkit-line-clamp: 3;'] > span:contains('Suggested Topics')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide(); //"Suggested topics" - at 'More > Topics' page
  39. $( "div[style='-webkit-line-clamp: 3;'] > span:contains('Discover new Lists')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //"Discover new Lists" - at 'Lists' page
  40. $( "div[style='-webkit-line-clamp: 3;'] > span:contains('Expand your timeline with Topics')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide(); //"Expand your timeline with Topics" - at the newsfeed
  41. //$( "span[aria-label^='Recommended Topic:'] > span > span" ).parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().hide(); //At the newsfeed
  42. $( "div[aria-label='Open app']" ).parent().hide(); //"Open app" - at any tweet on mobile browser
  43. $( "div[data-testid='inlinePrompt'] > h1[role='heading'] > span > span > span:contains('Concerned about your digital security?')" ).parent().parent().parent().parent().parent().parent().parent().hide().next().hide(); //"Digital security" - at the newsfeed
  44. $( "div[data-testid='inlinePrompt'] > h1[role='heading'] > span > span > span:contains('Get the app')" ).parent().parent().parent().parent().parent().parent().parent().hide().next().hide(); //"Get the app" - at the newsfeed
  45. // $( "article span:contains('Promoted')" ).parent().parent().parent().parent().parent().hide().next().hide().next().hide(); //"Promoted" - at ?, active for some regions only
  46. // $( "span:contains('Promoted by')" ).parent().parent().parent().parent().hide().next().hide().next().hide(); //"Promoted by" - at ?, active for some regions only
  47. // $( "span:contains('Promoted Tweet')" ).parent().parent().parent().hide(); //"Promoted Tweet" - at ?, active for some regions only
  48. // $( "span:contains('Promoted')" ).parent().parent().parent().parent().hide(); //"Promoted" - at ?, active for some regions only
  49. // $( "div[aria-label='Set as not interested']" ).parent().parent().parent().parent().parent().parent().parent().hide(); //"Set as non-interested" - at ?, active for some regions only
  50.  
  51. //==== UKRAINIAN INTERFACE
  52. //Show more
  53. $( "div[role='button'][tabindex='0'] > div > div > div > span:contains('Показати відповіді')" ).click(); //"Show replies" button
  54. $( "div[role='button'][tabindex='0'] > div > div > span:contains('Показати більше відповідей')" ).click(); //"Show more replies" button
  55. $( "div[role='button'][tabindex='0'] > div > span > span:contains('Показати')" ).click(); //"Show additional replies, including those that may contain offensive content" button
  56.  
  57. //Hide useless sections
  58. $( "aside[aria-label='Рекомендовані']" ).parent().hide(); //"Who to follow" - at the newsfeed (right column)
  59. $( "div > div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('Рекомендації')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //"Who to follow" - at anybody's profile
  60. $( "section[role='region'] > div[aria-label='Стрічка: Актуальне зараз']" ).parent().parent().hide(); //"Trends for you" - at the newsfeed (right column)
  61. //$( "div > div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('What's happening')" ).parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().hide(); //"What's happening" - at the newsfeed (right column)
  62. $( "div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('Тренди для вас')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //"Trends for you" - at 'Explore' page
  63. $( "div > div > div > div > div > h1 > span:contains('Схоже, ви перебуваєте в новому місці')" ).parent().parent().parent().parent().parent().parent().hide(); //"You seem to be in a new location" - at 'Explore' page
  64. //$( "div > div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('Topics to follow')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide(); //"Topics to follow" - at anybody's profile
  65. //$( "div[style='-webkit-line-clamp: 3;'] > span:contains('Suggested Topics')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide(); //"Suggested topics" - at 'More > Topics' page
  66. //$( "div[style='-webkit-line-clamp: 3;'] > span:contains('Discover new Lists')" ).parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //At the newsfeed
  67. //$( "div[style='-webkit-line-clamp: 3;'] > span:contains('Expand your timeline with Topics')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide(); //"Expand your timeline with Topics" - at the newsfeed
  68. //$( "span[aria-label^='Recommended Topic:'] > span > span" ).parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().hide(); //At the newsfeed
  69. $( "div[aria-label='Відкрити додаток']" ).parent().hide(); //"Open app" - at any tweet on mobile browser
  70. $( "div[data-testid='inlinePrompt'] > h1[role='heading'] > span > span > span:contains('Є сумніви щодо цифрової безпеки?')" ).parent().parent().parent().parent().parent().parent().parent().hide().next().hide(); //"Digital security" - at the newsfeed
  71. //$( "div[data-testid='inlinePrompt'] > h1[role='heading'] > span > span > span:contains('Get the app')" ).parent().parent().parent().parent().parent().parent().parent().hide().next().hide(); //"Get the app" - at the newsfeed
  72.  
  73. //==== CHINEESE SIMPLIFIED INTERFACE
  74. //Show more
  75. $( "div[role='button'][tabindex='0'] > div > div > div > span:contains('显示回复')" ).click(); //"Show replies" button
  76. $( "div[role='button'][tabindex='0'] > div > div > span:contains('显示更多回复')" ).click(); //"Show more replies" button
  77. $( "div[role='button'][tabindex='0'] > div > span > span:contains('显示')" ).click(); //"Show additional replies, including those that may contain offensive content" button
  78.  
  79. //Hide useless sections
  80. $( "aside[aria-label='推荐关注']" ).parent().hide(); //"Who to follow" - at the newsfeed (right column)
  81. $( "div > div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('推荐关注')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //"Who to follow" - at anybody's profile
  82. $( "section[role='region'] > div[aria-label='Timeline: Trending now']" ).parent().parent().hide(); //"Trends for you" - at the newsfeed (right column)
  83. //$( "div > div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('What's happening')" ).parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().hide(); //"What's happening" - at the newsfeed (right column)
  84. $( "div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('你的趋势')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //"Trends for you" - at 'Explore' page
  85. $( "div > div > div > div > div > h1 > span:contains('你似乎到了一个新位置')" ).parent().parent().parent().parent().parent().parent().hide(); //"You seem to be in a new location" - at 'Explore' page
  86. //$( "div > div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('Topics to follow')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide(); //"Topics to follow" - at anybody's profile
  87. //$( "div[style='-webkit-line-clamp: 3;'] > span:contains('Suggested Topics')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide(); //"Suggested topics" - at 'More > Topics' page
  88. //$( "div[style='-webkit-line-clamp: 3;'] > span:contains('Discover new Lists')" ).parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //At the newsfeed
  89. //$( "div[style='-webkit-line-clamp: 3;'] > span:contains('Expand your timeline with Topics')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide(); //"Expand your timeline with Topics" - at the newsfeed
  90. //$( "span[aria-label^='Recommended Topic:'] > span > span" ).parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().hide(); //At the newsfeed
  91. $( "div[aria-label='打开应用']" ).parent().hide(); //"Open app" - at any tweet on mobile browser
  92. //$( "div[data-testid='inlinePrompt'] > h1[role='heading'] > span > span > span:contains('Concerned about your digital security?')" ).parent().parent().parent().parent().parent().parent().parent().hide().next().hide(); //"Digital security" - at the newsfeed
  93. //$( "div[data-testid='inlinePrompt'] > h1[role='heading'] > span > span > span:contains('Get the app')" ).parent().parent().parent().parent().parent().parent().parent().hide().next().hide(); //"Get the app" - at the newsfeed
  94.  
  95. //==== CHINEESE TRADITIONAL INTERFACE
  96. //Show more
  97. $( "div[role='button'][tabindex='0'] > div > div > div > span:contains('顯示回覆')" ).click(); //"Show replies" button
  98. $( "div[role='button'][tabindex='0'] > div > div > span:contains('顯示更多回覆')" ).click(); //"Show more replies" button
  99. $( "div[role='button'][tabindex='0'] > div > span > span:contains('顯示')" ).click(); //"Show additional replies, including those that may contain offensive content" button
  100.  
  101. //Hide useless sections
  102. $( "aside[aria-label='跟隨誰']" ).parent().hide(); //"Who to follow" - at the newsfeed (right column)
  103. $( "div > div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('跟隨誰')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //"Who to follow" - at anybody's profile
  104. $( "section[role='region'] > div[aria-label='時間軸:流行趨勢']" ).parent().parent().hide(); //"Trends for you" - at the newsfeed (right column)
  105. //$( "div > div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('What's happening')" ).parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().hide(); //"What's happening" - at the newsfeed (right column)
  106. $( "div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('你的流行趨勢')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //"Trends for you" - at 'Explore' page
  107. $( "div > div > div > div > div > h1 > span:contains('你似乎位於新的位置')" ).parent().parent().parent().parent().parent().parent().hide(); //"You seem to be in a new location" - at 'Explore' page
  108. //$( "div > div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('Topics to follow')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide(); //"Topics to follow" - at anybody's profile
  109. //$( "div[style='-webkit-line-clamp: 3;'] > span:contains('Suggested Topics')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide(); //"Suggested topics" - at 'More > Topics' page
  110. //$( "div[style='-webkit-line-clamp: 3;'] > span:contains('Discover new Lists')" ).parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //At the newsfeed
  111. //$( "div[style='-webkit-line-clamp: 3;'] > span:contains('Expand your timeline with Topics')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide(); //"Expand your timeline with Topics" - at the newsfeed
  112. //$( "span[aria-label^='Recommended Topic:'] > span > span" ).parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().hide(); //At the newsfeed
  113. $( "div[aria-label='開啟應用程式']" ).parent().hide(); //"Open app" - at any tweet on mobile browser
  114. //$( "div[data-testid='inlinePrompt'] > h1[role='heading'] > span > span > span:contains('Concerned about your digital security?')" ).parent().parent().parent().parent().parent().parent().parent().hide().next().hide(); //"Digital security" - at the newsfeed
  115. //$( "div[data-testid='inlinePrompt'] > h1[role='heading'] > span > span > span:contains('Get the app')" ).parent().parent().parent().parent().parent().parent().parent().hide().next().hide(); //"Get the app" - at the newsfeed
  116.  
  117. //==== SPANISH INTERFACE
  118. //Show more
  119. $( "div[role='button'][tabindex='0'] > div > div > div > span:contains('Mostrar respuestas')" ).click(); //"Show replies" button
  120. $( "div[role='button'][tabindex='0'] > div > div > span:contains('Mostrar más respuestas')" ).click(); //"Show more replies" button
  121. $( "div[role='button'][tabindex='0'] > div > span > span:contains('Mostrar')" ).click(); //"Show additional replies, including those that may contain offensive content" button
  122.  
  123. //Hide useless sections
  124. $( "aside[aria-label='A quién seguir']" ).parent().hide(); //"Who to follow" - at the newsfeed (right column)
  125. $( "div > div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('A quién seguir')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //"Who to follow" - at anybody's profile
  126. $( "section[role='region'] > div[aria-label='Cronología: Tendencias del momento']" ).parent().parent().hide(); //"Trends for you" - at the newsfeed (right column)
  127. $( "div > div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('Qué está pasando')" ).parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().hide(); //"What's happening" - at the newsfeed (right column)
  128. $( "div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('Tendencias para ti')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //"Trends for you" - at 'Explore' page
  129. $( "div > div > div > div > div > h1 > span:contains('Parece que estás en una nueva ubicación')" ).parent().parent().parent().parent().parent().parent().hide(); //"You seem to be in a new location" - at 'Explore' page
  130. $( "div > div > h2 > div[style='-webkit-line-clamp: 3;'] > span:contains('Temas para seguir')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide(); //"Topics to follow" - at anybody's profile
  131. $( "div[style='-webkit-line-clamp: 3;'] > span:contains('Temas sugeridos')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide(); //"Suggested topics" - at 'More > Topics' page
  132. $( "div[style='-webkit-line-clamp: 3;'] > span:contains('Descubre Listas nuevas')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //"Discover new Lists" - at 'Lists' page
  133. $( "div[style='-webkit-line-clamp: 3;'] > span:contains('Amplía tu cronología con Temas')" ).parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide().next().hide().next().hide(); //At the newsfeed
  134. //$( "div[style='-webkit-line-clamp: 3;'] > span:contains('Amplía tu cronología con Temas')" ).parent().parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide(); //"Expand your timeline with Topics" - at the newsfeed
  135. //$( "span[aria-label^='Recommended Topic:'] > span > span" ).parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().hide(); //At the newsfeed
  136. $( "div[aria-label='Abrir aplicación']" ).parent().hide(); //"Open app" - at any tweet on mobile browser
  137. //$( "div[data-testid='inlinePrompt'] > h1[role='heading'] > span > span > span:contains('Concerned about your digital security?')" ).parent().parent().parent().parent().parent().parent().parent().hide().next().hide(); //"Digital security" - at the newsfeed
  138. //$( "div[data-testid='inlinePrompt'] > h1[role='heading'] > span > span > span:contains('Get the app')" ).parent().parent().parent().parent().parent().parent().parent().hide().next().hide(); //"Get the app" - at the newsfeed
  139. $( "article span:contains('Promocionado')" ).parent().parent().parent().parent().parent().hide().next().hide().next().hide(); //"Promoted" - at ?, active for some regions only
  140. //$( "span:contains('Promoted by')" ).parent().parent().parent().parent().hide().next().hide().next().hide(); //"Promoted by" - at ?, active for some regions only
  141. $( "span:contains('Tweet promocionado')" ).parent().parent().parent().hide(); //"Promoted Tweet" - at ?, active for some regions only
  142. $( "span:contains('Promocionado')" ).parent().parent().parent().parent().hide(); //"Promoted" - at ?, active for some regions only
  143. //$( "div[aria-label='Set as not interested']" ).parent().parent().parent().parent().parent().parent().parent().hide(); //"Set as non-interested" - at ?, active for some regions only
  144.  
  145. // }, 100); //Interval to check page content
  146. };
  147.  
  148. const rootNode = document.querySelector("#react-root");
  149. if (rootNode != null) {
  150. const rootObserver = new MutationObserver(rootCallback);
  151. rootObserver.observe(rootNode, config);
  152. }
  153.  
  154. })();

QingJ © 2025

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