Control Panel for Twitter

Gives you more control over Twitter and adds missing features and UI improvements

当前为 2025-01-29 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Control Panel for Twitter
  3. // @description Gives you more control over Twitter and adds missing features and UI improvements
  4. // @icon https://raw.githubusercontent.com/insin/control-panel-for-twitter/master/icons/icon32.png
  5. // @namespace https://github.com/insin/control-panel-for-twitter/
  6. // @match https://twitter.com/*
  7. // @match https://mobile.twitter.com/*
  8. // @match https://x.com/*
  9. // @match https://mobile.x.com/*
  10. // @run-at document-start
  11. // @version 183
  12. // ==/UserScript==
  13. void function() {
  14.  
  15. let debug = false
  16.  
  17. /** @type {boolean} */
  18. let desktop
  19. /** @type {boolean} */
  20. let mobile
  21. let isSafari = navigator.userAgent.includes('Safari/') && !/Chrom(e|ium)\//.test(navigator.userAgent)
  22.  
  23. /** @type {HTMLHtmlElement} */
  24. let $html
  25. /** @type {HTMLElement} */
  26. let $body
  27. /** @type {HTMLElement} */
  28. let $reactRoot
  29. /** @type {string} */
  30. let lang
  31. /** @type {string} */
  32. let dir
  33. /** @type {boolean} */
  34. let ltr
  35.  
  36. //#region Default config
  37. /**
  38. * @type {import("./types").Config}
  39. */
  40. const config = {
  41. debug: false,
  42. // Shared
  43. addAddMutedWordMenuItem: true,
  44. alwaysUseLatestTweets: true,
  45. defaultToLatestSearch: false,
  46. disableHomeTimeline: false,
  47. disabledHomeTimelineRedirect: 'notifications',
  48. disableTweetTextFormatting: false,
  49. dontUseChirpFont: false,
  50. dropdownMenuFontWeight: true,
  51. fastBlock: true,
  52. followButtonStyle: 'monochrome',
  53. hideAdsNav: true,
  54. hideBlueReplyFollowedBy: false,
  55. hideBlueReplyFollowing: false,
  56. hideBookmarkButton: false,
  57. hideBookmarkMetrics: true,
  58. hideBookmarksNav: false,
  59. hideCommunitiesNav: false,
  60. hideExplorePageContents: true,
  61. hideFollowingMetrics: true,
  62. hideForYouTimeline: true,
  63. hideGrokNav: true,
  64. hideInlinePrompts: true,
  65. hideJobsNav: true,
  66. hideLikeMetrics: true,
  67. hideListsNav: false,
  68. hideMetrics: false,
  69. hideMonetizationNav: true,
  70. hideMoreTweets: true,
  71. hideProfileRetweets: false,
  72. hideQuoteTweetMetrics: true,
  73. hideQuotesFrom: [],
  74. hideReplyMetrics: true,
  75. hideRetweetMetrics: true,
  76. hideSeeNewTweets: false,
  77. hideShareTweetButton: false,
  78. hideSubscriptions: true,
  79. hideTimelineTweetBox: false,
  80. hideTotalTweetsMetrics: true,
  81. hideTweetAnalyticsLinks: false,
  82. hideTwitterBlueReplies: false,
  83. hideTwitterBlueUpsells: true,
  84. hideUnavailableQuoteTweets: true,
  85. hideVerifiedNotificationsTab: true,
  86. hideViews: true,
  87. hideWhoToFollowEtc: true,
  88. listRetweets: 'ignore',
  89. mutableQuoteTweets: true,
  90. mutedQuotes: [],
  91. quoteTweets: 'ignore',
  92. reducedInteractionMode: false,
  93. restoreLinkHeadlines: true,
  94. replaceLogo: true,
  95. restoreOtherInteractionLinks: false,
  96. restoreQuoteTweetsLink: true,
  97. retweets: 'separate',
  98. showBlueReplyFollowersCountAmount: '1000000',
  99. showBlueReplyFollowersCount: false,
  100. showBlueReplyVerifiedAccounts: false,
  101. showBookmarkButtonUnderFocusedTweets: true,
  102. sortReplies: 'relevant',
  103. tweakNewLayout: false,
  104. tweakQuoteTweetsPage: true,
  105. twitterBlueChecks: 'replace',
  106. unblurSensitiveContent: false,
  107. uninvertFollowButtons: true,
  108. // Experiments
  109. // none currently
  110. // Desktop only
  111. fullWidthContent: false,
  112. fullWidthMedia: true,
  113. hideAccountSwitcher: false,
  114. hideExploreNav: true,
  115. hideExploreNavWithSidebar: true,
  116. hideMessagesDrawer: true,
  117. hideProNav: true,
  118. hideSidebarContent: true,
  119. hideSpacesNav: false,
  120. navBaseFontSize: true,
  121. navDensity: 'default',
  122. showRelevantPeople: false,
  123. // Mobile only
  124. hideMessagesBottomNavItem: false,
  125. }
  126. //#endregion
  127.  
  128. //#region Locales
  129. /**
  130. * @type {Record<string, import("./types").Locale>}
  131. */
  132. const locales = {
  133. 'ar-x-fm': {
  134. ADD_MUTED_WORD: 'اضافة كلمة مكتومة',
  135. GROK_ACTIONS: 'إجراءات Grok',
  136. HOME: 'الرئيسيّة',
  137. LIKES: 'الإعجابات',
  138. MOST_RELEVANT: 'الأكثر ملائمة',
  139. MUTE_THIS_CONVERSATION: 'كتم هذه المحادثه',
  140. POST_ALL: 'نشر الكل',
  141. POST_UNAVAILABLE: 'هذا المنشور غير متاح.',
  142. PROFILE_SUMMARY: 'ملخص الملف الشخصيّ',
  143. QUOTES: 'اقتباسات',
  144. QUOTE_TWEET: 'اقتباس التغريدة',
  145. QUOTE_TWEETS: 'تغريدات اقتباس',
  146. REPOST: 'إعادة النشر',
  147. REPOSTS: 'المنشورات المُعاد نشرها',
  148. RETWEET: 'إعادة التغريد',
  149. RETWEETED_BY: 'مُعاد تغريدها بواسطة',
  150. RETWEETS: 'إعادات التغريد',
  151. SHARED: 'مشترك',
  152. SHARED_TWEETS: 'التغريدات المشتركة',
  153. SHOW: 'إظهار',
  154. SHOW_MORE_REPLIES: 'عرض المزيد من الردود',
  155. SORT_REPLIES: 'فرز الردود',
  156. TURN_OFF_QUOTE_TWEETS: 'تعطيل تغريدات اقتباس',
  157. TURN_OFF_RETWEETS: 'تعطيل إعادة التغريد',
  158. TURN_ON_RETWEETS: 'تفعيل إعادة التغريد',
  159. TWEET: 'غرّدي',
  160. TWEETS: 'التغريدات',
  161. TWEET_ALL: 'تغريد الكل',
  162. TWEET_INTERACTIONS: 'تفاعلات التغريدة',
  163. TWEET_YOUR_REPLY: 'التغريد بردك!',
  164. TWITTER: 'تويتر',
  165. UNDO_RETWEET: 'التراجع عن التغريدة',
  166. VIEW: 'عرض',
  167. WHATS_HAPPENING: 'ما الذي يحدث؟',
  168. },
  169. ar: {
  170. ADD_MUTED_WORD: 'اضافة كلمة مكتومة',
  171. GROK_ACTIONS: 'إجراءات Grok',
  172. HOME: 'الرئيسيّة',
  173. LIKES: 'الإعجابات',
  174. MOST_RELEVANT: 'الأكثر ملائمة',
  175. MUTE_THIS_CONVERSATION: 'كتم هذه المحادثه',
  176. POST_ALL: 'نشر الكل',
  177. POST_UNAVAILABLE: 'هذا المنشور غير متاح.',
  178. PROFILE_SUMMARY: 'ملخص الملف الشخصيّ',
  179. QUOTE: 'اقتباس',
  180. QUOTES: 'اقتباسات',
  181. QUOTE_TWEET: 'اقتباس التغريدة',
  182. QUOTE_TWEETS: 'تغريدات اقتباس',
  183. REPOST: 'إعادة النشر',
  184. REPOSTS: 'المنشورات المُعاد نشرها',
  185. RETWEET: 'إعادة التغريد',
  186. RETWEETED_BY: 'مُعاد تغريدها بواسطة',
  187. RETWEETS: 'إعادات التغريد',
  188. SHARED: 'مشترك',
  189. SHARED_TWEETS: 'التغريدات المشتركة',
  190. SHOW: 'إظهار',
  191. SHOW_MORE_REPLIES: 'عرض المزيد من الردود',
  192. SORT_REPLIES: 'فرز الردود',
  193. TURN_OFF_QUOTE_TWEETS: 'تعطيل تغريدات اقتباس',
  194. TURN_OFF_RETWEETS: 'تعطيل إعادة التغريد',
  195. TURN_ON_RETWEETS: 'تفعيل إعادة التغريد',
  196. TWEET: 'تغريد',
  197. TWEETS: 'التغريدات',
  198. TWEET_ALL: 'تغريد الكل',
  199. TWEET_INTERACTIONS: 'تفاعلات التغريدة',
  200. TWEET_YOUR_REPLY: 'التغريد بردك!',
  201. UNDO_RETWEET: 'التراجع عن التغريدة',
  202. VIEW: 'عرض',
  203. WHATS_HAPPENING: 'ما الذي يحدث؟',
  204. },
  205. bg: {
  206. ADD_MUTED_WORD: 'Добавяне на заглушена дума',
  207. GROK_ACTIONS: 'Действия, свързани с Grok',
  208. HOME: 'Начало',
  209. LIKES: 'Харесвания',
  210. MOST_RELEVANT: 'Най-подходящи',
  211. MUTE_THIS_CONVERSATION: 'Заглушаване на разговора',
  212. POST_ALL: 'Публикуване на всичко',
  213. POST_UNAVAILABLE: 'Тази публикация не е налична.',
  214. PROFILE_SUMMARY: 'Резюме на профила',
  215. QUOTE: 'Цитат',
  216. QUOTES: 'Цитати',
  217. QUOTE_TWEET: 'Цитиране на туита',
  218. QUOTE_TWEETS: 'Туитове с цитат',
  219. REPOST: 'Препубликуване',
  220. REPOSTS: 'Препубликувания',
  221. RETWEET: 'Ретуитване',
  222. RETWEETED_BY: 'Ретуитнат от',
  223. RETWEETS: 'Ретуитове',
  224. SHARED: 'Споделен',
  225. SHARED_TWEETS: 'Споделени туитове',
  226. SHOW: 'Показване',
  227. SHOW_MORE_REPLIES: 'Показване на още отговори',
  228. SORT_REPLIES: 'Сортиране на отговорите',
  229. TURN_OFF_QUOTE_TWEETS: 'Изключване на туитове с цитат',
  230. TURN_OFF_RETWEETS: 'Изключване на ретуитовете',
  231. TURN_ON_RETWEETS: 'Включване на ретуитовете',
  232. TWEET: 'Туит',
  233. TWEETS: 'Туитове',
  234. TWEET_ALL: 'Туитване на всички',
  235. TWEET_INTERACTIONS: 'Интеракции с туит',
  236. TWEET_YOUR_REPLY: 'Отговори с туит!',
  237. UNDO_RETWEET: 'Отмяна на ретуитването',
  238. VIEW: 'Преглед',
  239. WHATS_HAPPENING: 'Какво се случва?',
  240. },
  241. bn: {
  242. ADD_MUTED_WORD: 'নীরব করা শব্দ যোগ করুন',
  243. GROK_ACTIONS: 'Grok কার্যকলাপ',
  244. HOME: 'হোম',
  245. LIKES: 'পছন্দ',
  246. MOST_RELEVANT: 'সবচেয়ে প্রাসঙ্গিক',
  247. MUTE_THIS_CONVERSATION: 'এই কথা-বার্তা নীরব করুন',
  248. POST_ALL: 'সবকটি পোস্ট করুন',
  249. POST_UNAVAILABLE: 'এই পোস্টটি অনুপলভ্য।',
  250. PROFILE_SUMMARY: 'প্রোফাইল সারসংক্ষেপ',
  251. QUOTE: 'উদ্ধৃতি',
  252. QUOTES: 'উদ্ধৃতিগুলো',
  253. QUOTE_TWEET: 'টুইট উদ্ধৃত করুন',
  254. QUOTE_TWEETS: 'টুইট উদ্ধৃতিগুলো',
  255. REPOST: 'রিপোস্ট',
  256. REPOSTS: 'রিপোস্ট',
  257. RETWEET: 'পুনঃটুইট',
  258. RETWEETED_BY: 'পুনঃ টুইট করেছেন',
  259. RETWEETS: 'পুনঃটুইটগুলো',
  260. SHARED: 'ভাগ করা',
  261. SHARED_TWEETS: 'ভাগ করা টুইটগুলি',
  262. SHOW: 'দেখান',
  263. SHOW_MORE_REPLIES: 'আরও উত্তর দেখান',
  264. SORT_REPLIES: 'উত্তরগুলো বাছুন',
  265. TURN_OFF_QUOTE_TWEETS: 'উদ্ধৃতি টুইটগুলি বন্ধ করুন',
  266. TURN_OFF_RETWEETS: 'পুনঃ টুইটগুলি বন্ধ করুন',
  267. TURN_ON_RETWEETS: 'পুনঃ টুইটগুলি চালু করুন',
  268. TWEET: 'টুইট',
  269. TWEETS: 'টুইটগুলি',
  270. TWEET_ALL: 'সব টুইট করুন',
  271. TWEET_INTERACTIONS: 'টুইট ইন্টারেকশন',
  272. TWEET_YOUR_REPLY: 'আপনার উত্তর টুইট করুন!',
  273. TWITTER: 'টুইটার',
  274. UNDO_RETWEET: 'পুনঃ টুইট পুর্বাবস্থায় ফেরান',
  275. VIEW: 'দেখুন',
  276. WHATS_HAPPENING: 'কি ঘটছে?',
  277. },
  278. ca: {
  279. ADD_MUTED_WORD: 'Afegeix una paraula silenciada',
  280. GROK_ACTIONS: 'Accions de Grok',
  281. HOME: 'Inici',
  282. LIKES: 'Agradaments',
  283. MOST_RELEVANT: 'El més rellevant',
  284. MUTE_THIS_CONVERSATION: 'Silencia la conversa',
  285. POST_ALL: 'Publica-ho tot',
  286. POST_UNAVAILABLE: 'Aquesta publicació no està disponible.',
  287. PROFILE_SUMMARY: 'Resum del perfil',
  288. QUOTE: 'Cita',
  289. QUOTES: 'Cites',
  290. QUOTE_TWEET: 'Cita el tuit',
  291. QUOTE_TWEETS: 'Tuits amb cita',
  292. REPOST: 'Republicació',
  293. REPOSTS: 'Republicacions',
  294. RETWEET: 'Retuit',
  295. RETWEETED_BY: 'Retuitat per',
  296. RETWEETS: 'Retuits',
  297. SHARED: 'Compartit',
  298. SHARED_TWEETS: 'Tuits compartits',
  299. SHOW: 'Mostra',
  300. SHOW_MORE_REPLIES: 'Mostra més respostes',
  301. SORT_REPLIES: 'Ordena les respostes',
  302. TURN_OFF_QUOTE_TWEETS: 'Desactiva els tuits amb cita',
  303. TURN_OFF_RETWEETS: 'Desactiva els retuits',
  304. TURN_ON_RETWEETS: 'Activa els retuits',
  305. TWEET: 'Tuita',
  306. TWEETS: 'Tuits',
  307. TWEET_ALL: 'Tuita-ho tot',
  308. TWEET_INTERACTIONS: 'Interaccions amb tuits',
  309. TWEET_YOUR_REPLY: 'Tuita la teva resposta',
  310. UNDO_RETWEET: 'Desfés el retuit',
  311. VIEW: 'Mostra',
  312. WHATS_HAPPENING: 'Què està passant?',
  313. },
  314. cs: {
  315. ADD_MUTED_WORD: 'Přidat slovo na seznam skrytých slov',
  316. GROK_ACTIONS: 'Akce funkce Grok',
  317. HOME: 'Hlavní stránka',
  318. LIKES: 'Lajky',
  319. MOST_RELEVANT: 'Nejvíce související',
  320. MUTE_THIS_CONVERSATION: 'Skrýt tuto konverzaci',
  321. POST_ALL: 'Postovat vše',
  322. POST_UNAVAILABLE: 'Tento post není dostupný.',
  323. PROFILE_SUMMARY: 'Souhrn profilu',
  324. QUOTE: 'Citace',
  325. QUOTES: 'Citace',
  326. QUOTE_TWEET: 'Citovat Tweet',
  327. QUOTE_TWEETS: 'Tweety s citací',
  328. REPOSTS: 'Reposty',
  329. RETWEET: 'Retweetnout',
  330. RETWEETED_BY: 'Retweetnuto uživateli',
  331. RETWEETS: 'Retweety',
  332. SHARED: 'Sdílený',
  333. SHARED_TWEETS: 'Sdílené tweety',
  334. SHOW: 'Zobrazit',
  335. SHOW_MORE_REPLIES: 'Zobrazit další odpovědi',
  336. SORT_REPLIES: 'Seřadit odpovědi',
  337. TURN_OFF_QUOTE_TWEETS: 'Vypnout tweety s citací',
  338. TURN_OFF_RETWEETS: 'Vypnout retweety',
  339. TURN_ON_RETWEETS: 'Zapnout retweety',
  340. TWEET: 'Tweetovat',
  341. TWEETS: 'Tweety',
  342. TWEET_ALL: 'Tweetnout vše',
  343. TWEET_INTERACTIONS: 'Tweetovat interakce',
  344. TWEET_YOUR_REPLY: 'Tweetujte svou odpověď!',
  345. UNDO_RETWEET: 'Zrušit Retweet',
  346. VIEW: 'Zobrazit',
  347. WHATS_HAPPENING: 'Co se děje?',
  348. },
  349. da: {
  350. ADD_MUTED_WORD: 'Tilføj skjult ord',
  351. GROK_ACTIONS: 'Grok-handlinger',
  352. HOME: 'Forside',
  353. LIKES: 'Likes',
  354. MOST_RELEVANT: 'Mest relevante',
  355. MUTE_THIS_CONVERSATION: 'Skjul denne samtale',
  356. POST_ALL: 'Post alle',
  357. POST_UNAVAILABLE: 'Denne post er ikke tilgængelig.',
  358. PROFILE_SUMMARY: 'Profilresumé',
  359. QUOTE: 'Citat',
  360. QUOTES: 'Citater',
  361. QUOTE_TWEET: 'Citér Tweet',
  362. QUOTE_TWEETS: 'Citat-Tweets',
  363. RETWEETED_BY: 'Retweetet af',
  364. SHARED: 'Delt',
  365. SHARED_TWEETS: 'Delte tweets',
  366. SHOW: 'Vis',
  367. SHOW_MORE_REPLIES: 'Vis flere svar',
  368. SORT_REPLIES: 'Sortér svar',
  369. TURN_OFF_QUOTE_TWEETS: 'Slå Citat-Tweets fra',
  370. TURN_OFF_RETWEETS: 'Slå Retweets fra',
  371. TURN_ON_RETWEETS: 'Slå Retweets til',
  372. TWEET_ALL: 'Tweet alt',
  373. TWEET_INTERACTIONS: 'Tweet-interaktioner',
  374. TWEET_YOUR_REPLY: 'Tweet dit svar!',
  375. UNDO_RETWEET: 'Fortryd Retweet',
  376. VIEW: 'Vis',
  377. WHATS_HAPPENING: 'Hvad sker der?',
  378. },
  379. de: {
  380. ADD_MUTED_WORD: 'Stummgeschaltetes Wort hinzufügen',
  381. GROK_ACTIONS: 'Grok-Aktionen',
  382. HOME: 'Startseite',
  383. LIKES: 'Gefällt mir',
  384. MOST_RELEVANT: 'Besonders relevant',
  385. MUTE_THIS_CONVERSATION: 'Diese Konversation stummschalten',
  386. POST_ALL: 'Alle posten',
  387. POST_UNAVAILABLE: 'Dieser Post ist nicht verfügbar.',
  388. PROFILE_SUMMARY: 'Kurzprofil',
  389. QUOTE: 'Zitat',
  390. QUOTES: 'Zitate',
  391. QUOTE_TWEET: 'Tweet zitieren',
  392. QUOTE_TWEETS: 'Zitierte Tweets',
  393. REPOST: 'Reposten',
  394. RETWEET: 'Retweeten',
  395. RETWEETED_BY: 'Retweetet von',
  396. SHARED: 'Geteilt',
  397. SHARED_TWEETS: 'Geteilte Tweets',
  398. SHOW: 'Anzeigen',
  399. SHOW_MORE_REPLIES: 'Mehr Antworten anzeigen',
  400. SORT_REPLIES: 'Antworten sortieren',
  401. TURN_OFF_QUOTE_TWEETS: 'Zitierte Tweets ausschalten',
  402. TURN_OFF_RETWEETS: 'Retweets ausschalten',
  403. TURN_ON_RETWEETS: 'Retweets einschalten',
  404. TWEET: 'Twittern',
  405. TWEET_ALL: 'Alle twittern',
  406. TWEET_INTERACTIONS: 'Tweet-Interaktionen',
  407. TWEET_YOUR_REPLY: 'Twittere deine Antwort!',
  408. UNDO_RETWEET: 'Retweet rückgängig machen',
  409. VIEW: 'Anzeigen',
  410. WHATS_HAPPENING: 'Was passiert?',
  411. },
  412. el: {
  413. ADD_MUTED_WORD: 'Προσθήκη λέξης σε σίγαση',
  414. GROK_ACTIONS: 'Δράσεις Grok',
  415. HOME: 'Αρχική σελίδα',
  416. LIKES: '"Μου αρέσει"',
  417. MOST_RELEVANT: 'Πιο σχετική',
  418. MUTE_THIS_CONVERSATION: 'Σίγαση αυτής της συζήτησης',
  419. POST_ALL: 'Δημοσίευση όλων',
  420. POST_UNAVAILABLE: 'Αυτή η ανάρτηση δεν είναι διαθέσιμη.',
  421. PROFILE_SUMMARY: ' Περίληψη προφίλ',
  422. QUOTE: 'Παράθεση',
  423. QUOTES: 'Παραθέσεις',
  424. QUOTE_TWEET: 'Παράθεση Tweet',
  425. QUOTE_TWEETS: 'Tweet με παράθεση',
  426. REPOST: 'Αναδημοσίευση',
  427. REPOSTS: 'Αναδημοσιεύσεις',
  428. RETWEETED_BY: 'Έγινε Retweet από',
  429. RETWEETS: 'Retweet',
  430. SHARED: 'Κοινόχρηστο',
  431. SHARED_TWEETS: 'Κοινόχρηστα Tweets',
  432. SHOW: 'Εμφάνιση',
  433. SHOW_MORE_REPLIES: 'Εμφάνιση περισσότερων απαντήσεων',
  434. SORT_REPLIES: 'Ταξινόμηση απαντήσεων',
  435. TURN_OFF_QUOTE_TWEETS: 'Απενεργοποίηση των tweet με παράθεση',
  436. TURN_OFF_RETWEETS: 'Απενεργοποίηση των Retweet',
  437. TURN_ON_RETWEETS: 'Ενεργοποίηση των Retweet',
  438. TWEETS: 'Tweet',
  439. TWEET_ALL: 'Δημοσίευση όλων ως Tweet',
  440. TWEET_INTERACTIONS: 'Αλληλεπιδράσεις με tweet',
  441. TWEET_YOUR_REPLY: 'Στείλτε την απάντησή σας!',
  442. UNDO_RETWEET: 'Αναίρεση Retweet',
  443. VIEW: 'Προβολή',
  444. WHATS_HAPPENING: 'Τι συμβαίνει;',
  445. },
  446. en: {
  447. ADD_MUTED_WORD: 'Add muted word',
  448. GROK_ACTIONS: 'Grok actions',
  449. HOME: 'Home',
  450. LIKES: 'Likes',
  451. MOST_RELEVANT: 'Most relevant',
  452. MUTE_THIS_CONVERSATION: 'Mute this conversation',
  453. POST_ALL: 'Post all',
  454. POST_UNAVAILABLE: 'This post is unavailable.',
  455. PROFILE_SUMMARY: 'Profile Summary',
  456. QUOTE: 'Quote',
  457. QUOTES: 'Quotes',
  458. QUOTE_TWEET: 'Quote Tweet',
  459. QUOTE_TWEETS: 'Quote Tweets',
  460. REPOST: 'Repost',
  461. REPOSTS: 'Reposts',
  462. RETWEET: 'Retweet',
  463. RETWEETED_BY: 'Retweeted by',
  464. RETWEETS: 'Retweets',
  465. SHARED: 'Shared',
  466. SHARED_TWEETS: 'Shared Tweets',
  467. SHOW: 'Show',
  468. SHOW_MORE_REPLIES: 'Show more replies',
  469. SORT_REPLIES: 'Sort replies',
  470. TURN_OFF_QUOTE_TWEETS: 'Turn off Quote Tweets',
  471. TURN_OFF_RETWEETS: 'Turn off Retweets',
  472. TURN_ON_RETWEETS: 'Turn on Retweets',
  473. TWEET: 'Tweet',
  474. TWEETS: 'Tweets',
  475. TWEET_ALL: 'Tweet all',
  476. TWEET_INTERACTIONS: 'Tweet interactions',
  477. TWEET_YOUR_REPLY: 'Tweet your reply!',
  478. TWITTER: 'Twitter',
  479. UNDO_RETWEET: 'Undo Retweet',
  480. VIEW: 'View',
  481. WHATS_HAPPENING: "What's happening?",
  482. },
  483. es: {
  484. ADD_MUTED_WORD: 'Añadir palabra silenciada',
  485. GROK_ACTIONS: 'Acciones de Grok',
  486. HOME: 'Inicio',
  487. LIKES: 'Me gusta',
  488. MOST_RELEVANT: 'Más relevantes',
  489. MUTE_THIS_CONVERSATION: 'Silenciar esta conversación',
  490. POST_ALL: 'Postear todo',
  491. POST_UNAVAILABLE: 'Este post no está disponible.',
  492. PROFILE_SUMMARY: 'Resumen del perfil',
  493. QUOTE: 'Cita',
  494. QUOTES: 'Citas',
  495. QUOTE_TWEET: 'Citar Tweet',
  496. QUOTE_TWEETS: 'Tweets citados',
  497. REPOST: 'Repostear',
  498. RETWEET: 'Retwittear',
  499. RETWEETED_BY: 'Retwitteado por',
  500. SHARED: 'Compartido',
  501. SHARED_TWEETS: 'Tweets compartidos',
  502. SHOW: 'Mostrar',
  503. SHOW_MORE_REPLIES: 'Mostrar más respuestas',
  504. SORT_REPLIES: 'Organizar respuestas',
  505. TURN_OFF_QUOTE_TWEETS: 'Desactivar tweets citados',
  506. TURN_OFF_RETWEETS: 'Desactivar Retweets',
  507. TURN_ON_RETWEETS: 'Activar Retweets',
  508. TWEET: 'Twittear',
  509. TWEET_ALL: 'Twittear todo',
  510. TWEET_INTERACTIONS: 'Interacciones con Tweet',
  511. TWEET_YOUR_REPLY: '¡Twittea tu respuesta!',
  512. UNDO_RETWEET: 'Deshacer Retweet',
  513. VIEW: 'Ver',
  514. WHATS_HAPPENING: '¿Qué está pasando?',
  515. },
  516. eu: {
  517. ADD_MUTED_WORD: 'Gehitu isilarazitako hitza',
  518. GROK_ACTIONS: 'Grok actions',
  519. HOME: 'Hasiera',
  520. LIKES: 'Atsegiteak',
  521. MUTE_THIS_CONVERSATION: 'Isilarazi elkarrizketa hau',
  522. QUOTE: 'Aipamena',
  523. QUOTES: 'Aipamenak',
  524. QUOTE_TWEET: 'Txioa apaitu',
  525. QUOTE_TWEETS: 'Aipatu txioak',
  526. RETWEET: 'Bertxiotu',
  527. RETWEETED_BY: 'Bertxiotua:',
  528. RETWEETS: 'Bertxioak',
  529. SHARED: 'Partekatua',
  530. SHARED_TWEETS: 'Partekatutako',
  531. SHOW: 'Erakutsi',
  532. SHOW_MORE_REPLIES: 'Erakutsi erantzun gehiago',
  533. TURN_OFF_QUOTE_TWEETS: 'Desaktibatu aipatu txioak',
  534. TURN_OFF_RETWEETS: 'Desaktibatu birtxioak',
  535. TURN_ON_RETWEETS: 'Aktibatu birtxioak',
  536. TWEET: 'Txio',
  537. TWEETS: 'Txioak',
  538. TWEET_ALL: 'Txiotu guztiak',
  539. TWEET_INTERACTIONS: 'Txio elkarrekintzak',
  540. UNDO_RETWEET: 'Desegin birtxiokatzea',
  541. VIEW: 'Ikusi',
  542. WHATS_HAPPENING: 'Zer gertatzen ari da?',
  543. },
  544. fa: {
  545. ADD_MUTED_WORD: 'افزودن واژه خموش‌سازی شده',
  546. GROK_ACTIONS: 'کنش‌های Grok',
  547. HOME: 'خانه',
  548. LIKES: 'پسندها',
  549. MOST_RELEVANT: 'مرتبط‌ترین',
  550. MUTE_THIS_CONVERSATION: 'خموش‌سازی این گفتگو',
  551. POST_ALL: 'پست کردن همه',
  552. POST_UNAVAILABLE: 'این پست دردسترس نیست.',
  553. PROFILE_SUMMARY: 'خلاصه نمایه',
  554. QUOTE: 'نقل‌قول',
  555. QUOTES: 'نقل‌قول‌ها',
  556. QUOTE_TWEET: 'نقل‌توییت',
  557. QUOTE_TWEETS: 'نقل‌توییت‌ها',
  558. REPOST: 'بازپست',
  559. REPOSTS: 'بازپست',
  560. RETWEET: 'بازتوییت',
  561. RETWEETED_BY: 'بازتوییت‌ شد توسط',
  562. RETWEETS: 'بازتوییت‌ها',
  563. SHARED: 'مشترک',
  564. SHARED_TWEETS: 'توییتهای مشترک',
  565. SHOW: 'نمایش',
  566. SHOW_MORE_REPLIES: 'نمایش پاسخ‌های بیشتر',
  567. SORT_REPLIES: 'مرتب‌سازی پاسخ‌ها',
  568. TURN_OFF_QUOTE_TWEETS: 'غیرفعال‌سازی نقل‌توییت‌ها',
  569. TURN_OFF_RETWEETS: 'غیرفعال‌سازی بازتوییت‌ها',
  570. TURN_ON_RETWEETS: 'فعال سازی بازتوییت‌ها',
  571. TWEET: 'توییت',
  572. TWEETS: 'توييت‌ها',
  573. TWEET_ALL: 'توییت به همه',
  574. TWEET_INTERACTIONS: 'تعاملات توییت',
  575. TWEET_YOUR_REPLY: 'پاسختان را توییت کنید!',
  576. TWITTER: 'توییتر',
  577. UNDO_RETWEET: 'لغو بازتوییت',
  578. VIEW: 'مشاهده',
  579. WHATS_HAPPENING: 'چه خبر؟',
  580. },
  581. fi: {
  582. ADD_MUTED_WORD: 'Lisää hiljennetty sana',
  583. GROK_ACTIONS: 'Grok-toiminnat',
  584. HOME: 'Etusivu',
  585. LIKES: 'Tykkäykset',
  586. MOST_RELEVANT: 'Relevanteimmat',
  587. MUTE_THIS_CONVERSATION: 'Hiljennä tämä keskustelu',
  588. POST_ALL: 'Julkaise kaikki',
  589. POST_UNAVAILABLE: 'Tämä julkaisu ei ole saatavilla.',
  590. PROFILE_SUMMARY: 'Profiilin yhteenveto',
  591. QUOTE: 'Lainaa',
  592. QUOTES: 'Lainaukset',
  593. QUOTE_TWEET: 'Twiitin lainaus',
  594. QUOTE_TWEETS: 'Twiitin lainaukset',
  595. REPOST: 'Uudelleenjulkaise',
  596. REPOSTS: 'Uudelleenjulkaisut',
  597. RETWEET: 'Uudelleentwiittaa',
  598. RETWEETED_BY: 'Uudelleentwiitannut',
  599. RETWEETS: 'Uudelleentwiittaukset',
  600. SHARED: 'Jaettu',
  601. SHARED_TWEETS: 'Jaetut twiitit',
  602. SHOW: 'Näytä',
  603. SHOW_MORE_REPLIES: 'Näytä lisää vastauksia',
  604. SORT_REPLIES: 'Lajittele vastaukset',
  605. TURN_OFF_QUOTE_TWEETS: 'Poista twiitin lainaukset käytöstä',
  606. TURN_OFF_RETWEETS: 'Poista uudelleentwiittaukset käytöstä',
  607. TURN_ON_RETWEETS: 'Ota uudelleentwiittaukset käyttöön',
  608. TWEET: 'Twiittaa',
  609. TWEETS: 'Twiitit',
  610. TWEET_ALL: 'Twiittaa kaikki',
  611. TWEET_INTERACTIONS: 'Twiitin vuorovaikutukset',
  612. TWEET_YOUR_REPLY: 'Twiittaa vastauksesi',
  613. UNDO_RETWEET: 'Kumoa uudelleentwiittaus',
  614. VIEW: 'Näytä',
  615. WHATS_HAPPENING: 'Mitä tapahtuu?',
  616. },
  617. fil: {
  618. ADD_MUTED_WORD: 'Idagdag ang naka-mute na salita',
  619. GROK_ACTIONS: 'Mga aksyon ni Grok',
  620. LIKES: 'Mga Gusto',
  621. MOST_RELEVANT: 'Pinakanauugnay',
  622. MUTE_THIS_CONVERSATION: 'I-mute ang usapang ito',
  623. POST_ALL: 'I-post lahat',
  624. POST_UNAVAILABLE: 'Hindi available ang post na Ito.',
  625. PROFILE_SUMMARY: 'Buod ng Profile',
  626. QUOTES: 'Mga Quote',
  627. QUOTE_TWEET: 'Quote na Tweet',
  628. QUOTE_TWEETS: 'Mga Quote na Tweet',
  629. REPOST: 'I-repost',
  630. REPOSTS: '(na) Repost',
  631. RETWEET: 'I-retweet',
  632. RETWEETED_BY: 'Ni-retweet ni',
  633. RETWEETS: 'Mga Retweet',
  634. SHARED: 'Ibinahagi',
  635. SHARED_TWEETS: 'Mga Ibinahaging Tweet',
  636. SHOW: 'Ipakita',
  637. SHOW_MORE_REPLIES: 'Magpakita pa ng mga sagot',
  638. SORT_REPLIES: 'I-sort ang mga reply',
  639. TURN_OFF_QUOTE_TWEETS: 'I-off ang mga Quote na Tweet',
  640. TURN_OFF_RETWEETS: 'I-off ang Retweets',
  641. TURN_ON_RETWEETS: 'I-on ang Retweets',
  642. TWEET: 'Mag-tweet',
  643. TWEETS: 'Mga Tweet',
  644. TWEET_ALL: 'I-tweet lahat',
  645. TWEET_INTERACTIONS: 'Interaksyon sa Tweet',
  646. TWEET_YOUR_REPLY: 'I-Tweet ang sagot mo!',
  647. UNDO_RETWEET: 'Huwag nang I-retweet',
  648. VIEW: 'Tingnan',
  649. WHATS_HAPPENING: 'Anong nangyayari?',
  650. },
  651. fr: {
  652. ADD_MUTED_WORD: 'Ajouter un mot masqué',
  653. GROK_ACTIONS: 'Actions Grok',
  654. HOME: 'Accueil',
  655. LIKES: "J'aime",
  656. MOST_RELEVANT: 'Les plus pertinentes',
  657. MUTE_THIS_CONVERSATION: 'Masquer cette conversation',
  658. POST_ALL: 'Tout poster',
  659. POST_UNAVAILABLE: "Ce post n'est pas disponible.",
  660. PROFILE_SUMMARY: 'Résumé du profil',
  661. QUOTE: 'Citation',
  662. QUOTES: 'Citations',
  663. QUOTE_TWEET: 'Citer le Tweet',
  664. QUOTE_TWEETS: 'Tweets cités',
  665. RETWEET: 'Retweeter',
  666. RETWEETED_BY: 'Retweeté par',
  667. SHARED: 'Partagé',
  668. SHARED_TWEETS: 'Tweets partagés',
  669. SHOW: 'Afficher',
  670. SHOW_MORE_REPLIES: 'Voir plus de réponses',
  671. SORT_REPLIES: 'Trier les réponses',
  672. TURN_OFF_QUOTE_TWEETS: 'Désactiver les Tweets cités',
  673. TURN_OFF_RETWEETS: 'Désactiver les Retweets',
  674. TURN_ON_RETWEETS: 'Activer les Retweets',
  675. TWEET: 'Tweeter',
  676. TWEET_ALL: 'Tout tweeter',
  677. TWEET_INTERACTIONS: 'Interactions avec Tweet',
  678. TWEET_YOUR_REPLY: 'Tweetez votre réponse!',
  679. UNDO_RETWEET: 'Annuler le Retweet',
  680. VIEW: 'Voir',
  681. WHATS_HAPPENING: 'Quoi de neuf ?',
  682. },
  683. ga: {
  684. ADD_MUTED_WORD: 'Cuir focal balbhaithe leis',
  685. GROK_ACTIONS: 'Grok actions',
  686. HOME: 'Baile',
  687. LIKES: 'Thaitin siad seo le',
  688. MUTE_THIS_CONVERSATION: 'Balbhaigh an comhrá seo',
  689. QUOTE: 'Sliocht',
  690. QUOTES: 'Sleachta',
  691. QUOTE_TWEET: 'Cuir Ráiteas Leis',
  692. QUOTE_TWEETS: 'Luaigh Tvuíteanna',
  693. RETWEET: 'Atweetáil',
  694. RETWEETED_BY: 'Atweetáilte ag',
  695. RETWEETS: 'Atweetanna',
  696. SHARED: 'Roinnte',
  697. SHARED_TWEETS: 'Tweetanna Roinnte',
  698. SHOW: 'Taispeáin',
  699. SHOW_MORE_REPLIES: 'Taispeáin tuilleadh freagraí',
  700. TURN_OFF_QUOTE_TWEETS: 'Cas as Luaigh Tvuíteanna',
  701. TURN_OFF_RETWEETS: 'Cas as Atweetanna',
  702. TURN_ON_RETWEETS: 'Cas Atweetanna air',
  703. TWEETS: 'Tweetanna',
  704. TWEET_ALL: 'Tweetáil gach rud',
  705. TWEET_INTERACTIONS: 'Idirghníomhaíochtaí le Tweet',
  706. UNDO_RETWEET: 'Cuir an Atweet ar ceal',
  707. VIEW: 'Breathnaigh',
  708. WHATS_HAPPENING: 'Cad atá ag tarlú?',
  709. },
  710. gl: {
  711. ADD_MUTED_WORD: 'Engadir palabra silenciada',
  712. GROK_ACTIONS: 'Grok actions',
  713. HOME: 'Inicio',
  714. LIKES: 'Gústames',
  715. MUTE_THIS_CONVERSATION: 'Silenciar esta conversa',
  716. QUOTE: 'Cita',
  717. QUOTES: 'Citas',
  718. QUOTE_TWEET: 'Citar chío',
  719. QUOTE_TWEETS: 'Chíos citados',
  720. RETWEET: 'Rechouchiar',
  721. RETWEETED_BY: 'Rechouchiado por',
  722. RETWEETS: 'Rechouchíos',
  723. SHARED: 'Compartido',
  724. SHARED_TWEETS: 'Chíos compartidos',
  725. SHOW: 'Amosar',
  726. SHOW_MORE_REPLIES: 'Amosar máis respostas',
  727. TURN_OFF_QUOTE_TWEETS: 'Desactivar os chíos citados',
  728. TURN_OFF_RETWEETS: 'Desactivar os rechouchíos',
  729. TURN_ON_RETWEETS: 'Activar os rechouchíos',
  730. TWEET: 'Chío',
  731. TWEETS: 'Chíos',
  732. TWEET_ALL: 'Chiar todo',
  733. TWEET_INTERACTIONS: 'Interaccións chío',
  734. UNDO_RETWEET: 'Desfacer rechouchío',
  735. VIEW: 'Ver',
  736. WHATS_HAPPENING: 'Que está pasando?',
  737. },
  738. gu: {
  739. ADD_MUTED_WORD: 'જોડાણ અટકાવેલો શબ્દ ઉમેરો',
  740. GROK_ACTIONS: 'Grok પગલાં',
  741. HOME: 'હોમ',
  742. LIKES: 'લાઈક્સ',
  743. MOST_RELEVANT: 'સૌથી વધુ સુસંગત',
  744. MUTE_THIS_CONVERSATION: 'આ વાર્તાલાપનું જોડાણ અટકાવો',
  745. POST_ALL: 'બધા પોસ્ટ કરો',
  746. POST_UNAVAILABLE: 'આ પોસ્ટ અનુપલબ્ધ છે.',
  747. PROFILE_SUMMARY: 'પ્રોફાઇલ સારાંશ',
  748. QUOTE: 'અવતરણ',
  749. QUOTES: 'અવતરણો',
  750. QUOTE_TWEET: 'અવતરણની સાથે ટ્વીટ કરો',
  751. QUOTE_TWEETS: 'અવતરણની સાથે ટ્વીટ્સ',
  752. REPOST: 'રીપોસ્ટ કરો',
  753. REPOSTS: 'ફરીથી કરવામાં આવેલી પોસ્ટ',
  754. RETWEET: 'પુનટ્વીટ',
  755. RETWEETED_BY: 'આમની દ્વારા પુનટ્વીટ કરવામાં આવી',
  756. RETWEETS: 'પુનટ્વીટ્સ',
  757. SHARED: 'સાંજેડેલું',
  758. SHARED_TWEETS: 'શેર કરેલી ટ્વીટ્સ',
  759. SHOW: 'બતાવો',
  760. SHOW_MORE_REPLIES: 'વધુ પ્રત્યુતરો દર્શાવો',
  761. SORT_REPLIES: 'પ્રત્યુત્તરોને સૉર્ટ કરો',
  762. TURN_OFF_QUOTE_TWEETS: 'અવતરણની સાથે ટ્વીટ્સ બંધ કરો',
  763. TURN_OFF_RETWEETS: 'પુનટ્વીટ્સ બંધ કરો',
  764. TURN_ON_RETWEETS: 'પુનટ્વીટ્સ ચાલુ કરો',
  765. TWEET: 'ટ્વીટ',
  766. TWEETS: 'ટ્વીટ્સ',
  767. TWEET_ALL: 'બધાને ટ્વીટ કરો',
  768. TWEET_INTERACTIONS: 'ટ્વીટ ક્રિયાપ્રતિક્રિયાઓ',
  769. TWEET_YOUR_REPLY: 'તમારા પ્રત્યુત્તરને ટ્વીટ કરો!',
  770. UNDO_RETWEET: 'પુનટ્વીટને પૂર્વવત કરો',
  771. VIEW: 'જુઓ',
  772. WHATS_HAPPENING: 'શું થઈ રહ્યું છે?',
  773. },
  774. he: {
  775. ADD_MUTED_WORD: 'הוסף מילה מושתקת',
  776. GROK_ACTIONS: 'פעולות של Grok',
  777. HOME: 'דף הבית',
  778. LIKES: 'הערות "אהבתי"',
  779. MOST_RELEVANT: 'הכי רלוונטי',
  780. MUTE_THIS_CONVERSATION: 'להשתיק את השיחה הזאת',
  781. POST_ALL: 'פרסום הכל',
  782. POST_UNAVAILABLE: 'פוסט זה אינו זמין.',
  783. PROFILE_SUMMARY: 'סיכום הפרופיל',
  784. QUOTE: 'ציטוט',
  785. QUOTES: 'ציטוטים',
  786. QUOTE_TWEET: 'ציטוט ציוץ',
  787. QUOTE_TWEETS: 'ציוצי ציטוט',
  788. REPOST: 'לפרסם מחדש',
  789. REPOSTS: 'פרסומים מחדש',
  790. RETWEET: 'צייץ מחדש',
  791. RETWEETED_BY: 'צויץ מחדש על־ידי',
  792. RETWEETS: 'ציוצים מחדש',
  793. SHARED: 'משותף',
  794. SHARED_TWEETS: 'ציוצים משותפים',
  795. SHOW: 'הצג',
  796. SHOW_MORE_REPLIES: 'הצג תשובות נוספות',
  797. SORT_REPLIES: 'מיון תשובות',
  798. TURN_OFF_QUOTE_TWEETS: 'כבה ציוצי ציטוט',
  799. TURN_OFF_RETWEETS: 'כבה ציוצים מחדש',
  800. TURN_ON_RETWEETS: 'הפעל ציוצים מחדש',
  801. TWEET: 'צייץ',
  802. TWEETS: 'ציוצים',
  803. TWEET_ALL: 'צייץ הכול',
  804. TWEET_INTERACTIONS: 'אינטראקציות צייץ',
  805. TWEET_YOUR_REPLY: 'צייץ את התשובה!',
  806. TWITTER: 'טוויטר',
  807. UNDO_RETWEET: 'ביטול ציוץ מחדש',
  808. VIEW: 'הצג',
  809. WHATS_HAPPENING: 'מה קורה?',
  810. },
  811. hi: {
  812. ADD_MUTED_WORD: 'म्यूट किया गया शब्द जोड़ें',
  813. GROK_ACTIONS: 'Grok कार्रवाई',
  814. HOME: 'होम',
  815. LIKES: 'पसंद',
  816. MOST_RELEVANT: 'सर्वाधिक प्रासंगिक',
  817. MUTE_THIS_CONVERSATION: 'इस बातचीत को म्यूट करें',
  818. POST_ALL: 'सभी पोस्ट करें',
  819. POST_UNAVAILABLE: 'यह पोस्ट उपलब्ध नहीं है.',
  820. PROFILE_SUMMARY: 'प्रोफ़ाइल सारांश',
  821. QUOTE: 'कोट',
  822. QUOTES: 'कोट',
  823. QUOTE_TWEET: 'ट्वीट क्वोट करें',
  824. QUOTE_TWEETS: 'कोट ट्वीट्स',
  825. REPOST: 'रीपोस्ट',
  826. REPOSTS: 'रीपोस्ट्स',
  827. RETWEET: 'रीट्वीट करें',
  828. RETWEETED_BY: 'इनके द्वारा रीट्वीट किया गया',
  829. RETWEETS: 'रीट्वीट्स',
  830. SHARED: 'साझा किया हुआ',
  831. SHARED_TWEETS: 'साझा किए गए ट्वीट',
  832. SHOW: 'दिखाएं',
  833. SHOW_MORE_REPLIES: 'और अधिक जवाब दिखाएँ',
  834. SORT_REPLIES: 'जवाब सॉर्ट करें',
  835. TURN_OFF_QUOTE_TWEETS: 'कोट ट्वीट्स बंद करें',
  836. TURN_OFF_RETWEETS: 'रीट्वीट बंद करें',
  837. TURN_ON_RETWEETS: 'रीट्वीट चालू करें',
  838. TWEET: 'ट्वीट करें',
  839. TWEETS: 'ट्वीट',
  840. TWEET_ALL: 'सभी ट्वीट करें',
  841. TWEET_INTERACTIONS: 'ट्वीट इंटरैक्शन',
  842. TWEET_YOUR_REPLY: 'अपना जवाब ट्वीट करें!',
  843. UNDO_RETWEET: 'रीट्वीट को पूर्ववत करें',
  844. VIEW: 'देखें',
  845. WHATS_HAPPENING: 'क्या हो रहा है?',
  846. },
  847. hr: {
  848. ADD_MUTED_WORD: 'Dodaj onemogućenu riječ',
  849. GROK_ACTIONS: 'Grokove radnje',
  850. HOME: 'Naslovnica',
  851. LIKES: 'Oznake „sviđa mi se”',
  852. MOST_RELEVANT: 'Najrelevantnije',
  853. MUTE_THIS_CONVERSATION: 'Isključi zvuk ovog razgovora',
  854. POST_ALL: 'Objavi sve',
  855. POST_UNAVAILABLE: 'Ta objava nije dostupna.',
  856. PROFILE_SUMMARY: 'Sažetak profila',
  857. QUOTE: 'Citat',
  858. QUOTES: 'Citati',
  859. QUOTE_TWEET: 'Citiraj Tweet',
  860. QUOTE_TWEETS: 'Citirani tweetovi',
  861. REPOST: 'Proslijedi objavu',
  862. REPOSTS: 'Proslijeđene objave',
  863. RETWEET: 'Proslijedi tweet',
  864. RETWEETED_BY: 'Korisnici koji su proslijedili Tweet',
  865. RETWEETS: 'Proslijeđeni tweetovi',
  866. SHARED: 'Podijeljeno',
  867. SHARED_TWEETS: 'Dijeljeni tweetovi',
  868. SHOW: 'Prikaži',
  869. SHOW_MORE_REPLIES: 'Prikaži još odgovora',
  870. SORT_REPLIES: 'Sortiraj odgovore',
  871. TURN_OFF_QUOTE_TWEETS: 'Isključi citirane tweetove',
  872. TURN_OFF_RETWEETS: 'Isključi proslijeđene tweetove',
  873. TURN_ON_RETWEETS: 'Uključi proslijeđene tweetove',
  874. TWEETS: 'Tweetovi',
  875. TWEET_ALL: 'Tweetaj sve',
  876. TWEET_INTERACTIONS: 'Interakcije s Tweet',
  877. TWEET_YOUR_REPLY: 'Pošaljite Tweet s odgovorom!',
  878. UNDO_RETWEET: 'Poništi prosljeđivanje tweeta',
  879. VIEW: 'Prikaz',
  880. WHATS_HAPPENING: 'Što se događa?',
  881. },
  882. hu: {
  883. ADD_MUTED_WORD: 'Elnémított szó hozzáadása',
  884. GROK_ACTIONS: 'Grok-műveletek',
  885. HOME: 'Kezdőlap',
  886. LIKES: 'Kedvelések',
  887. MOST_RELEVANT: 'Legmegfelelőbb',
  888. MUTE_THIS_CONVERSATION: 'Beszélgetés némítása',
  889. POST_ALL: 'Az összes közzététele',
  890. POST_UNAVAILABLE: 'Ez a bejegyzés nem elérhető.',
  891. PROFILE_SUMMARY: 'Profil összegzése',
  892. QUOTE: 'Idézés',
  893. QUOTES: 'Idézések',
  894. QUOTE_TWEET: 'Tweet idézése',
  895. QUOTE_TWEETS: 'Tweet-idézések',
  896. REPOST: 'Újraposztolás',
  897. REPOSTS: 'Újraposztolások',
  898. RETWEETED_BY: 'Retweetelte',
  899. RETWEETS: 'Retweetek',
  900. SHARED: 'Megosztott',
  901. SHARED_TWEETS: 'Megosztott tweetek',
  902. SHOW: 'Megjelenítés',
  903. SHOW_MORE_REPLIES: 'Több válasz megjelenítése',
  904. SORT_REPLIES: 'Válaszok rendezése',
  905. TURN_OFF_QUOTE_TWEETS: 'Tweet-idézések kikapcsolása',
  906. TURN_OFF_RETWEETS: 'Retweetek kikapcsolása',
  907. TURN_ON_RETWEETS: 'Retweetek bekapcsolása',
  908. TWEET: 'Tweetelj',
  909. TWEETS: 'Tweetek',
  910. TWEET_ALL: 'Tweet küldése mindenkinek',
  911. TWEET_INTERACTIONS: 'Tweet interakciók',
  912. TWEET_YOUR_REPLY: 'Tweeteld válaszodat',
  913. UNDO_RETWEET: 'Retweet visszavonása',
  914. VIEW: 'Megtekintés',
  915. WHATS_HAPPENING: 'Mi történik?',
  916. },
  917. id: {
  918. ADD_MUTED_WORD: 'Tambahkan kata kunci yang dibisukan',
  919. GROK_ACTIONS: 'Tindakan Grok',
  920. HOME: 'Beranda',
  921. LIKES: 'Suka',
  922. MOST_RELEVANT: 'Paling relevan',
  923. MUTE_THIS_CONVERSATION: 'Bisukan percakapan ini',
  924. POST_ALL: 'Posting semua',
  925. POST_UNAVAILABLE: 'Postingan ini tidak tersedia.',
  926. PROFILE_SUMMARY: 'Ringkasan Profil',
  927. QUOTE: 'Kutipan',
  928. QUOTES: 'Kutipan',
  929. QUOTE_TWEET: 'Kutip Tweet',
  930. QUOTE_TWEETS: 'Tweet Kutipan',
  931. REPOST: 'Posting ulang',
  932. REPOSTS: 'Posting ulang',
  933. RETWEETED_BY: 'Di-retweet oleh',
  934. RETWEETS: 'Retweet',
  935. SHARED: 'Dibagikan',
  936. SHARED_TWEETS: 'Tweet yang Dibagikan',
  937. SHOW: 'Tampilkan',
  938. SHOW_MORE_REPLIES: 'Tampilkan balasan lainnya',
  939. SORT_REPLIES: 'Urutkan balasan',
  940. TURN_OFF_QUOTE_TWEETS: 'Matikan Tweet Kutipan',
  941. TURN_OFF_RETWEETS: 'Matikan Retweet',
  942. TURN_ON_RETWEETS: 'Nyalakan Retweet',
  943. TWEETS: 'Tweet',
  944. TWEET_ALL: 'Tweet semua',
  945. TWEET_INTERACTIONS: 'Interaksi Tweet',
  946. TWEET_YOUR_REPLY: 'Tweet balasan Anda!',
  947. UNDO_RETWEET: 'Batalkan Retweet',
  948. VIEW: 'Lihat',
  949. WHATS_HAPPENING: 'Apa yang terjadi?',
  950. },
  951. it: {
  952. ADD_MUTED_WORD: 'Aggiungi parola o frase silenziata',
  953. GROK_ACTIONS: 'Azioni di Grok',
  954. LIKES: 'Mi piace',
  955. MOST_RELEVANT: 'Più pertinenti',
  956. MUTE_THIS_CONVERSATION: 'Silenzia questa conversazione',
  957. POST_ALL: 'Posta tutto',
  958. POST_UNAVAILABLE: 'Questo post non è disponibile.',
  959. PROFILE_SUMMARY: 'Riepilogo del profilo',
  960. QUOTE: 'Citazione',
  961. QUOTES: 'Citazioni',
  962. QUOTE_TWEET: 'Cita Tweet',
  963. QUOTE_TWEETS: 'Tweet di citazione',
  964. REPOSTS: 'Repost',
  965. RETWEET: 'Ritwitta',
  966. RETWEETED_BY: 'Ritwittato da',
  967. RETWEETS: 'Retweet',
  968. SHARED: 'Condiviso',
  969. SHARED_TWEETS: 'Tweet condivisi',
  970. SHOW: 'Mostra',
  971. SHOW_MORE_REPLIES: 'Mostra altre risposte',
  972. SORT_REPLIES: 'Ordina risposte',
  973. TURN_OFF_QUOTE_TWEETS: 'Disattiva i Tweet di citazione',
  974. TURN_OFF_RETWEETS: 'Disattiva Retweet',
  975. TURN_ON_RETWEETS: 'Attiva Retweet',
  976. TWEET: 'Twitta',
  977. TWEETS: 'Tweet',
  978. TWEET_ALL: 'Twitta tutto',
  979. TWEET_INTERACTIONS: 'Interazioni con Tweet',
  980. TWEET_YOUR_REPLY: 'Twitta la tua risposta.',
  981. UNDO_RETWEET: 'Annulla Retweet',
  982. VIEW: 'Visualizza',
  983. WHATS_HAPPENING: 'Cosa sta succedendo?',
  984. },
  985. ja: {
  986. ADD_MUTED_WORD: 'ミュートするキーワードを追加',
  987. GROK_ACTIONS: 'Grokのアクション',
  988. HOME: 'ホーム',
  989. LIKES: 'いいね',
  990. MOST_RELEVANT: '関連性が高い',
  991. MUTE_THIS_CONVERSATION: 'この会話をミュート',
  992. POST_ALL: 'すべてポスト',
  993. POST_UNAVAILABLE: 'このポストは表示できません。',
  994. PROFILE_SUMMARY: 'プロフィールの要約',
  995. QUOTE: '引用',
  996. QUOTES: '引用',
  997. QUOTE_TWEET: '引用ツイート',
  998. QUOTE_TWEETS: '引用ツイート',
  999. REPOST: 'リポスト',
  1000. REPOSTS: 'リポスト',
  1001. RETWEET: 'リツイート',
  1002. RETWEETED_BY: 'リツイートしたユーザー',
  1003. RETWEETS: 'リツイート',
  1004. SHARED: '共有',
  1005. SHARED_TWEETS: '共有ツイート',
  1006. SHOW: '表示',
  1007. SHOW_MORE_REPLIES: '返信をさらに表示',
  1008. SORT_REPLIES: '返信を並べ替え',
  1009. TURN_OFF_QUOTE_TWEETS: '引用ツイートをオフにする',
  1010. TURN_OFF_RETWEETS: 'リツイートをオフにする',
  1011. TURN_ON_RETWEETS: 'リツイートをオンにする',
  1012. TWEET: 'ツイートする',
  1013. TWEETS: 'ツイート',
  1014. TWEET_ALL: 'すべてツイート',
  1015. TWEET_INTERACTIONS: 'ツイートの相互作用',
  1016. TWEET_YOUR_REPLY: '返信をツイートしましょう。',
  1017. UNDO_RETWEET: 'リツイートを取り消す',
  1018. VIEW: '表示する',
  1019. WHATS_HAPPENING: 'いまどうしてる?',
  1020. },
  1021. kn: {
  1022. ADD_MUTED_WORD: 'ಸದ್ದಡಗಿಸಿದ ಪದವನ್ನು ಸೇರಿಸಿ',
  1023. GROK_ACTIONS: 'Grok ಕ್ರಮಗಳು',
  1024. HOME: 'ಹೋಮ್',
  1025. LIKES: 'ಇಷ್ಟಗಳು',
  1026. MOST_RELEVANT: 'ಅತ್ಯಂತ ಸಂಬಂಧಿತ',
  1027. MUTE_THIS_CONVERSATION: 'ಈ ಸಂವಾದವನ್ನು ಸದ್ದಡಗಿಸಿ',
  1028. POST_ALL: 'ಎಲ್ಲವನ್ನೂ ಪೋಸ್ಟ್ ಮಾಡಿ',
  1029. POST_UNAVAILABLE: 'ಈ ಪೋಸ್ಟ್ ಲಭ್ಯವಿಲ್ಲ.',
  1030. PROFILE_SUMMARY: 'ಪ್ರೊಫೈಲ್ ಸಾರಾಂಶ',
  1031. QUOTE: 'ಕೋಟ್‌',
  1032. QUOTES: 'ಉಲ್ಲೇಖಗಳು',
  1033. QUOTE_TWEET: 'ಟ್ವೀಟ್ ಕೋಟ್ ಮಾಡಿ',
  1034. QUOTE_TWEETS: 'ಕೋಟ್ ಟ್ವೀಟ್‌ಗಳು',
  1035. REPOST: 'ಮರುಪೋಸ್ಟ್ ಮಾಡಿ',
  1036. REPOSTS: 'ಮರುಪೋಸ್ಟ್‌ಗಳು',
  1037. RETWEET: 'ಮರುಟ್ವೀಟಿಸಿ',
  1038. RETWEETED_BY: 'ಮರುಟ್ವೀಟಿಸಿದವರು',
  1039. RETWEETS: 'ಮರುಟ್ವೀಟ್‌ಗಳು',
  1040. SHARED: 'ಹಂಚಲಾಗಿದೆ',
  1041. SHARED_TWEETS: 'ಹಂಚಿದ ಟ್ವೀಟ್‌ಗಳು',
  1042. SHOW: 'ತೋರಿಸಿ',
  1043. SHOW_MORE_REPLIES: 'ಇನ್ನಷ್ಟು ಪ್ರತಿಕ್ರಿಯೆಗಳನ್ನು ತೋರಿಸಿ',
  1044. SORT_REPLIES: 'ಪ್ರತಿಕ್ರಿಯೆಗಳನ್ನು ಆಯೋಜಿಸಿ',
  1045. TURN_OFF_QUOTE_TWEETS: 'ಕೋಟ್ ಟ್ವೀಟ್‌ಗಳನ್ನು ಆಫ್ ಮಾಡಿ',
  1046. TURN_OFF_RETWEETS: 'ಮರುಟ್ವೀಟ್‌ಗಳನ್ನು ಆಫ್ ಮಾಡಿ',
  1047. TURN_ON_RETWEETS: 'ಮರುಟ್ವೀಟ್‌ಗಳನ್ನು ಆನ್ ಮಾಡಿ',
  1048. TWEET: 'ಟ್ವೀಟ್',
  1049. TWEETS: 'ಟ್ವೀಟ್‌ಗಳು',
  1050. TWEET_ALL: 'ಎಲ್ಲಾ ಟ್ವೀಟ್ ಮಾಡಿ',
  1051. TWEET_INTERACTIONS: 'ಟ್ವೀಟ್ ಸಂವಾದಗಳು',
  1052. TWEET_YOUR_REPLY: 'ನಿಮ್ಮ ಪ್ರತಿಕ್ರಿಯೆಯನ್ನು ಟ್ವೀಟ್ ಮಾಡಿ!',
  1053. UNDO_RETWEET: 'ಮರುಟ್ವೀಟಿಸುವುದನ್ನು ರದ್ದುಮಾಡಿ',
  1054. VIEW: 'ವೀಕ್ಷಿಸಿ',
  1055. WHATS_HAPPENING: 'ಏನು ನಡೆಯುತ್ತಿದೆ?',
  1056. },
  1057. ko: {
  1058. ADD_MUTED_WORD: '뮤트할 단어 추가하기',
  1059. GROK_ACTIONS: 'Grok 작업',
  1060. HOME: '홈',
  1061. LIKES: '마음에 들어요',
  1062. MOST_RELEVANT: '관련도 순서',
  1063. MUTE_THIS_CONVERSATION: '이 대화 뮤트하기',
  1064. POST_ALL: '모두 게시하기',
  1065. POST_UNAVAILABLE: '이 게시물을 볼 수 없습니다.',
  1066. PROFILE_SUMMARY: '프로필 요약',
  1067. QUOTE: '인용',
  1068. QUOTES: '인용',
  1069. QUOTE_TWEET: '트윗 인용하기',
  1070. QUOTE_TWEETS: '트윗 인용하기',
  1071. REPOST: '재게시',
  1072. REPOSTS: '재게시',
  1073. RETWEET: '리트윗',
  1074. RETWEETED_BY: '리트윗함',
  1075. RETWEETS: '리트윗',
  1076. SHARED: '공유된',
  1077. SHARED_TWEETS: '공유 트윗',
  1078. SHOW: '표시',
  1079. SHOW_MORE_REPLIES: '더 많은 답글 보기',
  1080. SORT_REPLIES: '답글 정렬하기',
  1081. TURN_OFF_QUOTE_TWEETS: '인용 트윗 끄기',
  1082. TURN_OFF_RETWEETS: '리트윗 끄기',
  1083. TURN_ON_RETWEETS: '리트윗 켜기',
  1084. TWEET: '트윗',
  1085. TWEETS: '트윗',
  1086. TWEET_ALL: '모두 트윗하기',
  1087. TWEET_INTERACTIONS: '트윗 상호작용',
  1088. TWEET_YOUR_REPLY: '내 답글을 트윗하세요',
  1089. TWITTER: '트위터',
  1090. UNDO_RETWEET: '리트윗 취소',
  1091. VIEW: '보기',
  1092. WHATS_HAPPENING: '무슨 일이야?',
  1093. },
  1094. mr: {
  1095. ADD_MUTED_WORD: 'म्यूट केलेले शब्द सामील करा',
  1096. GROK_ACTIONS: 'Grok कृती',
  1097. HOME: 'होम',
  1098. LIKES: 'पसंती',
  1099. MOST_RELEVANT: 'सर्वात महत्वाचे',
  1100. MUTE_THIS_CONVERSATION: 'ही चर्चा म्यूट करा',
  1101. POST_ALL: 'सर्व पोस्ट करा',
  1102. POST_UNAVAILABLE: 'हे पोस्ट अनुपलब्ध आहे.',
  1103. PROFILE_SUMMARY: 'प्रोफाइल सारांश',
  1104. QUOTE: 'भाष्य',
  1105. QUOTES: 'भाष्य',
  1106. QUOTE_TWEET: 'ट्विट वर भाष्य करा',
  1107. QUOTE_TWEETS: 'भाष्य ट्विट्स',
  1108. REPOST: 'पुन्हा पोस्ट करा',
  1109. REPOSTS: 'रिपोस्ट',
  1110. RETWEET: 'पुन्हा ट्विट',
  1111. RETWEETED_BY: 'यांनी पुन्हा ट्विट केले',
  1112. RETWEETS: 'पुनर्ट्विट्स',
  1113. SHARED: 'सामायिक',
  1114. SHARED_TWEETS: 'सामायिक ट्विट',
  1115. SHOW: 'दाखवा',
  1116. SHOW_MORE_REPLIES: 'अधिक प्रत्युत्तरे दाखवा',
  1117. SORT_REPLIES: 'प्रत्युत्तरांची क्रमवारी करा',
  1118. TURN_OFF_QUOTE_TWEETS: 'भाष्य ट्विट्स बंद करा',
  1119. TURN_OFF_RETWEETS: 'पुनर्ट्विट्स बंद करा',
  1120. TURN_ON_RETWEETS: 'पुनर्ट्विट्स चालू करा',
  1121. TWEET: 'ट्विट',
  1122. TWEETS: 'ट्विट्स',
  1123. TWEET_ALL: 'सर्व ट्विट करा',
  1124. TWEET_INTERACTIONS: 'ट्वीट इंटरऍक्शन्स',
  1125. TWEET_YOUR_REPLY: 'आपल्या प्रत्युत्तरावर ट्विट करा!',
  1126. UNDO_RETWEET: 'पुनर्ट्विट पूर्ववत करा',
  1127. VIEW: 'पहा',
  1128. WHATS_HAPPENING: 'काय होत आहे?',
  1129. },
  1130. ms: {
  1131. ADD_MUTED_WORD: 'Tambahkan perkataan yang disenyapkan',
  1132. GROK_ACTIONS: 'Tindakan Grok',
  1133. HOME: 'Laman Utama',
  1134. LIKES: 'Suka',
  1135. MOST_RELEVANT: 'Paling berkaitan',
  1136. MUTE_THIS_CONVERSATION: 'Senyapkan perbualan ini',
  1137. POST_ALL: 'Siarkan semua',
  1138. POST_UNAVAILABLE: 'Siaran ini tidak tersedia.',
  1139. PROFILE_SUMMARY: 'Ringkasan Profil',
  1140. QUOTE: 'Petikan',
  1141. QUOTES: 'Petikan',
  1142. QUOTE_TWEET: 'Petik Tweet',
  1143. QUOTE_TWEETS: 'Tweet Petikan',
  1144. REPOST: 'Siaran semula',
  1145. REPOSTS: 'Siaran semula',
  1146. RETWEET: 'Tweet semula',
  1147. RETWEETED_BY: 'Ditweet semula oleh',
  1148. RETWEETS: 'Tweet semula',
  1149. SHARED: 'Dikongsi',
  1150. SHARED_TWEETS: 'Tweet Berkongsi',
  1151. SHOW: 'Tunjukkan',
  1152. SHOW_MORE_REPLIES: 'Tunjukkan lagi balasan',
  1153. SORT_REPLIES: 'Isih balasan',
  1154. TURN_OFF_QUOTE_TWEETS: 'Matikan Tweet Petikan',
  1155. TURN_OFF_RETWEETS: 'Matikan Tweet semula',
  1156. TURN_ON_RETWEETS: 'Hidupkan Tweet semula',
  1157. TWEETS: 'Tweet',
  1158. TWEET_ALL: 'Tweet semua',
  1159. TWEET_INTERACTIONS: 'Interaksi Tweet',
  1160. TWEET_YOUR_REPLY: 'Tweet balasan anda!',
  1161. UNDO_RETWEET: 'Buat asal Tweet semula',
  1162. VIEW: 'Lihat',
  1163. WHATS_HAPPENING: 'Apa yang sedang berlaku?',
  1164. },
  1165. nb: {
  1166. ADD_MUTED_WORD: 'Skjul nytt ord',
  1167. GROK_ACTIONS: 'Grok-handlinger',
  1168. HOME: 'Hjem',
  1169. LIKES: 'Liker',
  1170. MOST_RELEVANT: 'Mest relevante',
  1171. MUTE_THIS_CONVERSATION: 'Skjul denne samtalen',
  1172. POST_ALL: 'Publiser alle',
  1173. POST_UNAVAILABLE: 'Dette innlegget er utilgjengelig.',
  1174. PROFILE_SUMMARY: 'Profilsammendrag',
  1175. QUOTE: 'Sitat',
  1176. QUOTES: 'Sitater',
  1177. QUOTE_TWEET: 'Sitat-Tweet',
  1178. QUOTE_TWEETS: 'Sitat-Tweets',
  1179. REPOST: 'Republiser',
  1180. REPOSTS: 'Republiseringer',
  1181. RETWEETED_BY: 'Retweetet av',
  1182. SHARED: 'Delt',
  1183. SHARED_TWEETS: 'Delte tweets',
  1184. SHOW: 'Vis',
  1185. SHOW_MORE_REPLIES: 'Vis flere svar',
  1186. SORT_REPLIES: 'Sorter svar',
  1187. TURN_OFF_QUOTE_TWEETS: 'Slå av sitat-tweets',
  1188. TURN_OFF_RETWEETS: 'Slå av Retweets',
  1189. TURN_ON_RETWEETS: 'Slå på Retweets',
  1190. TWEET_ALL: 'Tweet alle',
  1191. TWEET_INTERACTIONS: 'Tweet-interaksjoner',
  1192. TWEET_YOUR_REPLY: 'Tweet svaret ditt!',
  1193. UNDO_RETWEET: 'Angre Retweet',
  1194. VIEW: 'Vis',
  1195. WHATS_HAPPENING: 'Hva skjer?',
  1196. },
  1197. nl: {
  1198. ADD_MUTED_WORD: 'Genegeerd woord toevoegen',
  1199. GROK_ACTIONS: 'Grok-acties',
  1200. HOME: 'Startpagina',
  1201. LIKES: 'Vind-ik-leuks',
  1202. MOST_RELEVANT: 'Meest relevant',
  1203. MUTE_THIS_CONVERSATION: 'Dit gesprek negeren',
  1204. POST_ALL: 'Alles plaatsen',
  1205. POST_UNAVAILABLE: 'Deze post is niet beschikbaar.',
  1206. PROFILE_SUMMARY: 'Profieloverzicht',
  1207. QUOTE: 'Geciteerd',
  1208. QUOTES: 'Geciteerd',
  1209. QUOTE_TWEET: 'Citeer Tweet',
  1210. QUOTE_TWEETS: 'Geciteerde Tweets',
  1211. RETWEET: 'Retweeten',
  1212. RETWEETED_BY: 'Geretweet door',
  1213. SHARED: 'Gedeeld',
  1214. SHARED_TWEETS: 'Gedeelde Tweets',
  1215. SHOW: 'Weergeven',
  1216. SHOW_MORE_REPLIES: 'Meer antwoorden tonen',
  1217. SORT_REPLIES: 'Antwoorden sorteren',
  1218. TURN_OFF_QUOTE_TWEETS: 'Geciteerde Tweets uitschakelen',
  1219. TURN_OFF_RETWEETS: 'Retweets uitschakelen',
  1220. TURN_ON_RETWEETS: 'Retweets inschakelen',
  1221. TWEET: 'Tweeten',
  1222. TWEET_ALL: 'Alles tweeten',
  1223. TWEET_INTERACTIONS: 'Tweet-interacties',
  1224. TWEET_YOUR_REPLY: 'Tweet je antwoord!',
  1225. UNDO_RETWEET: 'Retweet ongedaan maken',
  1226. VIEW: 'Bekijken',
  1227. WHATS_HAPPENING: 'Wat gebeurt er?',
  1228. },
  1229. pl: {
  1230. ADD_MUTED_WORD: 'Dodaj wyciszone słowo',
  1231. GROK_ACTIONS: 'Akcje Groka',
  1232. HOME: 'Główna',
  1233. LIKES: 'Polubienia',
  1234. MOST_RELEVANT: 'Najtrafniejsze',
  1235. MUTE_THIS_CONVERSATION: 'Wycisz tę rozmowę',
  1236. POST_ALL: 'Opublikuj wszystko',
  1237. POST_UNAVAILABLE: 'Ten wpis jest niedostępny.',
  1238. PROFILE_SUMMARY: 'Podsumowanie profilu',
  1239. QUOTE: 'Cytuj',
  1240. QUOTES: 'Cytaty',
  1241. QUOTE_TWEET: 'Cytuj Tweeta',
  1242. QUOTE_TWEETS: 'Cytaty z Tweeta',
  1243. REPOST: 'Podaj dalej wpis',
  1244. REPOSTS: 'Wpisy podane dalej',
  1245. RETWEET: 'Podaj dalej',
  1246. RETWEETED_BY: 'Podane dalej przez',
  1247. RETWEETS: 'Tweety podane dalej',
  1248. SHARED: 'Udostępniony',
  1249. SHARED_TWEETS: 'Udostępnione Tweety',
  1250. SHOW: 'Pokaż',
  1251. SHOW_MORE_REPLIES: 'Pokaż więcej odpowiedzi',
  1252. SORT_REPLIES: 'Sortuj odpowiedzi',
  1253. TURN_OFF_QUOTE_TWEETS: 'Wyłącz tweety z cytatem',
  1254. TURN_OFF_RETWEETS: 'Wyłącz Tweety podane dalej',
  1255. TURN_ON_RETWEETS: 'Włącz Tweety podane dalej',
  1256. TWEETS: 'Tweety',
  1257. TWEET_ALL: 'Tweetnij wszystko',
  1258. TWEET_INTERACTIONS: 'Interakcje na Tweeta',
  1259. TWEET_YOUR_REPLY: 'Wyślij Tweeta z odpowiedzią!',
  1260. UNDO_RETWEET: 'Cofnij podanie dalej',
  1261. VIEW: 'Wyświetl',
  1262. WHATS_HAPPENING: 'Co się dzieje?',
  1263. },
  1264. pt: {
  1265. ADD_MUTED_WORD: 'Adicionar palavra silenciada',
  1266. GROK_ACTIONS: 'Ações do Grok',
  1267. HOME: 'Página Inicial',
  1268. LIKES: 'Curtidas',
  1269. MOST_RELEVANT: 'Mais relevante',
  1270. MUTE_THIS_CONVERSATION: 'Silenciar esta conversa',
  1271. POST_ALL: 'Postar tudo',
  1272. POST_UNAVAILABLE: 'Este post está indisponível.',
  1273. PROFILE_SUMMARY: 'Resumo do perfil',
  1274. QUOTE: 'Comentar',
  1275. QUOTES: 'Comentários',
  1276. QUOTE_TWEET: 'Comentar o Tweet',
  1277. QUOTE_TWEETS: 'Tweets com comentário',
  1278. REPOST: 'Repostar',
  1279. RETWEET: 'Retweetar',
  1280. RETWEETED_BY: 'Retweetado por',
  1281. SHARED: 'Compartilhado',
  1282. SHARED_TWEETS: 'Tweets Compartilhados',
  1283. SHOW: 'Mostrar',
  1284. SHOW_MORE_REPLIES: 'Mostrar mais respostas',
  1285. SORT_REPLIES: 'Ordenar respostas',
  1286. TURN_OFF_QUOTE_TWEETS: 'Desativar Tweets com comentário',
  1287. TURN_OFF_RETWEETS: 'Desativar Retweets',
  1288. TURN_ON_RETWEETS: 'Ativar Retweets',
  1289. TWEET: 'Tweetar',
  1290. TWEET_ALL: 'Tweetar tudo',
  1291. TWEET_INTERACTIONS: 'Interações com Tweet',
  1292. TWEET_YOUR_REPLY: 'Tweetar sua resposta!',
  1293. UNDO_RETWEET: 'Desfazer Retweet',
  1294. VIEW: 'Ver',
  1295. WHATS_HAPPENING: 'O que está acontecendo?',
  1296. },
  1297. ro: {
  1298. ADD_MUTED_WORD: 'Adaugă cuvântul ignorat',
  1299. GROK_ACTIONS: 'Acțiuni Grok',
  1300. HOME: 'Pagina principală',
  1301. LIKES: 'Aprecieri',
  1302. MOST_RELEVANT: 'Cele mai relevante',
  1303. MUTE_THIS_CONVERSATION: 'Ignoră această conversație',
  1304. POST_ALL: 'Postează tot',
  1305. POST_UNAVAILABLE: 'Această postare este indisponibilă.',
  1306. PROFILE_SUMMARY: 'Sumarul profilului',
  1307. QUOTE: 'Citat',
  1308. QUOTES: 'Citate',
  1309. QUOTE_TWEET: 'Citează Tweetul',
  1310. QUOTE_TWEETS: 'Tweeturi cu citat',
  1311. REPOST: 'Repostează',
  1312. REPOSTS: 'Repostări',
  1313. RETWEET: 'Redistribuie',
  1314. RETWEETED_BY: 'Redistribuit de către',
  1315. RETWEETS: 'Retweeturi',
  1316. SHARED: 'Partajat',
  1317. SHARED_TWEETS: 'Tweeturi partajate',
  1318. SHOW: 'Afișează',
  1319. SHOW_MORE_REPLIES: 'Afișează mai multe răspunsuri',
  1320. SORT_REPLIES: 'Sortare răspunsuri',
  1321. TURN_OFF_QUOTE_TWEETS: 'Dezactivează tweeturile cu citat',
  1322. TURN_OFF_RETWEETS: 'Dezactivează Retweeturile',
  1323. TURN_ON_RETWEETS: 'Activează Retweeturile',
  1324. TWEETS: 'Tweeturi',
  1325. TWEET_ALL: 'Dă Tweeturi cu tot',
  1326. TWEET_INTERACTIONS: 'Interacțiuni cu Tweetul',
  1327. TWEET_YOUR_REPLY: 'Dă Tweet cu răspunsul!',
  1328. UNDO_RETWEET: 'Anulează Retweetul',
  1329. VIEW: 'Vezi',
  1330. WHATS_HAPPENING: 'Ce se întâmplă?',
  1331. },
  1332. ru: {
  1333. ADD_MUTED_WORD: 'Добавить игнорируемое слово',
  1334. GROK_ACTIONS: 'Действия Grok',
  1335. HOME: 'Главная',
  1336. LIKES: 'Нравится',
  1337. MOST_RELEVANT: 'Наиболее актуальные',
  1338. MUTE_THIS_CONVERSATION: 'Игнорировать эту переписку',
  1339. POST_ALL: 'Опубликовать все',
  1340. POST_UNAVAILABLE: 'Этот пост недоступен.',
  1341. PROFILE_SUMMARY: 'Сводка профиля',
  1342. QUOTE: 'Цитата',
  1343. QUOTES: 'Цитаты',
  1344. QUOTE_TWEET: 'Цитировать',
  1345. QUOTE_TWEETS: 'Твиты с цитатами',
  1346. REPOST: 'Сделать репост',
  1347. REPOSTS: 'Репосты',
  1348. RETWEET: 'Ретвитнуть',
  1349. RETWEETED_BY: 'Ретвитнул(а)',
  1350. RETWEETS: 'Ретвиты',
  1351. SHARED: 'Общий',
  1352. SHARED_TWEETS: 'Общие твиты',
  1353. SHOW: 'Показать',
  1354. SHOW_MORE_REPLIES: 'Показать ещё ответы',
  1355. SORT_REPLIES: 'Упорядочить ответы',
  1356. TURN_OFF_QUOTE_TWEETS: 'Отключить твиты с цитатами',
  1357. TURN_OFF_RETWEETS: 'Отключить ретвиты',
  1358. TURN_ON_RETWEETS: 'Включить ретвиты',
  1359. TWEET: 'Твитнуть',
  1360. TWEETS: 'Твиты',
  1361. TWEET_ALL: 'Твитнуть все',
  1362. TWEET_INTERACTIONS: 'Взаимодействие в Твитнуть',
  1363. TWEET_YOUR_REPLY: 'Твитните свой ответ!',
  1364. TWITTER: 'Твиттер',
  1365. UNDO_RETWEET: 'Отменить ретвит',
  1366. VIEW: 'Посмотреть',
  1367. WHATS_HAPPENING: 'Что происходит?',
  1368. },
  1369. sk: {
  1370. ADD_MUTED_WORD: 'Pridať stíšené slovo',
  1371. GROK_ACTIONS: 'Akcie Groka',
  1372. HOME: 'Domov',
  1373. LIKES: 'Páči sa',
  1374. MOST_RELEVANT: 'Najrelevantnejšie',
  1375. MUTE_THIS_CONVERSATION: 'Stíšiť túto konverzáciu',
  1376. POST_ALL: 'Uverejniť všetko',
  1377. POST_UNAVAILABLE: 'Tento príspevok je nedostupný.',
  1378. PROFILE_SUMMARY: 'Súhrn profilu',
  1379. QUOTE: 'Citát',
  1380. QUOTES: 'Citáty',
  1381. QUOTE_TWEET: 'Tweet s citátom',
  1382. QUOTE_TWEETS: 'Tweety s citátom',
  1383. REPOST: 'Opätovné uverejnenie',
  1384. REPOSTS: 'Opätovné uverejnenia',
  1385. RETWEET: 'Retweetnuť',
  1386. RETWEETED_BY: 'Retweetnuté používateľom',
  1387. RETWEETS: 'Retweety',
  1388. SHARED: 'Zdieľaný',
  1389. SHARED_TWEETS: 'Zdieľané Tweety',
  1390. SHOW: 'Zobraziť',
  1391. SHOW_MORE_REPLIES: 'Zobraziť viac odpovedí',
  1392. SORT_REPLIES: 'Zoradiť odpovede',
  1393. TURN_OFF_QUOTE_TWEETS: 'Vypnúť tweety s citátom',
  1394. TURN_OFF_RETWEETS: 'Vypnúť retweety',
  1395. TURN_ON_RETWEETS: 'Zapnúť retweety',
  1396. TWEET: 'Tweetnuť',
  1397. TWEETS: 'Tweety',
  1398. TWEET_ALL: 'Tweetnuť všetko',
  1399. TWEET_INTERACTIONS: 'Interakcie s Tweet',
  1400. TWEET_YOUR_REPLY: 'Tweetnite odpoveď!',
  1401. UNDO_RETWEET: 'Zrušiť retweet',
  1402. VIEW: 'Zobraziť',
  1403. WHATS_HAPPENING: 'Čo sa deje?',
  1404. },
  1405. sr: {
  1406. ADD_MUTED_WORD: 'Додај игнорисану реч',
  1407. GROK_ACTIONS: 'Grok радње',
  1408. HOME: 'Почетна',
  1409. LIKES: 'Свиђања',
  1410. MOST_RELEVANT: 'Најважније',
  1411. MUTE_THIS_CONVERSATION: 'Игнориши овај разговор',
  1412. POST_ALL: 'Објави све',
  1413. POST_UNAVAILABLE: 'Ова објава није доступна.',
  1414. PROFILE_SUMMARY: 'Резиме профила',
  1415. QUOTE: 'Цитат',
  1416. QUOTES: 'Цитати',
  1417. QUOTE_TWEET: 'твит са цитатом',
  1418. QUOTE_TWEETS: 'твит(ов)а са цитатом',
  1419. REPOST: 'Поново објави',
  1420. REPOSTS: 'Понвне објаве',
  1421. RETWEET: 'Ретвитуј',
  1422. RETWEETED_BY: 'Ретвитовано од стране',
  1423. RETWEETS: 'Ретвитови',
  1424. SHARED: 'Подељено',
  1425. SHARED_TWEETS: 'Дељени твитови',
  1426. SHOW: 'Прикажи',
  1427. SHOW_MORE_REPLIES: 'Прикажи још одговора',
  1428. SORT_REPLIES: 'Сортирање одговора',
  1429. TURN_OFF_QUOTE_TWEETS: 'Искључи твит(ов)е са цитатом',
  1430. TURN_OFF_RETWEETS: 'Искључи ретвитове',
  1431. TURN_ON_RETWEETS: 'Укључи ретвитове',
  1432. TWEET: 'Твитуј',
  1433. TWEETS: 'Твитови',
  1434. TWEET_ALL: 'Твитуј све',
  1435. TWEET_INTERACTIONS: 'Интеракције са Твитуј',
  1436. TWEET_YOUR_REPLY: 'Твитуј свој одговор!',
  1437. TWITTER: 'Твитер',
  1438. UNDO_RETWEET: 'Опозови ретвит',
  1439. VIEW: 'Погледај',
  1440. WHATS_HAPPENING: 'Шта се дешава?',
  1441. },
  1442. sv: {
  1443. ADD_MUTED_WORD: 'Lägg till ignorerat ord',
  1444. GROK_ACTIONS: 'Grok-åtgärder',
  1445. HOME: 'Hem',
  1446. LIKES: 'Gilla-markeringar',
  1447. MOST_RELEVANT: 'Mest relevant',
  1448. MUTE_THIS_CONVERSATION: 'Ignorera den här konversationen',
  1449. POST_ALL: 'Lägg upp allt',
  1450. POST_UNAVAILABLE: 'Detta inlägg är inte tillgängligt.',
  1451. PROFILE_SUMMARY: 'Profilöversikt',
  1452. QUOTE: 'Citat',
  1453. QUOTES: 'Citat',
  1454. QUOTE_TWEET: 'Citera Tweet',
  1455. QUOTE_TWEETS: 'Citat-tweets',
  1456. REPOST: 'Återpublicera',
  1457. REPOSTS: 'Återpubliceringar',
  1458. RETWEET: 'Retweeta',
  1459. RETWEETED_BY: 'Retweetad av',
  1460. SHARED: 'Delad',
  1461. SHARED_TWEETS: 'Delade tweetsen',
  1462. SHOW: 'Visa',
  1463. SHOW_MORE_REPLIES: 'Visa fler svar',
  1464. SORT_REPLIES: 'Sortera svar',
  1465. TURN_OFF_QUOTE_TWEETS: 'Stäng av citat-tweets',
  1466. TURN_OFF_RETWEETS: 'Stäng av Retweets',
  1467. TURN_ON_RETWEETS: 'Slå på Retweets',
  1468. TWEET: 'Tweeta',
  1469. TWEET_ALL: 'Tweeta allt',
  1470. TWEET_INTERACTIONS: 'Interaktioner med Tweet',
  1471. TWEET_YOUR_REPLY: 'Tweeta ditt svar!',
  1472. UNDO_RETWEET: 'Ångra retweeten',
  1473. VIEW: 'Visa',
  1474. WHATS_HAPPENING: 'Vad händer?',
  1475. },
  1476. ta: {
  1477. ADD_MUTED_WORD: 'செயல்மறைத்த வார்த்தையைச் சேர்',
  1478. GROK_ACTIONS: 'Grok செயல்கள்',
  1479. HOME: 'முகப்பு',
  1480. LIKES: 'விருப்பங்கள்',
  1481. MOST_RELEVANT: 'மிகவும் தொடர்புடையவை',
  1482. MUTE_THIS_CONVERSATION: 'இந்த உரையாடலை செயல்மறை',
  1483. POST_ALL: 'எல்லாம் இடுகையிடு',
  1484. POST_UNAVAILABLE: 'இந்த இடுகை கிடைக்கவில்லை.',
  1485. PROFILE_SUMMARY: 'சுயவிவரச் சுருக்கம்',
  1486. QUOTE: 'மேற்கோள்',
  1487. QUOTES: 'மேற்கோள்கள்',
  1488. QUOTE_TWEET: 'ட்விட்டை மேற்கோள் காட்டு',
  1489. QUOTE_TWEETS: 'மேற்கோள் கீச்சுகள்',
  1490. REPOST: 'மறுஇடுகை',
  1491. REPOSTS: 'மறுஇடுகைகள்',
  1492. RETWEET: 'மறுட்விட் செய்',
  1493. RETWEETED_BY: 'இவரால் மறுட்விட் செய்யப்பட்டது',
  1494. RETWEETS: 'மறுகீச்சுகள்',
  1495. SHARED: 'பகிரப்பட்டது',
  1496. SHARED_TWEETS: 'பகிரப்பட்ட ட்வீட்டுகள்',
  1497. SHOW: 'காண்பி',
  1498. SHOW_MORE_REPLIES: 'மேலும் பதில்களைக் காண்பி',
  1499. SORT_REPLIES: 'பதில்களை வகைப்படுத்து',
  1500. TURN_OFF_QUOTE_TWEETS: 'மேற்கோள் கீச்சுகளை அணை',
  1501. TURN_OFF_RETWEETS: 'மறுகீச்சுகளை அணை',
  1502. TURN_ON_RETWEETS: 'மறுகீச்சுகளை இயக்கு',
  1503. TWEET: 'ட்விட் செய்',
  1504. TWEETS: 'கீச்சுகள்',
  1505. TWEET_ALL: 'அனைத்தையும் ட்விட் செய்',
  1506. TWEET_INTERACTIONS: 'ட்விட் செய் ஊடாடல்களைக்',
  1507. TWEET_YOUR_REPLY: 'உங்கள் பதிலை ட்விட் செய்யவும்!',
  1508. UNDO_RETWEET: 'மறுகீச்சை செயல்தவிர்',
  1509. VIEW: 'காண்பி',
  1510. WHATS_HAPPENING: 'என்ன நடக்கிறது?',
  1511. },
  1512. th: {
  1513. ADD_MUTED_WORD: 'เพิ่มคำที่ซ่อน',
  1514. GROK_ACTIONS: 'การดำเนินการของ Grok',
  1515. HOME: 'หน้าแรก',
  1516. LIKES: 'ความชอบ',
  1517. MOST_RELEVANT: 'เกี่ยวข้องที่สุด',
  1518. MUTE_THIS_CONVERSATION: 'ซ่อนบทสนทนานี้',
  1519. POST_ALL: 'โพสต์ทั้งหมด',
  1520. POST_UNAVAILABLE: 'โพสต์นี้ไม่สามารถใช้งานได้',
  1521. PROFILE_SUMMARY: 'ข้อมูลส่วนตัวโดยย่อ',
  1522. QUOTE: 'การอ้างอิง',
  1523. QUOTES: 'คำพูด',
  1524. QUOTE_TWEET: 'อ้างอิงทวีต',
  1525. QUOTE_TWEETS: 'ทวีตและคำพูด',
  1526. REPOST: 'รีโพสต์',
  1527. REPOSTS: 'รีโพสต์',
  1528. RETWEET: 'รีทวีต',
  1529. RETWEETED_BY: 'ถูกรีทวีตโดย',
  1530. RETWEETS: 'รีทวีต',
  1531. SHARED: 'แบ่งปัน',
  1532. SHARED_TWEETS: 'ทวีตที่แชร์',
  1533. SHOW: 'แสดง',
  1534. SHOW_MORE_REPLIES: 'แสดงการตอบกลับเพิ่มเติม',
  1535. SORT_REPLIES: 'จัดเรียงการตอบกลับ',
  1536. TURN_OFF_QUOTE_TWEETS: 'ปิดทวีตและคำพูด',
  1537. TURN_OFF_RETWEETS: 'ปิดรีทวีต',
  1538. TURN_ON_RETWEETS: 'เปิดรีทวีต',
  1539. TWEET: 'ทวีต',
  1540. TWEETS: 'ทวีต',
  1541. TWEET_ALL: 'ทวีตทั้งหมด',
  1542. TWEET_INTERACTIONS: 'การโต้ตอบของทวีต',
  1543. TWEET_YOUR_REPLY: 'ทวีตการตอบกลับของคุณ',
  1544. TWITTER: 'ทวิตเตอร์',
  1545. UNDO_RETWEET: 'ยกเลิกการรีทวีต',
  1546. VIEW: 'ดู',
  1547. WHATS_HAPPENING: 'เกิดอะไรขึ้น?',
  1548. },
  1549. tr: {
  1550. ADD_MUTED_WORD: 'Sessize alınacak kelime ekle',
  1551. GROK_ACTIONS: 'Grok işlemleri',
  1552. HOME: 'Anasayfa',
  1553. LIKES: 'Beğeni',
  1554. MOST_RELEVANT: 'En alakalı',
  1555. MUTE_THIS_CONVERSATION: 'Bu sohbeti sessize al',
  1556. POST_ALL: 'Tümünü gönder',
  1557. POST_UNAVAILABLE: 'Bu gönderi kullanılamıyor.',
  1558. PROFILE_SUMMARY: 'Profil Özeti',
  1559. QUOTE: 'Alıntı',
  1560. QUOTES: 'Alıntılar',
  1561. QUOTE_TWEET: 'Tweeti Alıntıla',
  1562. QUOTE_TWEETS: 'Alıntı Tweetler',
  1563. REPOST: 'Yeniden gönder',
  1564. REPOSTS: 'Yeniden gönderiler',
  1565. RETWEETED_BY: 'Retweetleyen(ler):',
  1566. RETWEETS: 'Retweetler',
  1567. SHARED: 'Paylaşılan',
  1568. SHARED_TWEETS: 'Paylaşılan Tweetler',
  1569. SHOW: 'Göster',
  1570. SHOW_MORE_REPLIES: 'Daha fazla yanıt göster',
  1571. SORT_REPLIES: 'Yanıtları sırala',
  1572. TURN_OFF_QUOTE_TWEETS: 'Alıntı Tweetleri kapat',
  1573. TURN_OFF_RETWEETS: 'Retweetleri kapat',
  1574. TURN_ON_RETWEETS: 'Retweetleri aç',
  1575. TWEET: 'Tweetle',
  1576. TWEETS: 'Tweetler',
  1577. TWEET_ALL: 'Hepsini Tweetle',
  1578. TWEET_INTERACTIONS: 'Tweet etkileşimleri',
  1579. TWEET_YOUR_REPLY: 'Yanıtını Tweetle.',
  1580. UNDO_RETWEET: 'Retweeti Geri Al',
  1581. VIEW: 'Görüntüle',
  1582. WHATS_HAPPENING: 'Ne oluyor?',
  1583. },
  1584. uk: {
  1585. ADD_MUTED_WORD: 'Додати слово до списку ігнорування',
  1586. GROK_ACTIONS: 'Дії Grok',
  1587. HOME: 'Головна',
  1588. LIKES: 'Вподобання',
  1589. MOST_RELEVANT: 'Найактуальніші',
  1590. MUTE_THIS_CONVERSATION: 'Ігнорувати цю розмову',
  1591. POST_ALL: 'Опублікувати все',
  1592. POST_UNAVAILABLE: 'Цей пост недоступний.',
  1593. PROFILE_SUMMARY: 'Зведення профілю',
  1594. QUOTE: 'Цитата',
  1595. QUOTES: 'Цитати',
  1596. QUOTE_TWEET: 'Цитувати твіт',
  1597. QUOTE_TWEETS: 'Цитовані твіти',
  1598. REPOST: 'Зробити репост',
  1599. REPOSTS: 'Репости',
  1600. RETWEET: 'Ретвітнути',
  1601. RETWEETED_BY: 'Ретвіти',
  1602. RETWEETS: 'Ретвіти',
  1603. SHARED: 'Спільний',
  1604. SHARED_TWEETS: 'Спільні твіти',
  1605. SHOW: 'Показати',
  1606. SHOW_MORE_REPLIES: 'Показати більше відповідей',
  1607. SORT_REPLIES: 'Сортувати відповіді',
  1608. TURN_OFF_QUOTE_TWEETS: 'Вимкнути цитовані твіти',
  1609. TURN_OFF_RETWEETS: 'Вимкнути ретвіти',
  1610. TURN_ON_RETWEETS: 'Увімкнути ретвіти',
  1611. TWEET: 'Твіт',
  1612. TWEETS: 'Твіти',
  1613. TWEET_ALL: 'Твітнути все',
  1614. TWEET_INTERACTIONS: 'Взаємодія твітів',
  1615. TWEET_YOUR_REPLY: 'Твітніть свою відповідь!',
  1616. TWITTER: 'Твіттер',
  1617. UNDO_RETWEET: 'Скасувати ретвіт',
  1618. VIEW: 'Переглянути',
  1619. WHATS_HAPPENING: 'Що відбувається?',
  1620. },
  1621. ur: {
  1622. ADD_MUTED_WORD: 'میوٹ شدہ لفظ شامل کریں',
  1623. GROK_ACTIONS: 'Grok actions',
  1624. HOME: 'ہوم',
  1625. LIKES: 'لائک',
  1626. MUTE_THIS_CONVERSATION: 'اس گفتگو کو میوٹ کریں',
  1627. QUOTE: 'نقل کریں',
  1628. QUOTES: 'منقول',
  1629. QUOTE_TWEET: 'ٹویٹ کا حوالہ دیں',
  1630. QUOTE_TWEETS: 'ٹویٹ کو نقل کرو',
  1631. RETWEET: 'ریٹویٹ',
  1632. RETWEETED_BY: 'جنہوں نے ریٹویٹ کیا',
  1633. RETWEETS: 'ریٹویٹس',
  1634. SHARED: 'مشترکہ',
  1635. SHARED_TWEETS: 'مشترکہ ٹویٹس',
  1636. SHOW: 'دکھائیں',
  1637. SHOW_MORE_REPLIES: 'مزید جوابات دکھائیں',
  1638. TURN_OFF_QUOTE_TWEETS: 'ٹویٹ کو نقل کرنا بند کریں',
  1639. TURN_OFF_RETWEETS: 'ری ٹویٹس غیر فعال کریں',
  1640. TURN_ON_RETWEETS: 'ری ٹویٹس غیر فعال کریں',
  1641. TWEET: 'ٹویٹ',
  1642. TWEETS: 'ٹویٹس',
  1643. TWEET_ALL: 'سب کو ٹویٹ کریں',
  1644. TWEET_INTERACTIONS: 'ٹویٹ تعاملات',
  1645. TWITTER: 'ٹوئٹر',
  1646. UNDO_RETWEET: 'ری ٹویٹ کو کالعدم کریں',
  1647. VIEW: 'دیکھیں',
  1648. WHATS_HAPPENING: 'کیا ہو رہا ہے؟',
  1649. },
  1650. vi: {
  1651. ADD_MUTED_WORD: 'Thêm từ tắt tiếng',
  1652. GROK_ACTIONS: 'Hành động của Grok',
  1653. HOME: 'Trang chủ',
  1654. LIKES: 'Lượt thích',
  1655. MOST_RELEVANT: 'Liên quan nhất',
  1656. MUTE_THIS_CONVERSATION: 'Tắt tiếng cuộc trò chuyện này',
  1657. POST_ALL: 'Đăng tất cả',
  1658. POST_UNAVAILABLE: 'Không có bài đăng này.',
  1659. PROFILE_SUMMARY: 'Tóm tắt hồ sơ',
  1660. QUOTE: 'Trích dẫn',
  1661. QUOTES: 'Trích dẫn',
  1662. QUOTE_TWEET: 'Trích dẫn Tweet',
  1663. QUOTE_TWEETS: 'Tweet trích dẫn',
  1664. REPOST: 'Đăng lại',
  1665. REPOSTS: 'Bài đăng lại',
  1666. RETWEET: 'Tweet lại',
  1667. RETWEETED_BY: 'Được Tweet lại bởi',
  1668. RETWEETS: 'Các Tweet lại',
  1669. SHARED: 'Đã chia sẻ',
  1670. SHARED_TWEETS: 'Tweet được chia sẻ',
  1671. SHOW: 'Hiện',
  1672. SHOW_MORE_REPLIES: 'Hiển thị thêm trả lời',
  1673. SORT_REPLIES: 'Sắp xếp câu trả lời',
  1674. TURN_OFF_QUOTE_TWEETS: 'Tắt Tweet trích dẫn',
  1675. TURN_OFF_RETWEETS: 'Tắt Tweet lại',
  1676. TURN_ON_RETWEETS: 'Bật Tweet lại',
  1677. TWEETS: 'Tweet',
  1678. TWEET_ALL: 'Đăng Tweet tất cả',
  1679. TWEET_INTERACTIONS: 'Tương tác Tweet',
  1680. TWEET_YOUR_REPLY: 'Đăng Tweet câu trả lời của bạn!',
  1681. UNDO_RETWEET: 'Hoàn tác Tweet lại',
  1682. VIEW: 'Xem',
  1683. WHATS_HAPPENING: 'Chuyện gì đang xảy ra?',
  1684. },
  1685. 'zh-Hant': {
  1686. ADD_MUTED_WORD: '加入靜音文字',
  1687. GROK_ACTIONS: 'Grok 動作',
  1688. HOME: '首頁',
  1689. LIKES: '喜歡的內容',
  1690. MOST_RELEVANT: '最相關',
  1691. MUTE_THIS_CONVERSATION: '將此對話靜音',
  1692. POST_ALL: '全部發佈',
  1693. POST_UNAVAILABLE: '此貼文無法查看。',
  1694. PROFILE_SUMMARY: '個人檔案摘要',
  1695. QUOTE: '引用',
  1696. QUOTES: '引用',
  1697. QUOTE_TWEET: '引用推文',
  1698. QUOTE_TWEETS: '引用的推文',
  1699. REPOST: '轉發',
  1700. REPOSTS: '轉發',
  1701. RETWEET: '轉推',
  1702. RETWEETED_BY: '已被轉推',
  1703. RETWEETS: '轉推',
  1704. SHARED: '共享',
  1705. SHARED_TWEETS: '分享的推文',
  1706. SHOW: '顯示',
  1707. SHOW_MORE_REPLIES: '顯示更多回覆',
  1708. SORT_REPLIES: '將回覆排序',
  1709. TURN_OFF_QUOTE_TWEETS: '關閉引用的推文',
  1710. TURN_OFF_RETWEETS: '關閉轉推',
  1711. TURN_ON_RETWEETS: '開啟轉推',
  1712. TWEET: '推文',
  1713. TWEETS: '推文',
  1714. TWEET_ALL: '推全部內容',
  1715. TWEET_INTERACTIONS: '推文互動',
  1716. TWEET_YOUR_REPLY: '推你的回覆!',
  1717. UNDO_RETWEET: '取消轉推',
  1718. VIEW: '查看',
  1719. WHATS_HAPPENING: '發生什麼事?',
  1720. },
  1721. zh: {
  1722. ADD_MUTED_WORD: '添加要隐藏的字词',
  1723. GROK_ACTIONS: 'Grok 操作',
  1724. HOME: '主页',
  1725. LIKES: '喜欢',
  1726. MOST_RELEVANT: '最相关',
  1727. MUTE_THIS_CONVERSATION: '隐藏此对话',
  1728. POST_ALL: '全部发帖',
  1729. POST_UNAVAILABLE: '这个帖子不可用。',
  1730. PROFILE_SUMMARY: '个人资料概要',
  1731. QUOTE: '引用',
  1732. QUOTES: '引用',
  1733. QUOTE_TWEET: '引用推文',
  1734. QUOTE_TWEETS: '引用推文',
  1735. REPOST: '转帖',
  1736. REPOSTS: '转帖',
  1737. RETWEET: '转推',
  1738. RETWEETED_BY: '转推者',
  1739. RETWEETS: '转推',
  1740. SHARED: '共享',
  1741. SHARED_TWEETS: '分享的推文',
  1742. SHOW: '显示',
  1743. SHOW_MORE_REPLIES: '显示更多回复',
  1744. SORT_REPLIES: '对回复排序',
  1745. TURN_OFF_QUOTE_TWEETS: '关闭引用推文',
  1746. TURN_OFF_RETWEETS: '关闭转推',
  1747. TURN_ON_RETWEETS: '开启转推',
  1748. TWEET: '推文',
  1749. TWEETS: '推文',
  1750. TWEET_ALL: '全部发推',
  1751. TWEET_INTERACTIONS: '推文互动',
  1752. TWEET_YOUR_REPLY: '发布你的回复!',
  1753. UNDO_RETWEET: '撤销转推',
  1754. VIEW: '查看',
  1755. WHATS_HAPPENING: '发生了什么?',
  1756. },
  1757. }
  1758.  
  1759. /**
  1760. * @param {import("./types").LocaleKey} code
  1761. * @returns {string}
  1762. */
  1763. function getString(code) {
  1764. return (locales[lang] || locales['en'])[code] || locales['en'][code];
  1765. }
  1766. //#endregion
  1767.  
  1768. //#region Constants
  1769. /** @enum {string} */
  1770. const PagePaths = {
  1771. ACCESSIBILITY_SETTINGS: '/settings/accessibility',
  1772. ADD_MUTED_WORD: '/settings/add_muted_keyword',
  1773. BOOKMARKS: '/i/bookmarks',
  1774. COMPOSE_MESSAGE: '/messages/compose',
  1775. COMPOSE_TWEET: '/compose/post',
  1776. CONNECT: '/i/connect',
  1777. DISPLAY_SETTINGS: '/settings/display',
  1778. HOME: '/home',
  1779. NOTIFICATION_TIMELINE: '/i/timeline',
  1780. PROFILE_SETTINGS: '/settings/profile',
  1781. SEARCH: '/search',
  1782. TIMELINE_SETTINGS: '/home/pinned/edit',
  1783. }
  1784.  
  1785. /** @enum {string} */
  1786. const Selectors = {
  1787. BLOCK_MENU_ITEM: '[data-testid="block"]',
  1788. DESKTOP_TIMELINE_HEADER: 'div[data-testid="primaryColumn"] > div > div:first-of-type',
  1789. DISPLAY_DONE_BUTTON_DESKTOP: '#layers button[role="button"]:not([aria-label])',
  1790. DISPLAY_DONE_BUTTON_MOBILE: 'main button[role="button"]:not([aria-label])',
  1791. MODAL_TIMELINE: 'section > h1 + div[aria-label] > div',
  1792. MOBILE_TIMELINE_HEADER: 'div[data-testid="TopNavBar"]',
  1793. MORE_DIALOG: 'div[aria-labelledby="modal-header"]',
  1794. NAV_HOME_LINK: 'a[data-testid="AppTabBar_Home_Link"]',
  1795. PRIMARY_COLUMN: 'div[data-testid="primaryColumn"]',
  1796. PRIMARY_NAV_DESKTOP: 'header nav',
  1797. PRIMARY_NAV_MOBILE: '#layers nav',
  1798. PROMOTED_TWEET_CONTAINER: '[data-testid="placementTracking"]',
  1799. SIDEBAR: 'div[data-testid="sidebarColumn"]',
  1800. SIDEBAR_WRAPPERS: 'div[data-testid="sidebarColumn"] > div > div > div > div > div',
  1801. SORT_REPLIES_PATH: 'svg path[d="M14 6V3h2v8h-2V8H3V6h11zm7 2h-3.5V6H21v2zM8 16v-3h2v8H8v-3H3v-2h5zm13 2h-9.5v-2H21v2z"]',
  1802. TIMELINE: 'div[data-testid="primaryColumn"] section > h1 + div[aria-label] > div',
  1803. TIMELINE_HEADING: 'h2[role="heading"]',
  1804. TWEET: '[data-testid="tweet"]',
  1805. VERIFIED_TICK: 'svg[data-testid="icon-verified"]',
  1806. X_LOGO_PATH: 'svg path[d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"]',
  1807. X_DARUMA_LOGO_PATH: 'svg path[d="M18.436 1.92h3.403l-7.433 8.495 8.745 11.563h-6.849l-5.363-7.012-6.136 7.012H1.4l7.951-9.088L.96 1.92h7.02l4.848 6.41 5.608-6.41zm-1.194 18.021h1.886L6.958 3.851H4.933l12.308 16.09z"]',
  1808. }
  1809.  
  1810. /** @enum {string} */
  1811. const Svgs = {
  1812. BLUE_LOGO_PATH: 'M16.5 3H2v18h15c3.038 0 5.5-2.46 5.5-5.5 0-1.4-.524-2.68-1.385-3.65-.08-.09-.089-.22-.023-.32.574-.87.908-1.91.908-3.03C22 5.46 19.538 3 16.5 3zm-.796 5.99c.457-.05.892-.17 1.296-.35-.302.45-.684.84-1.125 1.15.004.1.006.19.006.29 0 2.94-2.269 6.32-6.421 6.32-1.274 0-2.46-.37-3.459-1 .177.02.357.03.539.03 1.057 0 2.03-.35 2.803-.95-.988-.02-1.821-.66-2.109-1.54.138.03.28.04.425.04.206 0 .405-.03.595-.08-1.033-.2-1.811-1.1-1.811-2.18v-.03c.305.17.652.27 1.023.28-.606-.4-1.004-1.08-1.004-1.85 0-.4.111-.78.305-1.11 1.113 1.34 2.775 2.22 4.652 2.32-.038-.17-.058-.33-.058-.51 0-1.23 1.01-2.22 2.256-2.22.649 0 1.235.27 1.647.7.514-.1.997-.28 1.433-.54-.168.52-.526.96-.992 1.23z',
  1813. MUTE: '<g><path d="M18 6.59V1.2L8.71 7H5.5C4.12 7 3 8.12 3 9.5v5C3 15.88 4.12 17 5.5 17h2.09l-2.3 2.29 1.42 1.42 15.5-15.5-1.42-1.42L18 6.59zm-8 8V8.55l6-3.75v3.79l-6 6zM5 9.5c0-.28.22-.5.5-.5H8v6H5.5c-.28 0-.5-.22-.5-.5v-5zm6.5 9.24l1.45-1.45L16 19.2V14l2 .02v8.78l-6.5-4.06z"></path></g>',
  1814. RETWEET: '<g><path d="M4.5 3.88l4.432 4.14-1.364 1.46L5.5 7.55V16c0 1.1.896 2 2 2H13v2H7.5c-2.209 0-4-1.79-4-4V7.55L1.432 9.48.068 8.02 4.5 3.88zM16.5 6H11V4h5.5c2.209 0 4 1.79 4 4v8.45l2.068-1.93 1.364 1.46-4.432 4.14-4.432-4.14 1.364-1.46 2.068 1.93V8c0-1.1-.896-2-2-2z"></path></g>',
  1815. RETWEETS_OFF: '<g><path d="M3.707 21.707l18-18-1.414-1.414-2.088 2.088C17.688 4.137 17.11 4 16.5 4H11v2h5.5c.028 0 .056 0 .084.002l-10.88 10.88c-.131-.266-.204-.565-.204-.882V7.551l2.068 1.93 1.365-1.462L4.5 3.882.068 8.019l1.365 1.462 2.068-1.93V16c0 .871.278 1.677.751 2.334l-1.959 1.959 1.414 1.414zM18.5 9h2v7.449l2.068-1.93 1.365 1.462-4.433 4.137-4.432-4.137 1.365-1.462 2.067 1.93V9zm-8.964 9l-2 2H13v-2H9.536z"></path></g>',
  1816. TWITTER_FEATHER_PLUS_PATH: 'M23 3c-6.62-.1-10.38 2.421-13.05 6.03C7.29 12.61 6 17.331 6 22h2c0-1.007.07-2.012.19-3H12c4.1 0 7.48-3.082 7.94-7.054C22.79 10.147 23.17 6.359 23 3zm-7 8h-1.5v2H16c.63-.016 1.2-.08 1.72-.188C16.95 15.24 14.68 17 12 17H8.55c.57-2.512 1.57-4.851 3-6.78 2.16-2.912 5.29-4.911 9.45-5.187C20.95 8.079 19.9 11 16 11zM4 9V6H1V4h3V1h2v3h3v2H6v3H4z',
  1817. TWITTER_HOME_ACTIVE_PATH: 'M12 1.696L.622 8.807l1.06 1.696L3 9.679V19.5C3 20.881 4.119 22 5.5 22h13c1.381 0 2.5-1.119 2.5-2.5V9.679l1.318.824 1.06-1.696L12 1.696zM12 16.5c-1.933 0-3.5-1.567-3.5-3.5s1.567-3.5 3.5-3.5 3.5 1.567 3.5 3.5-1.567 3.5-3.5 3.5z',
  1818. TWITTER_HOME_INACTIVE_PATH: 'M12 9c-2.209 0-4 1.791-4 4s1.791 4 4 4 4-1.791 4-4-1.791-4-4-4zm0 6c-1.105 0-2-.895-2-2s.895-2 2-2 2 .895 2 2-.895 2-2 2zm0-13.304L.622 8.807l1.06 1.696L3 9.679V19.5C3 20.881 4.119 22 5.5 22h13c1.381 0 2.5-1.119 2.5-2.5V9.679l1.318.824 1.06-1.696L12 1.696zM19 19.5c0 .276-.224.5-.5.5h-13c-.276 0-.5-.224-.5-.5V8.429l7-4.375 7 4.375V19.5z',
  1819. TWITTER_LOGO_PATH: 'M23.643 4.937c-.835.37-1.732.62-2.675.733.962-.576 1.7-1.49 2.048-2.578-.9.534-1.897.922-2.958 1.13-.85-.904-2.06-1.47-3.4-1.47-2.572 0-4.658 2.086-4.658 4.66 0 .364.042.718.12 1.06-3.873-.195-7.304-2.05-9.602-4.868-.4.69-.63 1.49-.63 2.342 0 1.616.823 3.043 2.072 3.878-.764-.025-1.482-.234-2.11-.583v.06c0 2.257 1.605 4.14 3.737 4.568-.392.106-.803.162-1.227.162-.3 0-.593-.028-.877-.082.593 1.85 2.313 3.198 4.352 3.234-1.595 1.25-3.604 1.995-5.786 1.995-.376 0-.747-.022-1.112-.065 2.062 1.323 4.51 2.093 7.14 2.093 8.57 0 13.255-7.098 13.255-13.254 0-.2-.005-.402-.014-.602.91-.658 1.7-1.477 2.323-2.41z',
  1820. X_HOME_ACTIVE_PATH: 'M21.591 7.146L12.52 1.157c-.316-.21-.724-.21-1.04 0l-9.071 5.99c-.26.173-.409.456-.409.757v13.183c0 .502.418.913.929.913H9.14c.51 0 .929-.41.929-.913v-7.075h3.909v7.075c0 .502.417.913.928.913h6.165c.511 0 .929-.41.929-.913V7.904c0-.301-.158-.584-.408-.758z',
  1821. X_HOME_INACTIVE_PATH: 'M21.591 7.146L12.52 1.157c-.316-.21-.724-.21-1.04 0l-9.071 5.99c-.26.173-.409.456-.409.757v13.183c0 .502.418.913.929.913h6.638c.511 0 .929-.41.929-.913v-7.075h3.008v7.075c0 .502.418.913.929.913h6.639c.51 0 .928-.41.928-.913V7.904c0-.301-.158-.584-.408-.758zM20 20l-4.5.01.011-7.097c0-.502-.418-.913-.928-.913H9.44c-.511 0-.929.41-.929.913L8.5 20H4V8.773l8.011-5.342L20 8.764z',
  1822. PLUS_PATH: 'M11 11V4h2v7h7v2h-7v7h-2v-7H4v-2h7z',
  1823. }
  1824.  
  1825. /** @enum {string} */
  1826. const Images = {
  1827. TWITTER_FAVICON: 'data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAA0pJREFUWAntVk1oE1EQnnlJbFK3KUq9VJPYWgQVD/5QD0qpfweL1YJQoZAULBRPggp6kB78PQn14kHx0jRB0UO9REVFb1YqVBEsbZW2SbVS0B6apEnbbMbZ6qbZdTempqCHPAjvzcw3P5mdmfcAiquYgX+cAVwu/+5AdDMQnSPCHUhQA0hf+Rxy2OjicIvzm+qnKhito0qpb2wvJhWeJgCPP7oPELeHvdJ1VSGf3eOPnSWga0S0Qo9HxEkEusDBuNjbEca8G291nlBxmgDc/ukuIvAJxI6wr+yKCsq1ewLxQ2lZfpQLo8oQ4ZXdCkfnACrGWpyDCl+oQmVn5xuVPU102e2P3qoJkFOhzVb9S7KSnL5jJs/mI+As01PJFPSlZeFSZZoAGBRXBZyq9lk5NrC+e7pJ5en30c+JWk59pZ5vRDOuhAD381c/H/FKz1SMNgCE16rg505r5TT0uLqme93d0fbq+1SeLSeU83Ke0RHYFPGVPcjQfNDUwIa7M665+dQAEEjZoMwZMcEF9RxIDAgBQ2mCcqJ0Z0b+h4MNbZ4RnyOSDbNmE2iRk5jCNgIIckFoZAs4IgfLGrlKGjkzS16iwj6pV9I4mUvCPf73JVytH9nRJj24QHrqU8NCIWrMaGqAC+Ut/3ZzAS63cx4v2K/x/IvQBOCwWzu5KmJGwEJ5PIgeG9nQBDDcXPpFoDjJ7ThvBC6EZxXWkJG+JgAFwGM4KBAOcibeGCn8FQ/hyajXPmSk+1sACogn4hYk7OdiHDFSWipPkPWSmY6mCzIghEEuxJvcEYUvxIdhX2mvmSHDDPBF9AJRnDZTyp+P40671JYLbxiAohDxSTfQIg4oNxgPzCWPHaWQBViOf2jGqVwBaEaxGbAqOFMrp+SefC8eNhoFIY5lXzpmtnMGUB2IbU3JdIqVW9m5zcxINn/hAYKiIexdaTh4srHKORMAP0b28PNgJyGt5gvHzQVYx91QpVcwpRFl/p63HSR1DLbid1OcTpAJQOG7u+KH+aI5Qwj13IsamU5vkUSIc8uGLDa8OtoivV8U5HcydFLtT7hlSDVy2nfxI2Ibg9awuVU8IeJAOMF5m2B6jFs1tM5R9rS3GRP5uSuiihn4DzPwA7z7GDH+43gqAAAAAElFTkSuQmCC',
  1828. TWITTER_PIP_FAVICON: 'data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAALASURBVHgB7VZNchJBFP5eM9FoRWV2WiZmbmBuIJ4g5ASBRWJlRXIC4ASQVUqxCo4QTwDegJzAiYlFXM1YZWmVQD9fQ6YyAwMMGBZW8i2G6e7He1+/3wHuOih4+fWieJhiKsirA0ZbE44fXZUaWDIGBH4/L+UUUB897DMfPf5ermKJUOaRIhTiDlNEBSwZlnkwY2vCuYOEWD/xMrCoKC41utISRlcc3Or2dfnqwHbDcj9X0fbztn9DAHxOoM0xrZILSIBXtR9F0VGKbJIhz7kVi3Lr770yAz4p2iYm188/awVi6lo4Ns4mETEDLz94uTHjIxDDRaWoohhOSjwi/9mKEFjtlKsayAuRM7M2HmFJwCRVIIqLSAAJjS822v0Vaip1E1oKC6XrXtrExjnxnJ6ldoVKFj0+ujywW3FKTTzJoibmAXP+Yt9uBEsrfLbWRelJzS/0B8z4WoKa6zW/1dd83Hlnn0Z0peAQkqNHvNPZi+qIELBWUNU97LLJ4hDESMZSlNmo+b5UTEvC85m0JCipTQREE+BhdzypIwSkLvyn4LKYrEzQkSZCloiyw+xJbnygfxX+VAJrPWnBoC9ixBXdDm4XflD7YajIinFq3L0E45J7fBa3HyEg7mhgeWjPJODu223J/iMsATzhcmp04+ueXTW1OsiD2zIuVfNNLockBAyIkdaaPxHGs3YR0JTQWnGbWkFCQZX5imwCmBoX++nGpONYD1zu2S0a9IN/g3jSNcNnqsy0ww2ZdPJzCKLXWAAy1N6ay2BRAgEcGZ+aqDnaoqdbjw6dhQgYwz1S2xKOQyQ0Phy7vDPr5iH5ITY+elmtpddLFyQzZBTP3xGl3FJ95NzQJ1hiAgMSw5jnJOZvMA/EMBNKSW89kUAAp+45+g+yojRjljL9NoP4GxdLYzk334vy3lYP0HBjhsw97vHf4C/b8RLHAOr+CQAAAABJRU5ErkJggg==',
  1829. }
  1830.  
  1831. const THEME_BLUE = 'rgb(29, 155, 240)'
  1832. const THEME_COLORS = new Map([
  1833. ['blue500', THEME_BLUE],
  1834. ['yellow500', 'rgb(255, 212, 0)'],
  1835. ['magenta500', 'rgb(249, 24, 128)'],
  1836. ['purple500', 'rgb(120, 86, 255)'],
  1837. ['orange500', 'rgb(255, 122, 0)'],
  1838. ['green500', 'rgb(0, 186, 124)'],
  1839. ])
  1840. const HIGH_CONTRAST_LIGHT = new Map([
  1841. ['blue500', 'rgb(0, 56, 134)'],
  1842. ['yellow500', 'rgb(111, 62, 0)'],
  1843. ['magenta500', 'rgb(137, 10, 70)'],
  1844. ['purple500', 'rgb(82, 52, 183)'],
  1845. ['orange500', 'rgb(137, 43, 0)'],
  1846. ['green500', 'rgb(0, 97, 61)'],
  1847. ])
  1848. const HIGH_CONTRAST_DARK = new Map([
  1849. ['blue500', 'rgb(107, 201, 251)'],
  1850. ['yellow500', 'rgb(255, 235, 107)'],
  1851. ['magenta500', 'rgb(251, 112, 176)'],
  1852. ['purple500', 'rgb(172, 151, 255)'],
  1853. ['orange500', 'rgb(255, 173, 97)'],
  1854. ['green500', 'rgb(97, 214, 163)'],
  1855. ])
  1856. // <body> pseudo-selector for pages the full-width content feature works on
  1857. const FULL_WIDTH_BODY_PSEUDO = ':is(.Community, .List, .HomeTimeline)'
  1858. // Matches any notification count at the start of the title
  1859. const TITLE_NOTIFICATION_RE = /^\(\d+\+?\) /
  1860. // The Communities nav item takes you to /yourusername/communities
  1861. const URL_COMMUNITIES_RE = /^\/[a-zA-Z\d_]{1,20}\/communities\/?$/
  1862. const URL_COMMUNITY_RE = /^\/i\/communities\/\d+(?:\/about)?\/?$/
  1863. const URL_COMMUNITY_MEMBERS_RE = /^\/i\/communities\/\d+\/(?:members|moderators)\/?$/
  1864. const URL_DISCOVER_COMMUNITIES_RE = /^\/i\/communities\/suggested\/?/
  1865. const URL_LIST_RE = /\/i\/lists\/\d+\/?$/
  1866. const URL_MEDIA_RE = /\/(?:photo|video)\/\d\/?$/
  1867. const URL_MEDIAVIEWER_RE = /^\/[a-zA-Z\d_]{1,20}\/status\/\d+\/mediaviewer$/i
  1868. // Matches URLs which show one of the tabs on a user profile page
  1869. const URL_PROFILE_RE = /^\/([a-zA-Z\d_]{1,20})(?:\/(affiliates|with_replies|superfollows|highlights|articles|media|likes))?\/?$/
  1870. // Matches URLs which show a user's Followers you know / Followers / Following tab
  1871. const URL_PROFILE_FOLLOWS_RE = /^\/[a-zA-Z\d_]{1,20}\/(?:verified_followers|follow(?:ing|ers|ers_you_follow)|creator-subscriptions\/subscriptions)\/?$/
  1872. const URL_TWEET_RE = /^\/([a-zA-Z\d_]{1,20})\/status\/(\d+)\/?$/
  1873. const URL_TWEET_ENGAGEMENT_RE = /^\/[a-zA-Z\d_]{1,20}\/status\/\d+\/(quotes|retweets|reposts|likes)\/?$/
  1874.  
  1875. // The Twitter Media Assist exension adds a new button at the end of the action
  1876. // bar (#346)
  1877. const TWITTER_MEDIA_ASSIST_BUTTON_SELECTOR = '.tva-download-icon, .tva-modal-download-icon'
  1878. //#endregion
  1879.  
  1880. //#region Variables
  1881. /**
  1882. * The quoted Tweet associated with a caret menu that's just been opened.
  1883. * @type {import("./types").QuotedTweet}
  1884. */
  1885. let quotedTweet = null
  1886.  
  1887. /** `true` when a 'Block @${user}' menu item was seen in the last popup. */
  1888. let blockMenuItemSeen = false
  1889.  
  1890. /** `true` if we're opening the Sort replies menu to change settings. */
  1891. let changingSortReplies = false
  1892.  
  1893. /** Notification count in the title (including trailing space), e.g. `'(1) '`. */
  1894. let currentNotificationCount = ''
  1895.  
  1896. /** Title of the current page, without the `' / Twitter'` suffix. */
  1897. let currentPage = ''
  1898.  
  1899. /** Current `location.pathname`. */
  1900. let currentPath = ''
  1901.  
  1902. /**
  1903. * React Native stylesheet rule for the blur filter for sensitive content.
  1904. * @type {CSSStyleRule}
  1905. */
  1906. let filterBlurRule = null
  1907.  
  1908. /**
  1909. * React Native stylesheett rule for the Chirp font-family.
  1910. * @type {CSSStyleRule}
  1911. */
  1912. let fontFamilyRule = null
  1913.  
  1914. /** @type {string} */
  1915. let fontSize = null
  1916.  
  1917. /** Set to `true` when a Home/Following heading or Home nav link is used. */
  1918. let homeNavigationIsBeingUsed = false
  1919.  
  1920. /** Set to `true` when the media modal is open on desktop. */
  1921. let isDesktopMediaModalOpen = false
  1922.  
  1923. /** Set to `true` when the compose tweet modal is open on desktop. */
  1924. let isDesktopComposeTweetModalOpen = false
  1925.  
  1926. /**
  1927. * Cache for the last page title which was used for the Home timeline.
  1928. * @type {string}
  1929. */
  1930. let lastHomeTimelineTitle = null
  1931.  
  1932. /**
  1933. * MutationObservers active on the current modal.
  1934. * @type {import("./types").Disconnectable[]}
  1935. */
  1936. let modalObservers = []
  1937.  
  1938. /**
  1939. * `true` after the app has initialised.
  1940. * @type {boolean}
  1941. */
  1942. let observingPageChanges = false
  1943.  
  1944. /**
  1945. * MutationObservers active on the current page, or anything else we want to
  1946. * clean up when the user moves off the current page.
  1947. * @type {import("./types").NamedMutationObserver[]}
  1948. */
  1949. let pageObservers = []
  1950.  
  1951. /** `true` when a 'Pin to your profile' menu item was seen in the last popup. */
  1952. let pinMenuItemSeen = false
  1953.  
  1954. /** @type {number} */
  1955. let selectedHomeTabIndex = -1
  1956.  
  1957. /**
  1958. * Title for the fake timeline used to separate out retweets and quote tweets.
  1959. * @type {string}
  1960. */
  1961. let separatedTweetsTimelineTitle = null
  1962.  
  1963. /**
  1964. * The current "Color" setting.
  1965. * @type {string}
  1966. */
  1967. let themeColor = THEME_BLUE
  1968.  
  1969. /**
  1970. * Tab to switch to after navigating to the Tweet interactions page.
  1971. * @type {string}
  1972. */
  1973. let tweetInteractionsTab = null
  1974.  
  1975. /**
  1976. * `true` when "For you" was the last tab selected on the Home timeline.
  1977. */
  1978. let wasForYouTabSelected = false
  1979.  
  1980. function isOnAccessibilitySettingsPage() {
  1981. return currentPath == PagePaths.ACCESSIBILITY_SETTINGS
  1982. }
  1983.  
  1984. function isOnBookmarksPage() {
  1985. return currentPath.startsWith(PagePaths.BOOKMARKS)
  1986. }
  1987.  
  1988. function isOnCommunitiesPage() {
  1989. return URL_COMMUNITIES_RE.test(currentPath)
  1990. }
  1991.  
  1992. function isOnCommunityPage() {
  1993. return URL_COMMUNITY_RE.test(currentPath)
  1994. }
  1995.  
  1996. function isOnCommunityMembersPage() {
  1997. return URL_COMMUNITY_MEMBERS_RE.test(currentPath)
  1998. }
  1999.  
  2000. function isOnDiscoverCommunitiesPage() {
  2001. return URL_DISCOVER_COMMUNITIES_RE.test(currentPath)
  2002. }
  2003.  
  2004. function isOnDisplaySettingsPage() {
  2005. return currentPath == PagePaths.DISPLAY_SETTINGS
  2006. }
  2007.  
  2008. function isOnExplorePage() {
  2009. return currentPath == '/explore' || currentPath.startsWith('/explore/')
  2010. }
  2011.  
  2012. function isOnFollowListPage() {
  2013. return URL_PROFILE_FOLLOWS_RE.test(currentPath)
  2014. }
  2015.  
  2016. function isOnIndividualTweetPage() {
  2017. return URL_TWEET_RE.test(currentPath)
  2018. }
  2019.  
  2020. function isOnListPage() {
  2021. return URL_LIST_RE.test(currentPath)
  2022. }
  2023.  
  2024. function isOnHomeTimelinePage() {
  2025. return currentPath == PagePaths.HOME
  2026. }
  2027.  
  2028. function isOnMessagesPage() {
  2029. return currentPath.startsWith('/messages')
  2030. }
  2031.  
  2032. function isOnNotificationsPage() {
  2033. return currentPath.startsWith('/notifications')
  2034. }
  2035.  
  2036. function isOnProfilePage() {
  2037. let profilePathUsername = currentPath.match(URL_PROFILE_RE)?.[1]
  2038. if (!profilePathUsername) return false
  2039. // twitter.com/user and its sub-URLs put @user in the title
  2040. return currentPage.toLowerCase().includes(`${ltr ? '@' : ''}${profilePathUsername.toLowerCase()}${!ltr ? '@' : ''}`)
  2041. }
  2042.  
  2043. function isOnQuoteTweetsPage() {
  2044. let match = currentPath.match(URL_TWEET_ENGAGEMENT_RE)
  2045. return match?.[1] == 'quotes'
  2046. }
  2047.  
  2048. function isOnSearchPage() {
  2049. return currentPath.startsWith('/search') || currentPath.startsWith('/hashtag/')
  2050. }
  2051.  
  2052. function isOnSeparatedTweetsTimeline() {
  2053. return currentPage == separatedTweetsTimelineTitle
  2054. }
  2055.  
  2056. function isOnSettingsPage() {
  2057. return currentPath.startsWith('/settings')
  2058. }
  2059.  
  2060. function shouldHideSidebar() {
  2061. return isOnExplorePage() || isOnDiscoverCommunitiesPage()
  2062. }
  2063.  
  2064. function shouldShowSeparatedTweetsTab() {
  2065. return config.retweets == 'separate' || config.quoteTweets == 'separate'
  2066. }
  2067. //#endregion
  2068.  
  2069. //#region Utility functions
  2070. /**
  2071. * @param {string} role
  2072. * @return {HTMLStyleElement}
  2073. */
  2074. function addStyle(role) {
  2075. let $style = document.createElement('style')
  2076. $style.dataset.insertedBy = 'control-panel-for-twitter'
  2077. $style.dataset.role = role
  2078. document.head.appendChild($style)
  2079. return $style
  2080. }
  2081.  
  2082. /**
  2083. * @param {Element} $svg
  2084. */
  2085. function blueCheck($svg) {
  2086. if (!$svg) {
  2087. warn('blueCheck was given', $svg)
  2088. return
  2089. }
  2090. $svg.classList.add('tnt_blue_check')
  2091. // Safari doesn't support using `d: path(…)` to replace paths in an SVG, so
  2092. // we have to manually patch the path in it.
  2093. if (isSafari && config.twitterBlueChecks == 'replace') {
  2094. $svg.firstElementChild.firstElementChild.setAttribute('d', Svgs.BLUE_LOGO_PATH)
  2095. }
  2096. }
  2097.  
  2098. /**
  2099. * @param {Element} $svgPath
  2100. */
  2101. function twitterLogo($svgPath) {
  2102. // Safari doesn't support using `d: path(…)` to replace paths in an SVG, so
  2103. // we have to manually patch the path in it.
  2104. $svgPath.setAttribute('d', Svgs.TWITTER_LOGO_PATH)
  2105. $svgPath.classList.add('tnt_logo')
  2106. }
  2107.  
  2108. /**
  2109. * @param {Element} $svgPath
  2110. */
  2111. function homeIcon($svgPath) {
  2112. // Safari doesn't support using `d: path(…)` to replace paths in an SVG, so
  2113. // we have to manually patch the path in it.
  2114. let replacementPath = {
  2115. [Svgs.X_HOME_ACTIVE_PATH]: Svgs.TWITTER_HOME_ACTIVE_PATH,
  2116. [Svgs.X_HOME_INACTIVE_PATH]: Svgs.TWITTER_HOME_INACTIVE_PATH,
  2117. }[$svgPath.getAttribute('d')]
  2118. if (replacementPath) {
  2119. $svgPath.setAttribute('d', replacementPath)
  2120. }
  2121. }
  2122.  
  2123. /**
  2124. * @param {string} str
  2125. * @return {string}
  2126. */
  2127. function dedent(str) {
  2128. str = str.replace(/^[ \t]*\r?\n/, '')
  2129. let indent = /^[ \t]+/m.exec(str)
  2130. if (indent) str = str.replace(new RegExp('^' + indent[0], 'gm'), '')
  2131. return str.replace(/(\r?\n)[ \t]+$/, '$1')
  2132. }
  2133.  
  2134. /**
  2135. * @param {string} name
  2136. * @param {import("./types").Disconnectable[]} observers
  2137. */
  2138. function disconnectObserver(name, observers) {
  2139. for (let i = observers.length -1; i >= 0; i--) {
  2140. let observer = observers[i]
  2141. if ('name' in observer && observer.name == name) {
  2142. observer.disconnect()
  2143. observers.splice(i, 1)
  2144. log(`disconnected ${name} ${observers === pageObservers ? 'page' : 'modal'} observer`)
  2145. }
  2146. }
  2147. }
  2148.  
  2149. function disconnectModalObserver(name) {
  2150. disconnectObserver(name, modalObservers)
  2151. }
  2152.  
  2153. function disconnectAllModalObservers() {
  2154. if (modalObservers.length > 0) {
  2155. log(
  2156. `disconnecting ${modalObservers.length} modal observer${s(modalObservers.length)}`,
  2157. modalObservers.map(observer => observer['name'])
  2158. )
  2159. modalObservers.forEach(observer => observer.disconnect())
  2160. modalObservers = []
  2161. }
  2162. }
  2163.  
  2164. function disconnectPageObserver(name) {
  2165. disconnectObserver(name, pageObservers)
  2166. }
  2167.  
  2168. /**
  2169. * @param {MutationRecord[]} mutations
  2170. * @param {($el: Node) => boolean | HTMLElement} fn - return `true` to use [$el]
  2171. * as the result, or return a different HTMLElement to use it as the result.
  2172. * @returns {Node | HTMLElement | null}
  2173. */
  2174. function findAddedNode(mutations, fn) {
  2175. for (let mutation of mutations) {
  2176. for (let el of mutation.addedNodes) {
  2177. let result = fn(el)
  2178. if (result) {
  2179. return result === true ? el : result
  2180. }
  2181. }
  2182. }
  2183. return null
  2184. }
  2185.  
  2186. /**
  2187. * @param {string} selector
  2188. * @param {{
  2189. * name?: string
  2190. * stopIf?: () => boolean
  2191. * timeout?: number
  2192. * context?: Document | HTMLElement
  2193. * }?} options
  2194. * @returns {Promise<HTMLElement | null>}
  2195. */
  2196. function getElement(selector, {
  2197. name = null,
  2198. stopIf = null,
  2199. timeout = Infinity,
  2200. context = document,
  2201. } = {}) {
  2202. return new Promise((resolve) => {
  2203. let startTime = Date.now()
  2204. let rafId
  2205. let timeoutId
  2206.  
  2207. function stop($element, reason) {
  2208. if ($element == null) {
  2209. warn(`stopped waiting for ${name || selector} after ${reason}`)
  2210. }
  2211. else if (Date.now() > startTime) {
  2212. log(`${name || selector} appeared after ${Date.now() - startTime}ms`)
  2213. }
  2214. if (rafId) {
  2215. cancelAnimationFrame(rafId)
  2216. }
  2217. if (timeoutId) {
  2218. clearTimeout(timeoutId)
  2219. }
  2220. resolve($element)
  2221. }
  2222.  
  2223. if (timeout !== Infinity) {
  2224. timeoutId = setTimeout(stop, timeout, null, `${timeout}ms timeout`)
  2225. }
  2226.  
  2227. function queryElement() {
  2228. let $element = context.querySelector(selector)
  2229. if ($element) {
  2230. stop($element)
  2231. }
  2232. else if (stopIf?.() === true) {
  2233. stop(null, 'stopIf condition met')
  2234. }
  2235. else {
  2236. rafId = requestAnimationFrame(queryElement)
  2237. }
  2238. }
  2239.  
  2240. queryElement()
  2241. })
  2242. }
  2243.  
  2244. function getState() {
  2245. let wrapped = $reactRoot.firstElementChild.wrappedJSObject || $reactRoot.firstElementChild
  2246. let reactPropsKey = Object.keys(wrapped).find(key => key.startsWith('__reactProps'))
  2247. if (reactPropsKey) {
  2248. let state = wrapped[reactPropsKey].children?.props?.children?.props?.store?.getState()
  2249. if (state) return state
  2250. warn('React state not found')
  2251. } else {
  2252. warn('React prop key not found')
  2253. }
  2254. }
  2255.  
  2256. function hasNewLayout() {
  2257. return getState()?.featureSwitch?.user?.config?.rweb_sourcemap_migration?.value
  2258. }
  2259.  
  2260. function getStateEntities() {
  2261. let state = getState()
  2262. if (state) {
  2263. if (state.entities) return state.entities
  2264. warn('React state entities not found')
  2265. }
  2266. }
  2267.  
  2268. function getThemeColorFromState() {
  2269. let localState = getState().settings?.local
  2270. let color = localState?.themeColor
  2271. let highContrast = localState?.highContrastEnabled
  2272. $body.classList.toggle('HighContrast', highContrast)
  2273. if (color) {
  2274. if (THEME_COLORS.has(color)) {
  2275. let colors = THEME_COLORS
  2276. if (highContrast) colors = getColorScheme() == 'Default' ? HIGH_CONTRAST_LIGHT : HIGH_CONTRAST_DARK
  2277. return colors.get(color)
  2278. }
  2279. warn(color, 'not found in THEME_COLORS')
  2280. } else {
  2281. warn('could not get settings.local.themeColor from React state')
  2282. }
  2283. }
  2284.  
  2285. /**
  2286. * Gets cached tweet info from React state.
  2287. */
  2288. function getTweetInfo(id) {
  2289. let tweetEntities = getStateEntities()?.tweets?.entities
  2290. if (tweetEntities) {
  2291. let tweetInfo = tweetEntities[id]
  2292. if (!tweetInfo) {
  2293. warn('tweet info not found')
  2294. }
  2295. return tweetInfo
  2296. } else {
  2297. warn('tweet entities not found')
  2298. }
  2299. }
  2300.  
  2301. /**
  2302. * Gets cached user info from React state.
  2303. * @returns {import("./types").UserInfoObject}
  2304. */
  2305. function getUserInfo() {
  2306. /** @type {import("./types").UserInfoObject} */
  2307. let userInfo = {}
  2308. let userEntities = getStateEntities()?.users?.entities
  2309. if (userEntities) {
  2310. for (let user of Object.values(userEntities)) {
  2311. userInfo[user.screen_name] = {
  2312. following: user.following,
  2313. followedBy: user.followed_by,
  2314. followersCount: user.followers_count,
  2315. }
  2316. }
  2317. } else {
  2318. warn('user entities not found')
  2319. }
  2320. return userInfo
  2321. }
  2322.  
  2323. /**
  2324. * @param {import("./types").Disconnectable[]} observers
  2325. * @param {string} name
  2326. */
  2327. function isObserving(observers, name) {
  2328. return observers.some(observer => 'name' in observer && observer.name == name)
  2329. }
  2330.  
  2331. function log(...args) {
  2332. if (debug) {
  2333. let page = currentPage?.replace(/(\r?\n)+/g, ' ')
  2334. console.log(`${page ? `(${
  2335. page.length < 42 ? page : page.slice(0, 42) + '…'
  2336. })` : ''}`, ...args)
  2337. }
  2338. }
  2339.  
  2340. function warn(...args) {
  2341. if (debug) {
  2342. console.log(`❗ ${currentPage ? `(${currentPage})` : ''}`, ...args)
  2343. }
  2344. }
  2345.  
  2346. function error(...args) {
  2347. console.log(`❌ ${currentPage ? `(${currentPage})` : ''}`, ...args)
  2348. }
  2349.  
  2350. /**
  2351. * @param {() => boolean} condition
  2352. * @returns {() => boolean}
  2353. */
  2354. function not(condition) {
  2355. return () => !condition()
  2356. }
  2357.  
  2358. /**
  2359. * Convenience wrapper for the MutationObserver API - the callback is called
  2360. * immediately to support using an observer and its options as a trigger for any
  2361. * change, without looking at MutationRecords.
  2362. * @param {Node} $element
  2363. * @param {MutationCallback} callback
  2364. * @param {string} name
  2365. * @param {MutationObserverInit} options
  2366. * @return {import("./types").NamedMutationObserver}
  2367. */
  2368. function observeElement($element, callback, name, options = {childList: true}) {
  2369. if (name) {
  2370. if (options.childList && callback.length > 0) {
  2371. log(`observing ${name}`, $element)
  2372. } else {
  2373. log (`observing ${name}`)
  2374. }
  2375. }
  2376.  
  2377. let observer = new MutationObserver(callback)
  2378. callback([], observer)
  2379. observer.observe($element, options)
  2380. observer['name'] = name
  2381. return observer
  2382. }
  2383.  
  2384. /**
  2385. * @param {string} page
  2386. * @returns {() => boolean}
  2387. */
  2388. function pageIsNot(page) {
  2389. return function() {
  2390. let pageChanged = page != currentPage
  2391. if (pageChanged) {
  2392. log('pageIsNot', {page, currentPage})
  2393. }
  2394. return pageChanged
  2395. }
  2396. }
  2397.  
  2398. /**
  2399. * @param {string} path
  2400. * @returns {() => boolean}
  2401. */
  2402. function pathIsNot(path) {
  2403. return () => path != currentPath
  2404. }
  2405.  
  2406. /**
  2407. * @param {number} n
  2408. * @returns {string}
  2409. */
  2410. function s(n) {
  2411. return n == 1 ? '' : 's'
  2412. }
  2413.  
  2414. /**
  2415. * @param {Element} $tweetButtonText
  2416. */
  2417. function setTweetButtonText($tweetButtonText) {
  2418. let currentText = $tweetButtonText.textContent
  2419. if (currentText == getString('TWEET') || currentText == getString('TWEET_ALL')) return
  2420. $tweetButtonText.textContent = currentText == getString('POST_ALL') ? getString('TWEET_ALL') : getString('TWEET')
  2421. }
  2422.  
  2423. function storeConfigChanges(changes) {
  2424. window.postMessage({type: 'tntConfigChange', changes})
  2425. }
  2426. //#endregion
  2427.  
  2428. //#region Global observers
  2429. const checkReactNativeStylesheet = (() => {
  2430. /** @type {number} */
  2431. let startTime
  2432.  
  2433. return function checkReactNativeStylesheet() {
  2434. startTime ??= Date.now()
  2435.  
  2436. let $style = /** @type {HTMLStyleElement} */ (document.querySelector('style#react-native-stylesheet'))
  2437. if (!$style) {
  2438. warn('React Native stylesheet not found')
  2439. return
  2440. }
  2441.  
  2442. for (let rule of $style.sheet.cssRules) {
  2443. if (!(rule instanceof CSSStyleRule)) continue
  2444.  
  2445. if (fontFamilyRule == null &&
  2446. rule.style.fontFamily?.includes('TwitterChirp') &&
  2447. !rule.style.fontFamily.includes('TwitterChirpExtendedHeavy')) {
  2448. fontFamilyRule = rule
  2449. log('found Chirp fontFamily CSS rule in React Native stylesheet')
  2450. configureFont()
  2451. }
  2452.  
  2453. if (filterBlurRule == null && rule.style.filter?.includes('blur(30px)')) {
  2454. filterBlurRule = rule
  2455. log('found filter: blur(30px) rule in React Native stylesheet', filterBlurRule)
  2456. configureDynamicCss()
  2457. }
  2458. }
  2459.  
  2460. let elapsedTime = Date.now() - startTime
  2461. if (fontFamilyRule == null || filterBlurRule == null) {
  2462. if (elapsedTime < 3000) {
  2463. setTimeout(checkReactNativeStylesheet, 100)
  2464. } else {
  2465. warn(`stopped checking React Native stylesheet after ${elapsedTime}ms`)
  2466. }
  2467. } else {
  2468. log(`finished checking React Native stylesheet in ${elapsedTime}ms`)
  2469. }
  2470. }
  2471. })()
  2472.  
  2473. /**
  2474. * When the "Background" setting is changed, <body>'s backgroundColor is changed
  2475. * and the app is re-rendered, so we need to re-process the current page.
  2476. */
  2477. function observeBodyBackgroundColor() {
  2478. let lastBackgroundColor = null
  2479.  
  2480. observeElement($body, () => {
  2481. let backgroundColor = $body.style.backgroundColor
  2482. if (backgroundColor == lastBackgroundColor) return
  2483.  
  2484. $body.classList.toggle('Default', backgroundColor == 'rgb(255, 255, 255)')
  2485. $body.classList.toggle('Dim', backgroundColor == 'rgb(21, 32, 43)')
  2486. $body.classList.toggle('LightsOut', backgroundColor == 'rgb(0, 0, 0)')
  2487.  
  2488. if (lastBackgroundColor != null) {
  2489. log('Background setting changed - re-processing current page')
  2490. observePopups()
  2491. observeSideNavTweetButton()
  2492. processCurrentPage()
  2493. }
  2494. lastBackgroundColor = backgroundColor
  2495. }, '<body> style attribute for background colour changes', {
  2496. attributes: true,
  2497. attributeFilter: ['style']
  2498. })
  2499. }
  2500.  
  2501. // TODO Restore "What's happening?" in the first Tweet's placeholder
  2502. async function observeDesktopComposeTweetModal($popup) {
  2503. let $modalDialog = await getElement('div[role="dialog"][aria-labelledby]', {
  2504. context: $popup,
  2505. stopIf: () => !isDesktopComposeTweetModalOpen
  2506. })
  2507. if (!$modalDialog) return
  2508.  
  2509. /** @type {import("./types").Disconnectable} */
  2510. let tweetButtonObserver
  2511.  
  2512. function disconnectTweetButtonObserver() {
  2513. if (tweetButtonObserver) {
  2514. log('disconnecting tweet button dialog observer')
  2515. tweetButtonObserver.disconnect()
  2516. modalObservers.splice(modalObservers.indexOf(tweetButtonObserver), 1)
  2517. tweetButtonObserver = null
  2518. }
  2519. }
  2520.  
  2521. let waitingForTweetButton = false
  2522.  
  2523. modalObservers.push(
  2524. observeElement($modalDialog, async () => {
  2525. if (waitingForTweetButton) return
  2526.  
  2527. waitingForTweetButton = true
  2528. let $tweetButtonText = await getElement('button[data-testid="tweetButton"] span > span', {
  2529. context: $modalDialog,
  2530. name: 'tweet button',
  2531. timeout: 500,
  2532. })
  2533. waitingForTweetButton = false
  2534.  
  2535. if (!$tweetButtonText) {
  2536. disconnectTweetButtonObserver()
  2537. return
  2538. }
  2539.  
  2540. setTweetButtonText($tweetButtonText)
  2541.  
  2542. // The button will be moved around when multiple Tweets are being edited
  2543. tweetButtonObserver = observeElement($modalDialog, (mutations) => {
  2544. for (let mutation of mutations) {
  2545. for (let $addedNode of mutation.addedNodes) {
  2546. let $tweetButtonText = $addedNode.querySelector?.('button[data-testid="tweetButton"] span > span')
  2547. if ($tweetButtonText) {
  2548. setTweetButtonText($tweetButtonText)
  2549. }
  2550. }
  2551. }
  2552. }, 'tweet button dialog', {childList: true, subtree: true})
  2553. modalObservers.push(tweetButtonObserver)
  2554. }, 'compose tweet modal dialog')
  2555. )
  2556. }
  2557.  
  2558. /**
  2559. * @param {HTMLElement} $popup
  2560. */
  2561. async function observeDesktopModalTimeline($popup) {
  2562. // Media modals remember if they were previously collapsed, so we could be
  2563. // waiting for the initial timeline to be either rendered or expanded.
  2564. let $initialTimeline = await getElement(Selectors.MODAL_TIMELINE, {
  2565. context: $popup,
  2566. name: 'initial modal timeline',
  2567. stopIf: () => !isDesktopMediaModalOpen,
  2568. })
  2569.  
  2570. if ($initialTimeline == null) return
  2571.  
  2572. /**
  2573. * @param {HTMLElement} $timeline
  2574. */
  2575. function observeModalTimelineItems($timeline) {
  2576. disconnectModalObserver('modal timeline')
  2577. modalObservers.push(
  2578. observeElement($timeline, () => onIndividualTweetTimelineChange($timeline, {observers: modalObservers}), 'modal timeline')
  2579. )
  2580. setDefaultSortReplies()
  2581.  
  2582. // If other media in the modal is clicked, the timeline is replaced.
  2583. disconnectModalObserver('modal timeline parent')
  2584. modalObservers.push(
  2585. observeElement($timeline.parentElement, (mutations) => {
  2586. mutations.forEach((mutation) => {
  2587. mutation.addedNodes.forEach((/** @type {HTMLElement} */ $newTimeline) => {
  2588. log('modal timeline replaced')
  2589. disconnectModalObserver('modal timeline')
  2590. modalObservers.push(
  2591. observeElement($newTimeline, () => onIndividualTweetTimelineChange($newTimeline, {observers: modalObservers}), 'modal timeline')
  2592. )
  2593. setDefaultSortReplies()
  2594. })
  2595. })
  2596. }, 'modal timeline parent')
  2597. )
  2598. }
  2599.  
  2600. /**
  2601. * @param {HTMLElement} $timeline
  2602. */
  2603. function observeModalTimeline($timeline) {
  2604. // If the inital timeline doesn't have a style attribute it's a placeholder
  2605. if ($timeline.hasAttribute('style')) {
  2606. observeModalTimelineItems($timeline)
  2607. }
  2608. else {
  2609. log('waiting for modal timeline')
  2610. let startTime = Date.now()
  2611. modalObservers.push(
  2612. observeElement($timeline.parentElement, (mutations) => {
  2613. mutations.forEach((mutation) => {
  2614. mutation.addedNodes.forEach((/** @type {HTMLElement} */ $timeline) => {
  2615. disconnectModalObserver('modal timeline parent')
  2616. if (Date.now() > startTime) {
  2617. log(`modal timeline appeared after ${Date.now() - startTime}ms`, $timeline)
  2618. }
  2619. observeModalTimelineItems($timeline)
  2620. })
  2621. })
  2622. }, 'modal timeline parent')
  2623. )
  2624. }
  2625. }
  2626.  
  2627. // The modal timeline can be expanded and collapsed
  2628. let $expandedContainer = $initialTimeline.closest('[aria-expanded="true"]')
  2629. modalObservers.push(
  2630. observeElement($expandedContainer.parentElement, async (mutations) => {
  2631. if (mutations.some(mutation => mutation.removedNodes.length > 0)) {
  2632. log('modal timeline collapsed')
  2633. disconnectModalObserver('modal timeline parent')
  2634. disconnectModalObserver('modal timeline')
  2635. }
  2636. else if (mutations.some(mutation => mutation.addedNodes.length > 0)) {
  2637. log('modal timeline expanded')
  2638. let $timeline = await getElement(Selectors.MODAL_TIMELINE, {
  2639. context: $popup,
  2640. name: 'expanded modal timeline',
  2641. stopIf: () => !isDesktopMediaModalOpen,
  2642. })
  2643. if ($timeline == null) return
  2644. observeModalTimeline($timeline)
  2645. }
  2646. }, 'collapsible modal timeline container')
  2647. )
  2648.  
  2649. observeModalTimeline($initialTimeline)
  2650. }
  2651.  
  2652. const observeFavicon = (() => {
  2653. /** @type {HTMLElement} */
  2654. let $shortcutIcon
  2655. /** @type {MutationObserver} */
  2656. let shortcutIconObserver
  2657.  
  2658. async function observeFavicon() {
  2659. $shortcutIcon ??= await getElement('link[rel="shortcut icon"]', {name: 'shortcut icon'})
  2660.  
  2661. if (!config.replaceLogo) {
  2662. if (shortcutIconObserver != null) {
  2663. shortcutIconObserver.disconnect()
  2664. shortcutIconObserver = null
  2665. if ($shortcutIcon.getAttribute('href').startsWith('data:')) {
  2666. $shortcutIcon.setAttribute('href', `//abs.twimg.com/favicons/twitter${currentNotificationCount ? '-pip' : ''}.3.ico`)
  2667. }
  2668. }
  2669. return
  2670. }
  2671.  
  2672. shortcutIconObserver = observeElement($shortcutIcon, () => {
  2673. let href = $shortcutIcon.getAttribute('href')
  2674. if (href.startsWith('data:')) return
  2675. $shortcutIcon.setAttribute('href', href.includes('pip') ? Images.TWITTER_PIP_FAVICON : Images.TWITTER_FAVICON)
  2676. }, 'shortcut icon href', {
  2677. attributes: true,
  2678. attributeFilter: ['href']
  2679. })
  2680. }
  2681.  
  2682. observeFavicon.updatePip = function(showPip) {
  2683. if (!$shortcutIcon) return
  2684. let icon = showPip ? Images.TWITTER_PIP_FAVICON : Images.TWITTER_FAVICON
  2685. if ($shortcutIcon.getAttribute('href') != icon) {
  2686. $shortcutIcon.setAttribute('href', icon)
  2687. }
  2688. }
  2689.  
  2690. return observeFavicon
  2691. })()
  2692.  
  2693. /**
  2694. * Twitter displays popups in the #layers element. It also reuses open popups
  2695. * in certain cases rather than creating one from scratch, so we also need to
  2696. * deal with nested popups, e.g. if you hover over the caret menu in a Tweet, a
  2697. * popup will be created to display a "More" tootip and clicking to open the
  2698. * menu will create a nested element in the existing popup, whereas clicking the
  2699. * caret quickly without hovering over it will display the menu in new popup.
  2700. * Use of nested popups can also differ between desktop and mobile, so features
  2701. * need to be mindful of that.
  2702. */
  2703. const observePopups = (() => {
  2704. /** @type {MutationObserver} */
  2705. let popupObserver
  2706. /** @type {WeakMap<HTMLElement, {disconnect()}>} */
  2707. let nestedObservers = new WeakMap()
  2708.  
  2709. return async function observePopups() {
  2710. if (popupObserver) {
  2711. popupObserver.disconnect()
  2712. popupObserver = null
  2713. }
  2714.  
  2715. let $layers = await getElement('#layers', {
  2716. name: 'layers',
  2717. })
  2718.  
  2719. // There can be only one
  2720. if (popupObserver) {
  2721. popupObserver.disconnect()
  2722. }
  2723.  
  2724. popupObserver = observeElement($layers, (mutations) => {
  2725. mutations.forEach((mutation) => {
  2726. mutation.addedNodes.forEach((/** @type {HTMLElement} */ $el) => {
  2727. let nestedObserver = onPopup($el)
  2728. if (nestedObserver) {
  2729. nestedObservers.set($el, nestedObserver)
  2730. }
  2731. })
  2732. mutation.removedNodes.forEach((/** @type {HTMLElement} */ $el) => {
  2733. if (nestedObservers.has($el)) {
  2734. nestedObservers.get($el).disconnect()
  2735. nestedObservers.delete($el)
  2736. }
  2737. })
  2738. })
  2739. }, 'popup container')
  2740. }
  2741. })()
  2742.  
  2743. async function observeTitle() {
  2744. let $title = await getElement('title', {name: '<title>'})
  2745. observeElement($title, () => {
  2746. let title = $title.textContent
  2747. if (config.replaceLogo && (ltr ? /X$/ : /^(?:\(\d+\+?\) )?X/).test(title)) {
  2748. let newTitle = title.replace(ltr ? /X$/ : 'X', getString('TWITTER'))
  2749. document.title = newTitle
  2750. // If Twitter is opened in the background, changing the title might not
  2751. // re-fire the title MutationObserver, preventing the initial page from
  2752. // being processed.
  2753. if (!currentPage) {
  2754. onTitleChange(newTitle)
  2755. }
  2756. return
  2757. }
  2758. if (observingPageChanges) {
  2759. onTitleChange(title)
  2760. }
  2761. }, '<title>')
  2762. }
  2763. //#endregion
  2764.  
  2765. //#region Page observers
  2766. async function observeSidebar() {
  2767. let $primaryColumn = await getElement(Selectors.PRIMARY_COLUMN, {
  2768. name: 'primary column'
  2769. })
  2770. let $sidebarContainer = $primaryColumn.parentElement
  2771. pageObservers.push(
  2772. observeElement($sidebarContainer, () => {
  2773. let $sidebar = $sidebarContainer.querySelector(Selectors.SIDEBAR)
  2774. log(`sidebar ${$sidebar ? 'appeared' : 'disappeared'}`)
  2775. $body.classList.toggle('Sidebar', Boolean($sidebar))
  2776. if ($sidebar && config.twitterBlueChecks != 'ignore' && !isOnSearchPage() && !isOnExplorePage()) {
  2777. observeSearchForm()
  2778. }
  2779. }, 'sidebar container')
  2780. )
  2781. }
  2782.  
  2783. const observeSideNavTweetButton = (() => {
  2784. /** @type {MutationObserver} */
  2785. let observer
  2786.  
  2787. return async function observeSideNavTweetButton() {
  2788. if (observer) {
  2789. observer.disconnect()
  2790. observer = null
  2791. }
  2792.  
  2793. if (!desktop || !config.replaceLogo) return
  2794.  
  2795. // This element is updated when text is added or removed on resize
  2796. let $buttonTextContainer = await getElement('a[data-testid="SideNav_NewTweet_Button"] > div > span', {
  2797. name: 'sidenav tweet button text container',
  2798. })
  2799. observer = observeElement($buttonTextContainer, () => {
  2800. if ($buttonTextContainer.childElementCount > 0) {
  2801. let $buttonText = /** @type {HTMLElement} */ ($buttonTextContainer.querySelector('span > span'))
  2802. if ($buttonText) {
  2803. setTweetButtonText($buttonText)
  2804. } else {
  2805. warn('could not find tweet button text')
  2806. }
  2807. }
  2808. }, 'sidenav tweet button')
  2809. }
  2810. })()
  2811.  
  2812. async function observeSearchForm() {
  2813. let $searchForm = await getElement('form[role="search"]', {
  2814. name: 'search form',
  2815. stopIf: pageIsNot(currentPage),
  2816. // The sidebar on Profile pages can be really slow
  2817. timeout: 2000,
  2818. })
  2819. if (!$searchForm) return
  2820. let $results = /** @type {HTMLElement} */ ($searchForm.lastElementChild)
  2821. pageObservers.push(
  2822. observeElement($results, () => {
  2823. processBlueChecks($results)
  2824. }, 'search results', {childList: true, subtree: true})
  2825. )
  2826. }
  2827.  
  2828. /**
  2829. * @param {string} page
  2830. * @param {import("./types").TimelineOptions?} options
  2831. */
  2832. async function observeTimeline(page, options = {}) {
  2833. let {
  2834. isTabbed = false,
  2835. onTabChanged = null,
  2836. onTimelineAppeared = null,
  2837. tabbedTimelineContainerSelector = null,
  2838. timelineSelector = Selectors.TIMELINE,
  2839. } = options
  2840.  
  2841. let $timeline = await getElement(timelineSelector, {
  2842. name: 'initial timeline',
  2843. stopIf: pageIsNot(page),
  2844. })
  2845.  
  2846. if ($timeline == null) return
  2847.  
  2848. /**
  2849. * @param {HTMLElement} $timeline
  2850. */
  2851. function observeTimelineItems($timeline) {
  2852. disconnectPageObserver('timeline')
  2853. pageObservers.push(
  2854. observeElement($timeline, () => onTimelineChange($timeline, page, options), 'timeline')
  2855. )
  2856. onTimelineAppeared?.()
  2857. if (isTabbed) {
  2858. // When a tab which has been viewed before is revisited, the timeline is
  2859. // replaced.
  2860. disconnectPageObserver('timeline parent')
  2861. pageObservers.push(
  2862. observeElement($timeline.parentElement, (mutations) => {
  2863. mutations.forEach((mutation) => {
  2864. mutation.addedNodes.forEach((/** @type {HTMLElement} */ $newTimeline) => {
  2865. disconnectPageObserver('timeline')
  2866. log('tab changed')
  2867. onTabChanged?.()
  2868. pageObservers.push(
  2869. observeElement($newTimeline, () => onTimelineChange($newTimeline, page, options), 'timeline')
  2870. )
  2871. })
  2872. })
  2873. }, 'timeline parent')
  2874. )
  2875. }
  2876. }
  2877.  
  2878. // If the inital timeline doesn't have a style attribute it's a placeholder
  2879. if ($timeline.hasAttribute('style')) {
  2880. observeTimelineItems($timeline)
  2881. }
  2882. else {
  2883. log('waiting for timeline')
  2884. let startTime = Date.now()
  2885. pageObservers.push(
  2886. observeElement($timeline.parentElement, (mutations) => {
  2887. mutations.forEach((mutation) => {
  2888. mutation.addedNodes.forEach((/** @type {HTMLElement} */ $timeline) => {
  2889. disconnectPageObserver('timeline parent')
  2890. if (Date.now() > startTime) {
  2891. log(`timeline appeared after ${Date.now() - startTime}ms`, $timeline)
  2892. }
  2893. observeTimelineItems($timeline)
  2894. })
  2895. })
  2896. }, 'timeline parent')
  2897. )
  2898. }
  2899.  
  2900. // On some tabbed timeline pages, the first time a new tab is navigated to,
  2901. // the element containing the timeline is replaced with a loading spinner.
  2902. if (isTabbed && tabbedTimelineContainerSelector) {
  2903. let $tabbedTimelineContainer = document.querySelector(tabbedTimelineContainerSelector)
  2904. if ($tabbedTimelineContainer) {
  2905. let waitingForNewTimeline = false
  2906. pageObservers.push(
  2907. observeElement($tabbedTimelineContainer, async (mutations) => {
  2908. // This is going to fire twice on a new tab, as the spinner is added
  2909. // then replaced with the new timeline element.
  2910. if (!mutations.some(mutation => mutation.addedNodes.length > 0) || waitingForNewTimeline) return
  2911.  
  2912. waitingForNewTimeline = true
  2913. let $newTimeline = await getElement(timelineSelector, {
  2914. name: 'new timeline',
  2915. stopIf: pageIsNot(page),
  2916. })
  2917. waitingForNewTimeline = false
  2918. if (!$newTimeline) return
  2919.  
  2920. log('tab changed')
  2921. onTabChanged?.()
  2922. observeTimelineItems($newTimeline)
  2923. }, 'tabbed timeline container')
  2924. )
  2925. } else {
  2926. warn('tabbed timeline container not found', tabbedTimelineContainerSelector)
  2927. }
  2928. }
  2929. }
  2930.  
  2931. /**
  2932. * @param {string} page
  2933. */
  2934. async function observeIndividualTweetTimeline(page) {
  2935. let $timeline = await getElement(Selectors.TIMELINE, {
  2936. name: 'initial individual tweet timeline',
  2937. stopIf: pageIsNot(page),
  2938. })
  2939.  
  2940. if ($timeline == null) return
  2941.  
  2942. /**
  2943. * @param {HTMLElement} $timeline
  2944. */
  2945. function observeTimelineItems($timeline) {
  2946. pageObservers.push(
  2947. observeElement($timeline, () => onIndividualTweetTimelineChange($timeline, {observers: pageObservers}), 'individual tweet timeline')
  2948. )
  2949. }
  2950.  
  2951. // If the inital timeline doesn't have a style attribute it's a placeholder
  2952. if ($timeline.hasAttribute('style')) {
  2953. observeTimelineItems($timeline)
  2954. }
  2955. else {
  2956. log('waiting for individual tweet timeline')
  2957. let startTime = Date.now()
  2958. pageObservers.push(
  2959. observeElement($timeline.parentElement, (mutations) => {
  2960. mutations.forEach((mutation) => {
  2961. mutation.addedNodes.forEach((/** @type {HTMLElement} */ $timeline) => {
  2962. disconnectPageObserver('individual tweet timeline parent')
  2963. if (Date.now() > startTime) {
  2964. log(`individual tweet timeline appeared after ${Date.now() - startTime}ms`, $timeline)
  2965. }
  2966. observeTimelineItems($timeline)
  2967. })
  2968. })
  2969. }, 'individual tweet timeline parent')
  2970. )
  2971. }
  2972. }
  2973. //#endregion
  2974.  
  2975. //#region Tweak functions
  2976. /**
  2977. * Add an "Add muted word" menu item after the given link which takes you
  2978. * straight to entering a new muted word (by clicking its way through all the
  2979. * individual screens!).
  2980. * @param {HTMLElement} $link
  2981. * @param {string} linkSelector
  2982. */
  2983. async function addAddMutedWordMenuItem($link, linkSelector) {
  2984. log('adding "Add muted word" menu item')
  2985.  
  2986. // Wait for the dropdown to appear on desktop
  2987. if (desktop) {
  2988. $link = await getElement(`#layers div[data-testid="Dropdown"] ${linkSelector}`, {
  2989. name: 'rendered menu item',
  2990. timeout: 100,
  2991. })
  2992. if (!$link) return
  2993. }
  2994.  
  2995. let $addMutedWord = /** @type {HTMLElement} */ ($link.parentElement.cloneNode(true))
  2996. $addMutedWord.classList.add('tnt_menu_item')
  2997. $addMutedWord.querySelector('a').href = PagePaths.ADD_MUTED_WORD
  2998. $addMutedWord.querySelector('span').textContent = getString('ADD_MUTED_WORD')
  2999. $addMutedWord.querySelector('svg').innerHTML = Svgs.MUTE
  3000. $addMutedWord.addEventListener('click', (e) => {
  3001. e.preventDefault()
  3002. addMutedWord()
  3003. })
  3004. $link.parentElement.insertAdjacentElement('beforebegin', $addMutedWord)
  3005. }
  3006.  
  3007. function addCaretMenuListenerForQuoteTweet($tweet) {
  3008. let $caret = /** @type {HTMLElement} */ ($tweet.querySelector('[data-testid="caret"]'))
  3009. if ($caret && !$caret.dataset.tweakNewTwitterListener) {
  3010. $caret.addEventListener('click', () => {
  3011. quotedTweet = getQuotedTweetDetails($tweet, {getText: true})
  3012. })
  3013. $caret.dataset.tweakNewTwitterListener = 'true'
  3014. }
  3015. }
  3016.  
  3017. /**
  3018. * @param {HTMLElement} $blockMenuItem
  3019. */
  3020. async function addMuteQuotesMenuItems($blockMenuItem) {
  3021. log('mutableQuoteTweets: adding "Mute this conversation" and "Turn off Quote Tweets" menu item')
  3022.  
  3023. // Wait for the menu to render properly on desktop
  3024. if (desktop) {
  3025. $blockMenuItem = await getElement(`:scope > div > div > div > ${Selectors.BLOCK_MENU_ITEM}`, {
  3026. context: $blockMenuItem.parentElement,
  3027. name: 'rendered block menu item',
  3028. timeout: 100,
  3029. })
  3030. if (!$blockMenuItem) return
  3031. }
  3032.  
  3033. let $muteQuotes = /** @type {HTMLElement} */ ($blockMenuItem.previousElementSibling.cloneNode(true))
  3034. $muteQuotes.classList.add('tnt_menu_item')
  3035. $muteQuotes.querySelector('span').textContent = getString('MUTE_THIS_CONVERSATION')
  3036. $muteQuotes.addEventListener('click', (e) => {
  3037. e.preventDefault()
  3038. log('mutableQuoteTweets: muting quotes of a tweet', quotedTweet)
  3039. config.mutedQuotes = config.mutedQuotes.concat(quotedTweet)
  3040. storeConfigChanges({mutedQuotes: config.mutedQuotes})
  3041. processCurrentPage()
  3042. // Dismiss the menu
  3043. let $menuLayer = /** @type {HTMLElement} */ ($blockMenuItem.closest('[role="group"]')?.firstElementChild?.firstElementChild)
  3044. if (!$menuLayer) {
  3045. warn('mutableQuoteTweets: could not find menu layer to dismiss menu')
  3046. }
  3047. $menuLayer?.click()
  3048. })
  3049.  
  3050. if (quotedTweet?.quotedBy) {
  3051. let $toggleQuotes = /** @type {HTMLElement} */ ($blockMenuItem.previousElementSibling.cloneNode(true))
  3052. $toggleQuotes.classList.add('tnt_menu_item')
  3053. $toggleQuotes.querySelector('span').textContent = getString(`TURN_OFF_QUOTE_TWEETS`)
  3054. $toggleQuotes.querySelector('svg').innerHTML = Svgs.RETWEETS_OFF
  3055. $toggleQuotes.addEventListener('click', (e) => {
  3056. e.preventDefault()
  3057. log('mutableQuoteTweets: toggling quotes from', quotedTweet.quotedBy)
  3058. if (config.hideQuotesFrom.includes(quotedTweet.quotedBy)) {
  3059. config.hideQuotesFrom = config.hideQuotesFrom.filter(user => user != quotedTweet.quotedBy)
  3060. } else {
  3061. config.hideQuotesFrom = config.hideQuotesFrom.concat(quotedTweet.quotedBy)
  3062. }
  3063. storeConfigChanges({hideQuotesFrom: config.hideQuotesFrom})
  3064. processCurrentPage()
  3065. // Dismiss the menu
  3066. let $menuLayer = /** @type {HTMLElement} */ ($blockMenuItem.closest('[role="group"]')?.firstElementChild?.firstElementChild)
  3067. if (!$menuLayer) {
  3068. warn('mutableQuoteTweets: could not find menu layer to dismiss menu')
  3069. }
  3070. $menuLayer?.click()
  3071. })
  3072. $blockMenuItem.insertAdjacentElement('beforebegin', $toggleQuotes)
  3073. } else {
  3074. warn('mutableQuoteTweets: quotedBy not available when Tweet menu was opened')
  3075. }
  3076.  
  3077. $blockMenuItem.insertAdjacentElement('beforebegin', $muteQuotes)
  3078. }
  3079.  
  3080. async function addMutedWord() {
  3081. if (!document.querySelector('a[href="/settings')) {
  3082. let $settingsAndSupport = /** @type {HTMLElement} */ (document.querySelector('[data-testid="settingsAndSupport"]'))
  3083. $settingsAndSupport?.click()
  3084. }
  3085.  
  3086. for (let path of [
  3087. '/settings',
  3088. '/settings/privacy_and_safety',
  3089. '/settings/mute_and_block',
  3090. '/settings/muted_keywords',
  3091. '/settings/add_muted_keyword',
  3092. ]) {
  3093. let $link = await getElement(`a[href="${path}"]`, {timeout: 500})
  3094. if (!$link) return
  3095. $link.click()
  3096. }
  3097. let $input = await getElement('input[name="keyword"]')
  3098. setTimeout(() => $input.focus(), 100)
  3099. }
  3100.  
  3101. /**
  3102. * Add a "Turn on/off Retweets" menu item to a List's menu.
  3103. * @param {HTMLElement} $switchMenuItem
  3104. */
  3105. async function addToggleListRetweetsMenuItem($switchMenuItem) {
  3106. log('adding "Turn on/off Retweets" menu item')
  3107.  
  3108. // Wait for the menu to render properly on desktop
  3109. if (desktop) {
  3110. $switchMenuItem = await getElement(':scope > div > div > div > [role="menuitem"]', {
  3111. context: $switchMenuItem.parentElement,
  3112. name: 'rendered switch menu item',
  3113. timeout: 100,
  3114. })
  3115. if (!$switchMenuItem) return
  3116. }
  3117.  
  3118. let $toggleRetweets = /** @type {HTMLElement} */ ($switchMenuItem.cloneNode(true))
  3119. $toggleRetweets.classList.add('tnt_menu_item')
  3120. $toggleRetweets.querySelector('span').textContent = getString(`TURN_${config.listRetweets == 'ignore' ? 'OFF' : 'ON'}_RETWEETS`)
  3121. $toggleRetweets.querySelector('svg').innerHTML = config.listRetweets == 'ignore' ? Svgs.RETWEETS_OFF : Svgs.RETWEET
  3122. // Remove subtitle if the cloned menu item has one
  3123. $toggleRetweets.querySelector('div[dir] + div[dir]')?.remove()
  3124. $toggleRetweets.addEventListener('click', (e) => {
  3125. e.preventDefault()
  3126. log('toggling list retweets')
  3127. config.listRetweets = config.listRetweets == 'ignore' ? 'hide' : 'ignore'
  3128. storeConfigChanges({listRetweets: config.listRetweets})
  3129. processCurrentPage()
  3130. // Dismiss the menu
  3131. let $menuLayer = /** @type {HTMLElement} */ ($switchMenuItem.closest('[role="group"]')?.firstElementChild?.firstElementChild)
  3132. if (!$menuLayer) {
  3133. log('could not find menu layer to dismiss menu')
  3134. }
  3135. $menuLayer?.click()
  3136. })
  3137.  
  3138. $switchMenuItem.insertAdjacentElement('beforebegin', $toggleRetweets)
  3139. }
  3140.  
  3141. /**
  3142. * Redirects away from the Home timeline if we're on it and it's been disabled.
  3143. * @returns {boolean} `true` if redirected as a result of this call
  3144. */
  3145. function checkforDisabledHomeTimeline() {
  3146. if (config.disableHomeTimeline && location.pathname == PagePaths.HOME) {
  3147. log(`Home timeline disabled, redirecting to /${config.disabledHomeTimelineRedirect}`)
  3148. let primaryNavSelector = desktop ? Selectors.PRIMARY_NAV_DESKTOP : Selectors.PRIMARY_NAV_MOBILE
  3149. void (async () => {
  3150. let $navLink = await getElement(`${primaryNavSelector} a[href="/${config.disabledHomeTimelineRedirect}"]`, {
  3151. name: `${config.disabledHomeTimelineRedirect} nav link`,
  3152. stopIf: () => location.pathname != PagePaths.HOME,
  3153. })
  3154. if (!$navLink) return
  3155. $navLink.click()
  3156. })()
  3157. return true
  3158. }
  3159. }
  3160.  
  3161. //#region CSS
  3162. const configureCss = (() => {
  3163. let $style
  3164.  
  3165. return function configureCss() {
  3166. $style ??= addStyle('features')
  3167. let cssRules = [`
  3168. .tnt_font_family {
  3169. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  3170. }
  3171. `]
  3172. let hideCssSelectors = ['.HiddenTweet', '.HiddenTweet + [role="separator"]']
  3173. let menuRole = `[role="${desktop ? 'menu' : 'dialog'}"]`
  3174.  
  3175. // Theme colours for custom UI items
  3176. cssRules.push(`
  3177. body.Default {
  3178. --border-color: rgb(239, 243, 244);
  3179. --color: rgb(83, 100, 113);
  3180. --color-emphasis: rgb(15, 20, 25);
  3181. --hover-bg-color: rgb(247, 249, 249);
  3182. }
  3183. body.Dim {
  3184. --border-color: rgb(56, 68, 77);
  3185. --color: rgb(139, 152, 165);
  3186. --color-emphasis: rgb(247, 249, 249);
  3187. --hover-bg-color: rgb(30, 39, 50);
  3188. }
  3189. body.LightsOut {
  3190. --border-color: rgb(47, 51, 54);
  3191. --color: rgb(113, 118, 123);
  3192. --color-emphasis: rgb(247, 249, 249);
  3193. --hover-bg-color: rgb(22, 24, 28);
  3194. }
  3195. .tnt_menu_item:hover { background-color: var(--hover-bg-color) !important; }
  3196. `)
  3197.  
  3198. if (config.alwaysUseLatestTweets && config.hideForYouTimeline) {
  3199. cssRules.push(`
  3200. /* Prevent the For you tab container taking up space */
  3201. body.HomeTimeline nav.TimelineTabs div[role="tablist"] > div:first-child {
  3202. flex-grow: 0;
  3203. flex-shrink: 1;
  3204. /* New layout has margin-right on tabs */
  3205. margin-right: 0;
  3206. }
  3207. /* Hide the For you tab link */
  3208. body.HomeTimeline nav.TimelineTabs div[role="tablist"] > div:first-child > a {
  3209. display: none;
  3210. }
  3211. `)
  3212. }
  3213. if (config.disableTweetTextFormatting) {
  3214. cssRules.push(`
  3215. div[data-testid="tweetText"] span {
  3216. font-style: normal;
  3217. font-weight: normal;
  3218. }
  3219. `)
  3220. }
  3221. if (config.dropdownMenuFontWeight) {
  3222. cssRules.push(`
  3223. [data-testid="${desktop ? 'Dropdown' : 'sheetDialog'}"] [role="menuitem"] [dir] {
  3224. font-weight: normal;
  3225. }
  3226. `)
  3227. }
  3228. if (config.hideBookmarkButton) {
  3229. // Under timeline tweets
  3230. hideCssSelectors.push(
  3231. 'body:not(.Bookmarks) [data-testid="tweet"][tabindex="0"] [role="group"] > div:has(> button[data-testid$="ookmark"])',
  3232. )
  3233. if (!config.showBookmarkButtonUnderFocusedTweets) {
  3234. // Under the focused tweet
  3235. hideCssSelectors.push(
  3236. '[data-testid="tweet"][tabindex="-1"] [role="group"][id^="id__"] > div:has(> button[data-testid$="ookmark"])',
  3237. )
  3238. }
  3239. }
  3240. if (config.hideListsNav) {
  3241. hideCssSelectors.push(`${menuRole} a[href$="/lists"]`)
  3242. }
  3243. if (config.hideBookmarksNav) {
  3244. hideCssSelectors.push(`${menuRole} a[href$="/bookmarks"]`)
  3245. }
  3246. if (config.hideCommunitiesNav) {
  3247. hideCssSelectors.push(`${menuRole} a[href$="/communities"]`)
  3248. }
  3249. if (config.hideShareTweetButton) {
  3250. hideCssSelectors.push(
  3251. // Under timeline tweets
  3252. `[data-testid="tweet"][tabindex="0"] [role="group"] > div[style]:not(${TWITTER_MEDIA_ASSIST_BUTTON_SELECTOR})`,
  3253. // Under the focused tweet
  3254. `[data-testid="tweet"][tabindex="-1"] [role="group"] > div[style]:not(${TWITTER_MEDIA_ASSIST_BUTTON_SELECTOR})`,
  3255. )
  3256. }
  3257. if (config.hideSubscriptions) {
  3258. hideCssSelectors.push(
  3259. // Subscribe buttons in profile (multiple locations)
  3260. 'body.Profile [role="button"][style*="border-color: rgb(201, 54, 204)"]',
  3261. // Subscriptions count in profile
  3262. 'body.Profile a[href$="/creator-subscriptions/subscriptions"]',
  3263. // Subs tab in profile
  3264. 'body.Profile .SubsTab',
  3265. // Subscribe button in focused tweet
  3266. '[data-testid="tweet"][tabindex="-1"] [data-testid$="-subscribe"]',
  3267. // "Subscribe to" dropdown item (desktop)
  3268. '[data-testid="Dropdown"] > [data-testid="subscribe"]',
  3269. // "Subscribe to" menu item (mobile)
  3270. '[data-testid="sheetDialog"] > [data-testid="subscribe"]',
  3271. // "Subscriber" indicator in replies from subscribers
  3272. '[data-testid="tweet"] [data-testid="icon-subscriber"]',
  3273. // Monetization and Subscriptions items in Settings
  3274. 'body.Settings a[href="/settings/monetization"]',
  3275. 'body.Settings a[href="/settings/manage_subscriptions"]',
  3276. // Subscriptions tab link in Following/Follows
  3277. `body.ProfileFollows.Subscriptions ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:last-child > a`,
  3278. )
  3279. // Subscriptions tab in Following/Follows
  3280. cssRules.push(`
  3281. body.ProfileFollows.Subscriptions ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:last-child {
  3282. flex: 0;
  3283. /* New layout has margin-right on tabs */
  3284. margin-right: 0;
  3285. }
  3286. `)
  3287. }
  3288. if (config.hideMetrics) {
  3289. configureHideMetricsCss(cssRules, hideCssSelectors)
  3290. }
  3291. if (config.hideCommunitiesNav) {
  3292. hideCssSelectors.push(`${menuRole} a[href$="/communities"]`)
  3293. }
  3294. if (config.hideGrokNav) {
  3295. hideCssSelectors.push(
  3296. // In menus
  3297. `${menuRole} a[href$="/i/grok"]`,
  3298. // Grok Actions button
  3299. `button[aria-label="${getString('GROK_ACTIONS')}"]`,
  3300. // "Generate image" button in the Tweet editor
  3301. 'button[data-testid="grokImgGen"]',
  3302. // Any Grok buttons we manually tag
  3303. '.GrokButton',
  3304. // Grok suggested prompts in Tweets
  3305. '[data-testid="tweet"] [data-testid^="followups_"]',
  3306. '[data-testid="tweet"] [data-testid^="followups_"] + nav',
  3307. // Profile Summary button
  3308. `button[aria-label="${getString('PROFILE_SUMMARY')}"]`,
  3309. // Grok summary at the top of search results
  3310. 'body.Search [data-testid="primaryColumn"] > div > div:has(> [data-testid="followups_search"])',
  3311. )
  3312. }
  3313. if (config.hideMonetizationNav) {
  3314. hideCssSelectors.push(`${menuRole} a[href$="/i/monetization"]`)
  3315. }
  3316. if (config.hideAdsNav) {
  3317. hideCssSelectors.push(`${menuRole} a:is([href*="ads.twitter.com"], [href*="ads.x.com"])`)
  3318. }
  3319. if (config.hideJobsNav) {
  3320. hideCssSelectors.push(
  3321. // Jobs navigation item
  3322. `${menuRole} a[href="/jobs"]`,
  3323. // Jobs section in profiles
  3324. '.Profile [data-testid="jobs"]',
  3325. )
  3326. }
  3327. if (config.hideTweetAnalyticsLinks) {
  3328. hideCssSelectors.push('a[data-testid="analyticsButton"]')
  3329. }
  3330. if (config.hideTwitterBlueUpsells) {
  3331. hideCssSelectors.push(
  3332. // Premium/Verified menu items
  3333. `${menuRole} a:is([href^="/i/premium"], [href^="/i/verified"])`,
  3334. // In new More dialog
  3335. `${Selectors.MORE_DIALOG} a:is([href^="/i/premium"], [href^="/i/verified"])`,
  3336. // Analytics menu item
  3337. `${menuRole} a[href="/i/account_analytics"]`,
  3338. // "Highlight on your profile" on your tweets
  3339. '[role="menuitem"][data-testid="highlightUpsell"]',
  3340. // "Edit with Premium" on recent tweets
  3341. '[role="menuitem"][data-testid="editWithTwitterBlue"]',
  3342. // Premium item in Settings
  3343. 'body.Settings a[href^="/i/premium"]',
  3344. // "Highlight your best content instead" on the pin modal
  3345. '.PinModal [data-testid="sheetDialog"] > div > div:last-child > div > div > div:first-child',
  3346. // Highlight button on the pin modal
  3347. '.PinModal [data-testid="sheetDialog"] [role="button"]:first-child:nth-last-child(3)',
  3348. // Misc upsells in your own profile
  3349. `.OwnProfile ${Selectors.PRIMARY_COLUMN} a[href^="/i/premium"]`,
  3350. // Unlock Analytics button in your own profile
  3351. '.OwnProfile [data-testid="analytics-preview"]',
  3352. )
  3353. // Hide Highlights and Articles tabs in your own profile if you don't have Premium
  3354. let profileTabsList = `body.OwnProfile:not(.PremiumProfile) ${Selectors.PRIMARY_COLUMN} nav div[role="tablist"]`
  3355. let upsellTabLinks = 'a:is([href$="/highlights"], [href$="/articles"])'
  3356. cssRules.push(`
  3357. ${profileTabsList} > div:has(> ${upsellTabLinks}) {
  3358. flex: 0;
  3359. /* New layout has margin-right on tabs */
  3360. margin-right: 0;
  3361. }
  3362. ${profileTabsList} > div > ${upsellTabLinks} {
  3363. display: none;
  3364. }
  3365. `)
  3366. // Hide upsell on the Likes tab in your own profile
  3367. cssRules.push(`
  3368. body.OwnProfile ${Selectors.PRIMARY_COLUMN} nav + div:has(a[href^="/i/premium"]) {
  3369. display: none;
  3370. }
  3371. `)
  3372. // Allow Pin and Cancel buttons go to max-width on the pin modal
  3373. cssRules.push(`
  3374. .PinModal [data-testid="sheetDialog"] > div > div:last-child > div > div {
  3375. width: 100%;
  3376. margin-top: 0;
  3377. padding-left: 32px;
  3378. padding-right: 32px;
  3379. }
  3380. `)
  3381. }
  3382. if (config.hideVerifiedNotificationsTab) {
  3383. cssRules.push(`
  3384. body.Notifications ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:nth-child(2),
  3385. body.ProfileFollows ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:nth-child(1) {
  3386. flex: 0;
  3387. /* New layout has margin-right on tabs */
  3388. margin-right: 0;
  3389. }
  3390. body.Notifications ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:nth-child(2) > a,
  3391. body.ProfileFollows ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:nth-child(1) > a {
  3392. display: none;
  3393. }
  3394. `)
  3395. }
  3396. if (config.hideViews) {
  3397. hideCssSelectors.push(
  3398. // "Views" under the focused tweet
  3399. '[data-testid="tweet"][tabindex="-1"] div[dir] + div[aria-hidden="true"]:nth-child(2):nth-last-child(2)',
  3400. '[data-testid="tweet"][tabindex="-1"] div[dir] + div[aria-hidden="true"]:nth-child(2):nth-last-child(2) + div[dir]:last-child'
  3401. )
  3402. }
  3403. if (config.hideWhoToFollowEtc) {
  3404. hideCssSelectors.push(`body.Profile ${Selectors.PRIMARY_COLUMN} aside[role="complementary"]`)
  3405. }
  3406. if (config.reducedInteractionMode) {
  3407. hideCssSelectors.push(
  3408. '[data-testid="tweet"] [role="group"]',
  3409. 'body.Tweet [data-testid="tweet"] + div > div [role="group"]',
  3410. )
  3411. }
  3412. if (config.restoreLinkHeadlines) {
  3413. hideCssSelectors.push(
  3414. // Existing headline overlaid on the card
  3415. '.tnt_overlay_headline',
  3416. // From <domain> link after the card
  3417. 'div[data-testid="card.wrapper"] + a',
  3418. )
  3419. } else {
  3420. hideCssSelectors.push('.tnt_link_headline')
  3421. }
  3422. if (config.restoreQuoteTweetsLink || config.restoreOtherInteractionLinks) {
  3423. cssRules.push(`
  3424. #tntInteractionLinks a {
  3425. text-decoration: none;
  3426. color: var(--color);
  3427. }
  3428. #tntInteractionLinks a:hover span:last-child {
  3429. text-decoration: underline;
  3430. }
  3431. #tntQuoteTweetCount {
  3432. margin-right: 2px;
  3433. font-weight: 700;
  3434. color: var(--color-emphasis);
  3435. }
  3436. /* Replaces the "View post engagements" link under your own tweets */
  3437. a[data-testid="analyticsButton"] {
  3438. display: none;
  3439. }
  3440. `)
  3441. } else {
  3442. hideCssSelectors.push('#tntInteractionLinks')
  3443. }
  3444. if (!config.restoreQuoteTweetsLink) {
  3445. hideCssSelectors.push('#tntQuoteTweetsLink')
  3446. }
  3447. if (!config.restoreOtherInteractionLinks) {
  3448. hideCssSelectors.push('#tntRetweetsLink', '#tntLikesLink')
  3449. }
  3450. if (config.tweakQuoteTweetsPage) {
  3451. // Hide the quoted tweet, which is repeated in every quote tweet
  3452. hideCssSelectors.push('body.QuoteTweets [data-testid="tweet"] [aria-labelledby] > div:last-child')
  3453. }
  3454. if (config.twitterBlueChecks == 'hide') {
  3455. hideCssSelectors.push('.tnt_blue_check')
  3456. }
  3457. if (config.twitterBlueChecks == 'replace') {
  3458. cssRules.push(`
  3459. :is(${Selectors.VERIFIED_TICK}, svg[data-testid="verificationBadge"]).tnt_blue_check path {
  3460. d: path("${Svgs.BLUE_LOGO_PATH}");
  3461. }
  3462. `)
  3463. }
  3464.  
  3465. if (shouldShowSeparatedTweetsTab()) {
  3466. if (hasNewLayout() || config.tweakNewLayout) {
  3467. cssRules.push(`
  3468. body:not(.SeparatedTweets) #tnt_separated_tweets_tab > a > div > div,
  3469. body.HomeTimeline.SeparatedTweets ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:not(#tnt_separated_tweets_tab) > a > div > div {
  3470. color: var(--color) !important;
  3471. }
  3472. body.SeparatedTweets #tnt_separated_tweets_tab > a > div > div {
  3473. color: var(--color-emphasis) !important;
  3474. }
  3475. body.Desktop #tnt_separated_tweets_tab:hover > a > div > div {
  3476. color: var(--color-emphasis) !important;
  3477. }
  3478. `)
  3479. } else {
  3480. cssRules.push(`
  3481. body.Default {
  3482. --tab-hover: rgba(15, 20, 25, 0.1);
  3483. }
  3484. body.Dim {
  3485. --tab-hover: rgba(247, 249, 249, 0.1);
  3486. }
  3487. body.LightsOut {
  3488. --tab-hover: rgba(231, 233, 234, 0.1);
  3489. }
  3490. body.Desktop #tnt_separated_tweets_tab:hover,
  3491. body.Mobile:not(.SeparatedTweets) #tnt_separated_tweets_tab:hover,
  3492. body.Mobile #tnt_separated_tweets_tab:active {
  3493. background-color: var(--tab-hover);
  3494. }
  3495. body:not(.SeparatedTweets) #tnt_separated_tweets_tab > a > div > div,
  3496. body.HomeTimeline.SeparatedTweets ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:not(#tnt_separated_tweets_tab) > a > div > div {
  3497. font-weight: normal !important;
  3498. color: var(--color) !important;
  3499. }
  3500. body.SeparatedTweets #tnt_separated_tweets_tab > a > div > div {
  3501. font-weight: bold;
  3502. color: var(--color-emphasis); !important;
  3503. }
  3504. body:not(.SeparatedTweets) #tnt_separated_tweets_tab > a > div > div > div,
  3505. body.HomeTimeline.SeparatedTweets ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:not(#tnt_separated_tweets_tab) > a > div > div > div {
  3506. height: 0 !important;
  3507. }
  3508. body.SeparatedTweets #tnt_separated_tweets_tab > a > div > div > div {
  3509. height: 4px !important;
  3510. min-width: 56px;
  3511. width: 100%;
  3512. position: absolute;
  3513. bottom: 0;
  3514. border-radius: 9999px;
  3515. }
  3516. `)
  3517. }
  3518. }
  3519.  
  3520. if (config.tweakNewLayout) {
  3521. cssRules.push(`
  3522. /* Make the image button first in the Tweet editor toolbar again */
  3523. [data-testid="toolBar"] [role="tablist"] > [role="presentation"] {
  3524. order: 1;
  3525. }
  3526. [data-testid="toolBar"] [role="tablist"] > [role="presentation"]:has(input[data-testid="fileInput"]) {
  3527. order: 0;
  3528. }
  3529. `)
  3530. if (config.replaceLogo) {
  3531. cssRules.push(`
  3532. /* Add theme colour back to Tweet editor toolbar buttons */
  3533. [data-testid="toolBar"] [role="tablist"] > [role="presentation"] svg {
  3534. fill: var(--theme-color);
  3535. }
  3536. `)
  3537. }
  3538. }
  3539.  
  3540. //#region Desktop-only
  3541. if (desktop) {
  3542. if (config.tweakNewLayout) {
  3543. cssRules.push(`
  3544. /* Realign nav items to the top */
  3545. header[role="banner"] > div > div > div {
  3546. justify-content: flex-start;
  3547. }
  3548. /* Restore size and contrast of nav link icons */
  3549. ${Selectors.PRIMARY_NAV_DESKTOP} > a svg {
  3550. width: 1.75rem !important;
  3551. height: 1.75rem !important;
  3552. fill: var(--color-emphasis) !important;
  3553. }
  3554. /* Give nav button icons more contrast too */
  3555. header[role="banner"] button svg,
  3556. ${Selectors.PRIMARY_NAV_DESKTOP} button svg {
  3557. fill: var(--color-emphasis) !important;
  3558. }
  3559. /* Make the Tweet button larger */
  3560. [data-testid="SideNav_NewTweet_Button"] {
  3561. min-width: 49px;
  3562. min-height: 49px;
  3563. }
  3564. /* Move the account switcher back to the bottom */
  3565. header[role="banner"] > div > div > div > div:last-child {
  3566. flex: 1;
  3567. justify-content: space-between;
  3568. }
  3569. /* Restore primary column borders */
  3570. header[role="banner"] > div > div > div {
  3571. border-right: 1px solid var(--border-color);
  3572. }
  3573. ${Selectors.PRIMARY_COLUMN} {
  3574. border-right: 1px solid var(--border-color);
  3575. }
  3576. /* Left-align main contents and stop it taking up all available space */
  3577. main {
  3578. align-items: flex-start !important;
  3579. flex-grow: 0 !important;
  3580. }
  3581. /* Remove the gap between main contents and sidebar */
  3582. main > div > div > div {
  3583. justify-content: normal !important;
  3584. }
  3585. /* Restore the sidebar to its old width */
  3586. ${Selectors.SIDEBAR},
  3587. ${Selectors.SIDEBAR} > div > div,
  3588. ${Selectors.SIDEBAR_WRAPPERS} > div:first-child {
  3589. width: 350px !important;
  3590. }
  3591. /* Center content */
  3592. div[data-at-shortcutkeys] {
  3593. justify-content: center;
  3594. }
  3595. `)
  3596. if (config.replaceLogo) {
  3597. // TODO Manually patch Tweet button SVG in Safari
  3598. cssRules.push(`
  3599. /* Restore theme colour in nav item pips */
  3600. ${Selectors.PRIMARY_NAV_DESKTOP} > :is(a[href="/notifications"], a[href="/messages"]) div[aria-live],
  3601. ${Selectors.MORE_DIALOG} :is(a[href="/notifications"], a[href="/messages"]) div[aria-live],
  3602. /* Restore theme colour in profile switcher other accounts have notifications pip */
  3603. button[data-testid="SideNav_AccountSwitcher_Button"] > div > div[aria-label],
  3604. /* Restore theme colour in account switcher notifications pips */
  3605. [data-testid="HoverCard"] button[data-testid="UserCell"] div[aria-live] {
  3606. background-color: var(--theme-color);
  3607. }
  3608. /* Replace the plus icon in the Tweet button with the feather */
  3609. [data-testid="SideNav_NewTweet_Button"] path[d="${Svgs.PLUS_PATH}"] {
  3610. d: path("${Svgs.TWITTER_FEATHER_PLUS_PATH}");
  3611. }
  3612. `)
  3613. }
  3614. }
  3615. if (config.navDensity == 'comfortable' || config.navDensity == 'compact') {
  3616. cssRules.push(`
  3617. header nav > a,
  3618. header nav > div[data-testid="AppTabBar_More_Menu"] {
  3619. padding-top: 0 !important;
  3620. padding-bottom: 0 !important;
  3621. }
  3622. `)
  3623. }
  3624. if (config.navDensity == 'compact') {
  3625. cssRules.push(`
  3626. header nav > a > div,
  3627. header nav > div[data-testid="AppTabBar_More_Menu"] > div {
  3628. padding-top: 6px !important;
  3629. padding-bottom: 6px !important;
  3630. }
  3631. `)
  3632. }
  3633. if (config.hideSeeNewTweets) {
  3634. hideCssSelectors.push(`body.HomeTimeline ${Selectors.PRIMARY_COLUMN} > div > div:first-child > div[style^="transform"]`)
  3635. }
  3636. if (config.hideTimelineTweetBox) {
  3637. hideCssSelectors.push(`body.HomeTimeline ${Selectors.PRIMARY_COLUMN} > div > div:nth-child(3)`)
  3638. }
  3639. if (config.disableHomeTimeline) {
  3640. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_DESKTOP} a[href="/home"]`)
  3641. }
  3642. if (config.fullWidthContent) {
  3643. cssRules.push(`
  3644. /* Use full width when the sidebar is visible */
  3645. body.Sidebar${FULL_WIDTH_BODY_PSEUDO} ${Selectors.PRIMARY_COLUMN},
  3646. body.Sidebar${FULL_WIDTH_BODY_PSEUDO} ${Selectors.PRIMARY_COLUMN} > div:first-child > div:last-child {
  3647. max-width: 990px;
  3648. }
  3649. /* Make the "What's happening" input keep its original width */
  3650. body.HomeTimeline ${Selectors.PRIMARY_COLUMN} > div:first-child > div:nth-of-type(3) div[role="progressbar"] + div {
  3651. max-width: 598px;
  3652. }
  3653. /* Use full width when the sidebar is not visible */
  3654. body:not(.Sidebar)${FULL_WIDTH_BODY_PSEUDO} header[role="banner"] {
  3655. flex-grow: 0;
  3656. }
  3657. body:not(.Sidebar)${FULL_WIDTH_BODY_PSEUDO} main[role="main"] > div {
  3658. width: 100%;
  3659. }
  3660. body:not(.Sidebar)${FULL_WIDTH_BODY_PSEUDO} ${Selectors.PRIMARY_COLUMN} {
  3661. max-width: unset;
  3662. width: 100%;
  3663. }
  3664. body:not(.Sidebar)${FULL_WIDTH_BODY_PSEUDO} ${Selectors.PRIMARY_COLUMN} > div:first-child > div:first-child div,
  3665. body:not(.Sidebar)${FULL_WIDTH_BODY_PSEUDO} ${Selectors.PRIMARY_COLUMN} > div:first-child > div:last-child {
  3666. max-width: unset;
  3667. }
  3668. `)
  3669. if (!config.fullWidthMedia) {
  3670. // Make media & cards keep their original width
  3671. cssRules.push(`
  3672. body${FULL_WIDTH_BODY_PSEUDO} ${Selectors.PRIMARY_COLUMN} ${Selectors.TWEET} > div > div > div:nth-of-type(2) > div:nth-of-type(2) > div[id][aria-labelledby]:not(:empty) {
  3673. max-width: 504px;
  3674. }
  3675. `)
  3676. }
  3677. // Hide the sidebar when present
  3678. hideCssSelectors.push(`body.Sidebar${FULL_WIDTH_BODY_PSEUDO} ${Selectors.SIDEBAR}`)
  3679. }
  3680. if (config.hideAccountSwitcher) {
  3681. cssRules.push(`
  3682. header[role="banner"] > div > div > div > div:last-child {
  3683. flex-shrink: 1 !important;
  3684. align-items: flex-end !important;
  3685. }
  3686. `)
  3687. hideCssSelectors.push(
  3688. '[data-testid="SideNav_AccountSwitcher_Button"] > div:first-child:not(:only-child)',
  3689. '[data-testid="SideNav_AccountSwitcher_Button"] > div:first-child + div',
  3690. )
  3691. }
  3692. if (config.hideExplorePageContents) {
  3693. hideCssSelectors.push(
  3694. // Tabs
  3695. `body.Explore ${Selectors.DESKTOP_TIMELINE_HEADER} nav`,
  3696. // Content
  3697. `body.Explore ${Selectors.TIMELINE}`,
  3698. )
  3699. }
  3700. if (config.hideAdsNav) {
  3701. // In new More dialog
  3702. hideCssSelectors.push(`${Selectors.MORE_DIALOG} a:is([href*="ads.twitter.com"], [href*="ads.x.com"])`)
  3703. }
  3704. if (config.hideGrokNav) {
  3705. hideCssSelectors.push(
  3706. `${Selectors.PRIMARY_NAV_DESKTOP} a[href$="/i/grok"]`,
  3707. // In new More dialog
  3708. `${Selectors.MORE_DIALOG} a[href$="/i/grok"]`,
  3709. // Grok drawer
  3710. 'div[data-testid="GrokDrawer"]',
  3711. )
  3712. }
  3713. if (config.hideJobsNav) {
  3714. hideCssSelectors.push(
  3715. `${Selectors.PRIMARY_NAV_DESKTOP} a[href="/jobs"]`,
  3716. // In new More dialog
  3717. `${Selectors.MORE_DIALOG} a[href="/jobs"]`,
  3718. )
  3719. }
  3720. if (config.hideListsNav) {
  3721. hideCssSelectors.push(
  3722. `${Selectors.PRIMARY_NAV_DESKTOP} a[href$="/lists"]`,
  3723. // In new More dialog
  3724. `${Selectors.MORE_DIALOG} a[href$="/lists"]`,
  3725. )
  3726. }
  3727. if (config.hideMonetizationNav) {
  3728. // In new More dialog
  3729. hideCssSelectors.push(`${Selectors.MORE_DIALOG} a[href$="/i/monetization"]`)
  3730. }
  3731. if (config.hideProNav) {
  3732. hideCssSelectors.push(`${menuRole} a:is([href*="pro.twitter.com"], [href*="pro.x.com"])`)
  3733. }
  3734. if (config.hideSpacesNav) {
  3735. hideCssSelectors.push(
  3736. `${menuRole} a[href="/i/spaces/start"]`,
  3737. // In new More dialog
  3738. `${Selectors.MORE_DIALOG} a[href="/i/spaces/start"]`,
  3739. )
  3740. }
  3741. if (config.hideTwitterBlueUpsells) {
  3742. hideCssSelectors.push(
  3743. // Nav items
  3744. `${Selectors.PRIMARY_NAV_DESKTOP} a:is([href^="/i/premium"], [href^="/i/verified"])`,
  3745. // Search sidebar Radar upsell
  3746. `body.Search ${Selectors.SIDEBAR_WRAPPERS} > div:first-child:has(a[href="/i/radar"])`,
  3747. `body.Search ${Selectors.SIDEBAR_WRAPPERS} > div:first-child:has(a[href="/i/radar"]) + div:empty`,
  3748. )
  3749. }
  3750. if (config.hideSidebarContent) {
  3751. // Only show the first sidebar item by default
  3752. // Re-show subsequent non-algorithmic sections on specific pages
  3753. cssRules.push(`
  3754. ${Selectors.SIDEBAR_WRAPPERS} > div:not(:first-of-type) {
  3755. display: none;
  3756. }
  3757. body.Search ${Selectors.SIDEBAR_WRAPPERS} > div:nth-of-type(2) {
  3758. display: block;
  3759. }
  3760. /* Radar upsell in Search uses the first item and adds a second one for spacing */
  3761. body.Search ${Selectors.SIDEBAR_WRAPPERS}:has(a[href="/i/radar"]) > div:first-of-type,
  3762. body.Search ${Selectors.SIDEBAR_WRAPPERS}:has(a[href="/i/radar"]) > div:nth-of-type(2):empty {
  3763. display: none;
  3764. }
  3765. body.Search ${Selectors.SIDEBAR_WRAPPERS}:has(a[href="/i/radar"]) > div:nth-of-type(3),
  3766. body.Search ${Selectors.SIDEBAR_WRAPPERS}:has(a[href="/i/radar"]) > div:nth-of-type(4) {
  3767. display: block;
  3768. }
  3769. `)
  3770. if (config.showRelevantPeople) {
  3771. cssRules.push(`
  3772. body.Tweet ${Selectors.SIDEBAR_WRAPPERS} > div:is(:nth-of-type(2), :nth-of-type(3)) {
  3773. display: block;
  3774. }
  3775. `)
  3776. }
  3777. hideCssSelectors.push(`body.HideSidebar ${Selectors.SIDEBAR}`)
  3778. } else if (config.hideTwitterBlueUpsells) {
  3779. // Hide "Subscribe to premium" individually
  3780. hideCssSelectors.push(
  3781. `body.HomeTimeline ${Selectors.SIDEBAR_WRAPPERS} > div:nth-of-type(3)`
  3782. )
  3783. }
  3784. if (config.hideShareTweetButton) {
  3785. hideCssSelectors.push(
  3786. // In media modal
  3787. `[aria-modal="true"] div > div:first-of-type [role="group"] > div[style]:not([role]):not(${TWITTER_MEDIA_ASSIST_BUTTON_SELECTOR})`,
  3788. )
  3789. }
  3790. if (config.hideExploreNav) {
  3791. // When configured, hide Explore only when the sidebar is showing, or
  3792. // when on a page full-width content is enabled on.
  3793. let bodySelector = `${config.hideExploreNavWithSidebar ? `body.Sidebar${config.fullWidthContent ? `:not(${FULL_WIDTH_BODY_PSEUDO})` : ''} ` : ''}`
  3794. hideCssSelectors.push(
  3795. `${bodySelector}${Selectors.PRIMARY_NAV_DESKTOP} a[href="/explore"]`,
  3796. // In new More dialog
  3797. `${Selectors.MORE_DIALOG} a[href="/explore"]`,
  3798. )
  3799. }
  3800. if (config.hideBookmarksNav) {
  3801. hideCssSelectors.push(
  3802. `${Selectors.PRIMARY_NAV_DESKTOP} a[href="/i/bookmarks"]`,
  3803. // In new More dialog
  3804. `${Selectors.MORE_DIALOG} a[href="/i/bookmarks"]`,
  3805. )
  3806. }
  3807. if (config.hideCommunitiesNav) {
  3808. hideCssSelectors.push(
  3809. `${Selectors.PRIMARY_NAV_DESKTOP} a[href$="/communities"]`,
  3810. // In new More dialog
  3811. `${Selectors.MORE_DIALOG} a[href$="/communities"]`,
  3812. )
  3813. }
  3814. if (config.hideMessagesDrawer) {
  3815. cssRules.push(`div[data-testid="DMDrawer"] { visibility: hidden; }`)
  3816. }
  3817. if (config.hideViews) {
  3818. hideCssSelectors.push(
  3819. // Under timeline tweets
  3820. '[data-testid="tweet"][tabindex="0"] [role="group"] > div:has(> a[href$="/analytics"])',
  3821. // In media modal
  3822. '[aria-modal="true"] > div > div:first-of-type [role="group"] > div:has(> a[href$="/analytics"])',
  3823. )
  3824. }
  3825. if (config.retweets != 'separate' && config.quoteTweets != 'separate') {
  3826. hideCssSelectors.push('#tnt_separated_tweets_tab')
  3827. }
  3828. }
  3829. //#endregion
  3830.  
  3831. //#region Mobile only
  3832. if (mobile) {
  3833. if (config.tweakNewLayout) {
  3834. cssRules.push(`
  3835. /* Remove new padding from profile details and the tab bar (this has to be accidental) */
  3836. body.Profile ${Selectors.PRIMARY_COLUMN} > div > div > div > div > div > div > div > div {
  3837. padding-left: 0;
  3838. padding-right: 0;
  3839. }
  3840. `)
  3841. if (config.replaceLogo) {
  3842. cssRules.push(`
  3843. /* Restore theme colour in nav item pips */
  3844. ${Selectors.PRIMARY_NAV_MOBILE} > :is(a[href^="/notifications"], a[href="/messages"]) div[aria-label],
  3845. /* Restore theme colour in profile button other accounts have notifications pip */
  3846. button[data-testid="DashButton_ProfileIcon_Link"] div[aria-label],
  3847. /* Restore theme colour in account switcher notifications pips */
  3848. [role="dialog"] [data-testid^="UserAvatar-Container"] div[dir] {
  3849. background-color: var(--theme-color);
  3850. }
  3851. `)
  3852. }
  3853. }
  3854. if (config.disableHomeTimeline) {
  3855. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_MOBILE} a[href="/home"]`)
  3856. }
  3857. if (config.hideSeeNewTweets) {
  3858. hideCssSelectors.push(`body.HomeTimeline ${Selectors.MOBILE_TIMELINE_HEADER} ~ div[style^="transform"]:last-child`)
  3859. }
  3860. if (config.hideExplorePageContents) {
  3861. // Hide explore page contents so we don't get a brief flash of them
  3862. // before automatically switching the page to search mode.
  3863. hideCssSelectors.push(
  3864. // Tabs
  3865. `body.Explore ${Selectors.MOBILE_TIMELINE_HEADER} > div > div:nth-of-type(2)`,
  3866. // Content
  3867. `body.Explore ${Selectors.TIMELINE}`,
  3868. )
  3869. }
  3870. if (config.hideGrokNav) {
  3871. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_MOBILE} a[href="/i/grok"]`)
  3872. }
  3873. if (config.hideCommunitiesNav) {
  3874. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_MOBILE} a[href$="/communities"]`)
  3875. }
  3876. if (config.hideMessagesBottomNavItem) {
  3877. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_MOBILE} a[href="/messages"]`)
  3878. }
  3879. if (config.hideJobsNav) {
  3880. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_MOBILE} a[href="/jobs"]`)
  3881. }
  3882. if (config.hideTwitterBlueUpsells) {
  3883. hideCssSelectors.push(
  3884. `${Selectors.PRIMARY_NAV_MOBILE} a[href^="/i/premium"]`,
  3885. `${Selectors.MOBILE_TIMELINE_HEADER} a[href^="/i/premium"]`,
  3886. )
  3887. }
  3888. if (config.hideShareTweetButton) {
  3889. hideCssSelectors.push(
  3890. // In media modal
  3891. `body.MobileMedia [role="group"] > div[style]:not(${TWITTER_MEDIA_ASSIST_BUTTON_SELECTOR})`,
  3892. )
  3893. }
  3894. if (config.hideViews) {
  3895. hideCssSelectors.push(
  3896. // Under timeline tweets
  3897. '[data-testid="tweet"][tabindex="0"] [role="group"] > div:has(> a[href$="/analytics"])',
  3898. // In media modal
  3899. 'body.MobileMedia [role="group"] > div:has(> a[href$="/analytics"])',
  3900. )
  3901. }
  3902. //#endregion
  3903. }
  3904.  
  3905. if (hideCssSelectors.length > 0) {
  3906. cssRules.push(`
  3907. ${hideCssSelectors.join(',\n')} {
  3908. display: none !important;
  3909. }
  3910. `)
  3911. }
  3912.  
  3913. $style.textContent = cssRules.map(dedent).join('\n')
  3914. }
  3915. })()
  3916.  
  3917. function configureFont() {
  3918. if (!fontFamilyRule) {
  3919. warn('no fontFamilyRule found for configureFont to use')
  3920. return
  3921. }
  3922.  
  3923. if (config.dontUseChirpFont) {
  3924. if (fontFamilyRule.style.fontFamily.includes('TwitterChirp')) {
  3925. fontFamilyRule.style.fontFamily = fontFamilyRule.style.fontFamily.replace(/"?TwitterChirp"?, ?/, '')
  3926. log('disabled Chirp font')
  3927. }
  3928. } else if (!fontFamilyRule.style.fontFamily.includes('TwitterChirp')) {
  3929. fontFamilyRule.style.fontFamily = `"TwitterChirp", ${fontFamilyRule.style.fontFamily}`
  3930. log(`enabled Chirp font`)
  3931. }
  3932. }
  3933.  
  3934. /**
  3935. * @param {string[]} cssRules
  3936. * @param {string[]} hideCssSelectors
  3937. */
  3938. function configureHideMetricsCss(cssRules, hideCssSelectors) {
  3939. if (config.hideFollowingMetrics) {
  3940. // User profile hover card and page metrics
  3941. hideCssSelectors.push(
  3942. ':is(#layers, body.Profile) a:is([href$="/following"], [href$="/verified_followers"]) > span:first-child'
  3943. )
  3944. // Fix display of whitespace after hidden metrics
  3945. cssRules.push(
  3946. ':is(#layers, body.Profile) a:is([href$="/following"], [href$="/verified_followers"]) { white-space: pre-line; }'
  3947. )
  3948. }
  3949.  
  3950. if (config.hideTotalTweetsMetrics) {
  3951. // Tweet count under username header on profile pages
  3952. hideCssSelectors.push(`
  3953. body.Profile ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} > div > div:first-of-type h2 + div[dir]
  3954. `)
  3955. }
  3956.  
  3957. let timelineMetricSelectors = [
  3958. config.hideReplyMetrics && '[data-testid="reply"]',
  3959. config.hideRetweetMetrics && '[data-testid$="retweet"]',
  3960. config.hideLikeMetrics && '[data-testid$="like"]',
  3961. config.hideBookmarkMetrics && '[data-testid$="bookmark"], [data-testid$="removeBookmark"]',
  3962. ].filter(Boolean).join(', ')
  3963.  
  3964. if (timelineMetricSelectors) {
  3965. cssRules.push(
  3966. `[role="group"] button:is(${timelineMetricSelectors}) span { visibility: hidden; }`
  3967. )
  3968. }
  3969.  
  3970. if (config.hideQuoteTweetMetrics) {
  3971. hideCssSelectors.push('#tntQuoteTweetCount')
  3972. }
  3973. }
  3974.  
  3975. /**
  3976. * CSS which depends on anything we need to get from the page.
  3977. */
  3978. const configureDynamicCss = (() => {
  3979. let $style
  3980.  
  3981. return function configureDynamicCss() {
  3982. $style ??= addStyle('dynamic')
  3983. let cssRules = []
  3984.  
  3985. if (fontSize != null && config.navBaseFontSize) {
  3986. cssRules.push(`
  3987. ${Selectors.PRIMARY_NAV_DESKTOP} div[dir] span { font-size: ${fontSize}; font-weight: normal; }
  3988. ${Selectors.PRIMARY_NAV_DESKTOP} div[dir] { margin-top: -4px; }
  3989. `)
  3990. }
  3991.  
  3992. if (filterBlurRule != null && config.unblurSensitiveContent) {
  3993. cssRules.push(`
  3994. ${filterBlurRule.selectorText} {
  3995. filter: none !important;
  3996. }
  3997. ${filterBlurRule.selectorText} + div {
  3998. display: none !important;
  3999. }
  4000. `)
  4001. }
  4002.  
  4003. $style.textContent = cssRules.map(dedent).join('\n')
  4004. }
  4005. })()
  4006. //#endregion
  4007.  
  4008. /**
  4009. * Configures – or re-configures – the separated tweets timeline title.
  4010. *
  4011. * If we're currently on the separated tweets timeline and…
  4012. * - …its title has changed, the page title will be changed to "navigate" to it.
  4013. * - …the separated tweets timeline is no longer needed, we'll change the page
  4014. * title to "navigate" back to the Home timeline.
  4015. *
  4016. * @returns {boolean} `true` if "navigation" was triggered by this call
  4017. */
  4018. function configureSeparatedTweetsTimelineTitle() {
  4019. let wasOnSeparatedTweetsTimeline = isOnSeparatedTweetsTimeline()
  4020. let previousTitle = separatedTweetsTimelineTitle
  4021.  
  4022. if (config.retweets == 'separate' && config.quoteTweets == 'separate') {
  4023. separatedTweetsTimelineTitle = getString(config.replaceLogo ? 'SHARED_TWEETS' : 'SHARED')
  4024. } else if (config.retweets == 'separate') {
  4025. separatedTweetsTimelineTitle = getString(config.replaceLogo ? 'RETWEETS' : 'REPOSTS')
  4026. } else if (config.quoteTweets == 'separate') {
  4027. separatedTweetsTimelineTitle = getString(config.replaceLogo ? 'QUOTE_TWEETS' : 'QUOTES')
  4028. } else {
  4029. separatedTweetsTimelineTitle = null
  4030. }
  4031.  
  4032. let titleChanged = previousTitle != separatedTweetsTimelineTitle
  4033. if (wasOnSeparatedTweetsTimeline) {
  4034. if (separatedTweetsTimelineTitle == null) {
  4035. log('moving from separated tweets timeline to Home timeline after config change')
  4036. setTitle(getString('HOME'))
  4037. return true
  4038. }
  4039. if (titleChanged) {
  4040. log('applying new separated tweets timeline title after config change')
  4041. setTitle(separatedTweetsTimelineTitle)
  4042. return true
  4043. }
  4044. } else {
  4045. if (titleChanged && previousTitle != null && lastHomeTimelineTitle == previousTitle) {
  4046. log('updating lastHomeTimelineTitle with new separated tweets timeline title')
  4047. lastHomeTimelineTitle = separatedTweetsTimelineTitle
  4048. }
  4049. }
  4050. }
  4051.  
  4052. const configureThemeCss = (() => {
  4053. let $style
  4054.  
  4055. return function configureThemeCss() {
  4056. $style ??= addStyle('theme')
  4057. let cssRules = []
  4058.  
  4059. if (themeColor != null) {
  4060. cssRules.push(`
  4061. body {
  4062. --theme-color: ${themeColor};
  4063. }
  4064. `)
  4065. }
  4066.  
  4067. if (debug) {
  4068. cssRules.push(`
  4069. [data-item-type]::after {
  4070. position: absolute;
  4071. top: 0;
  4072. ${ltr ? 'right': 'left'}: 50px;
  4073. content: attr(data-item-type);
  4074. font-family: ${fontFamilyRule?.style.fontFamily || '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial'};
  4075. background-color: rgb(242, 29, 29);
  4076. color: white;
  4077. font-size: 11px;
  4078. font-weight: bold;
  4079. padding: 4px 6px;
  4080. border-bottom-left-radius: 1em;
  4081. border-bottom-right-radius: 1em;
  4082. }
  4083. `)
  4084. }
  4085.  
  4086. // Active tab colour for custom tabs
  4087. if (themeColor != null && shouldShowSeparatedTweetsTab()) {
  4088. cssRules.push(`
  4089. body.SeparatedTweets #tnt_separated_tweets_tab > a > div > div > div {
  4090. background-color: ${themeColor} !important;
  4091. }
  4092. `)
  4093. }
  4094.  
  4095. if (config.replaceLogo) {
  4096. cssRules.push(`
  4097. ${Selectors.X_LOGO_PATH}, ${Selectors.X_DARUMA_LOGO_PATH} {
  4098. fill: ${THEME_BLUE};
  4099. d: path("${Svgs.TWITTER_LOGO_PATH}");
  4100. }
  4101. .tnt_logo {
  4102. fill: ${THEME_BLUE};
  4103. }
  4104. svg path[d="${Svgs.X_HOME_ACTIVE_PATH}"] {
  4105. d: path("${Svgs.TWITTER_HOME_ACTIVE_PATH}");
  4106. }
  4107. svg path[d="${Svgs.X_HOME_INACTIVE_PATH}"] {
  4108. d: path("${Svgs.TWITTER_HOME_INACTIVE_PATH}");
  4109. }
  4110. `)
  4111. if (desktop) {
  4112. // Revert the Tweet buttons being made monochrome
  4113. cssRules.push(`
  4114. [data-testid="SideNav_NewTweet_Button"],
  4115. [data-testid="tweetButtonInline"],
  4116. [data-testid="tweetButton"] {
  4117. background-color: ${themeColor} !important;
  4118. }
  4119. [data-testid="SideNav_NewTweet_Button"]:hover,
  4120. [data-testid="tweetButtonInline"]:hover:not(:disabled),
  4121. [data-testid="tweetButton"]:hover:not(:disabled) {
  4122. background-color: ${themeColor.replace(')', ', 80%)')} !important;
  4123. }
  4124. body:is(.Dim, .LightsOut):not(.HighContrast) [data-testid="SideNav_NewTweet_Button"] > div,
  4125. body:is(.Dim, .LightsOut):not(.HighContrast) [data-testid="tweetButtonInline"] > div,
  4126. body:is(.Dim, .LightsOut):not(.HighContrast) [data-testid="tweetButton"] > div,
  4127. body:is(.Dim, .LightsOut):not(.HighContrast) [data-testid="SideNav_NewTweet_Button"] > div > svg {
  4128. color: rgb(255, 255, 255) !important;
  4129. }
  4130. `)
  4131. }
  4132. }
  4133.  
  4134. if (config.uninvertFollowButtons) {
  4135. // Shared styles for Following and Follow buttons
  4136. cssRules.push(`
  4137. [role="button"][data-testid$="-unfollow"]:not(:hover) {
  4138. border-color: rgba(0, 0, 0, 0) !important;
  4139. }
  4140. [role="button"][data-testid$="-follow"] {
  4141. background-color: rgba(0, 0, 0, 0) !important;
  4142. }
  4143. `)
  4144. if (config.followButtonStyle == 'monochrome' || themeColor == null) {
  4145. cssRules.push(`
  4146. /* Following button */
  4147. body.Default [role="button"][data-testid$="-unfollow"]:not(:hover) {
  4148. background-color: rgb(15, 20, 25) !important;
  4149. }
  4150. body.Default [role="button"][data-testid$="-unfollow"]:not(:hover) > :is(div, span) {
  4151. color: rgb(255, 255, 255) !important;
  4152. }
  4153. body:is(.Dim, .LightsOut) [role="button"][data-testid$="-unfollow"]:not(:hover) {
  4154. background-color: rgb(255, 255, 255) !important;
  4155. }
  4156. body:is(.Dim, .LightsOut) [role="button"][data-testid$="-unfollow"]:not(:hover) > :is(div, span) {
  4157. color: rgb(15, 20, 25) !important;
  4158. }
  4159. /* Follow button */
  4160. body.Default [role="button"][data-testid$="-follow"] {
  4161. border-color: rgb(207, 217, 222) !important;
  4162. }
  4163. body:is(.Dim, .LightsOut) [role="button"][data-testid$="-follow"] {
  4164. border-color: rgb(83, 100, 113) !important;
  4165. }
  4166. body.Default [role="button"][data-testid$="-follow"] > :is(div, span) {
  4167. color: rgb(15, 20, 25) !important;
  4168. }
  4169. body:is(.Dim, .LightsOut) [role="button"][data-testid$="-follow"] > :is(div, span) {
  4170. color: rgb(255, 255, 255) !important;
  4171. }
  4172. body.Default [role="button"][data-testid$="-follow"]:hover {
  4173. background-color: rgba(15, 20, 25, 0.1) !important;
  4174. }
  4175. body:is(.Dim, .LightsOut) [role="button"][data-testid$="-follow"]:hover {
  4176. background-color: rgba(255, 255, 255, 0.1) !important;
  4177. }
  4178. `)
  4179. }
  4180. if (config.followButtonStyle == 'themed' && themeColor != null) {
  4181. cssRules.push(`
  4182. /* Following button */
  4183. [role="button"][data-testid$="-unfollow"]:not(:hover) {
  4184. background-color: ${themeColor} !important;
  4185. }
  4186. [role="button"][data-testid$="-unfollow"]:not(:hover) > :is(div, span) {
  4187. color: rgb(255, 255, 255) !important;
  4188. }
  4189. /* Follow button */
  4190. [role="button"][data-testid$="-follow"] {
  4191. border-color: ${themeColor} !important;
  4192. }
  4193. [role="button"][data-testid$="-follow"] > :is(div, span) {
  4194. color: ${themeColor} !important;
  4195. }
  4196. [role="button"][data-testid$="-follow"]:hover {
  4197. background-color: ${themeColor} !important;
  4198. }
  4199. [role="button"][data-testid$="-follow"]:hover > :is(div, span) {
  4200. color: rgb(255, 255, 255) !important;
  4201. }
  4202. `)
  4203. }
  4204. if (mobile) {
  4205. cssRules.push(`
  4206. body.MediaViewer [role="button"][data-testid$="follow"]:not(:hover) {
  4207. border: revert !important;
  4208. background-color: transparent !important;
  4209. }
  4210. body.MediaViewer [role="button"][data-testid$="follow"]:not(:hover) > div {
  4211. color: ${themeColor} !important;
  4212. }
  4213. `)
  4214. }
  4215. }
  4216.  
  4217. $style.textContent = cssRules.map(dedent).join('\n')
  4218. }
  4219. })()
  4220.  
  4221. async function setDefaultSortReplies() {
  4222. if (config.sortReplies == 'relevant') return
  4223.  
  4224. let $sortRepliesIconPath = await getElement(Selectors.SORT_REPLIES_PATH, {
  4225. name: 'sort replies icon',
  4226. stopIf: pageIsNot(currentPage),
  4227. timeout: 3000,
  4228. })
  4229. if (!$sortRepliesIconPath) return
  4230.  
  4231. let $svg = $sortRepliesIconPath.parentElement.parentElement
  4232. let currentSort = $svg.nextElementSibling?.textContent
  4233. log('sortReplies: replies are sorted by', currentSort)
  4234. if (currentSort != getString('MOST_RELEVANT')) return
  4235.  
  4236. function changeSort() {
  4237. if (changingSortReplies) {
  4238. warn('sortReplies: ignoring additonal changeSort() call')
  4239. return
  4240. }
  4241. changingSortReplies = true
  4242. log('sortReplies: clicking Sort replies dropdown', $svg.parentElement.parentElement)
  4243. setTimeout(() => $svg.parentElement.parentElement.click(), 100)
  4244. }
  4245.  
  4246. let $focusedTweet = $svg.closest('div[data-testid="cellInnerDiv"]')
  4247. if ($focusedTweet.parentElement.childElementCount > 1) {
  4248. changeSort()
  4249. return
  4250. }
  4251.  
  4252. pageObservers.push(
  4253. observeElement($focusedTweet.parentElement, () => {
  4254. if ($focusedTweet.parentElement.childElementCount > 2) {
  4255. log('sortReplies: timeline elements added')
  4256. disconnectPageObserver('sortReplies: individual tweet timeline')
  4257. changeSort()
  4258. }
  4259. }, 'sortReplies: individual tweet timeline')
  4260. )
  4261. }
  4262.  
  4263. function getColorScheme() {
  4264. return {
  4265. 'rgb(255, 255, 255)': 'Default',
  4266. 'rgb(21, 32, 43)': 'Dim',
  4267. 'rgb(0, 0, 0)': 'LightsOut',
  4268. }[$body.style.backgroundColor]
  4269. }
  4270.  
  4271. /**
  4272. * @param {HTMLElement} $tweet
  4273. * @param {?{getText?: boolean}} options
  4274. * @returns {import("./types").QuotedTweet}
  4275. */
  4276. function getQuotedTweetDetails($tweet, options = {}) {
  4277. let {getText = false} = options
  4278. let $quotedByLink = /** @type {HTMLAnchorElement} */ ($tweet.querySelector('[data-testid="User-Name"] a'))
  4279. let $quotedTweet = $tweet.querySelector('div[id^="id__"] > div[dir] > span').parentElement.nextElementSibling
  4280. let $userName = $quotedTweet?.querySelector('[data-testid="User-Name"]')
  4281. let quotedBy = $quotedByLink?.pathname?.substring(1)
  4282. let user = $userName?.querySelector('[tabindex="-1"]')?.textContent
  4283. let time = $userName?.querySelector('time')?.dateTime
  4284. if (!getText) return {quotedBy, user, time}
  4285.  
  4286. let $heading = $quotedTweet?.querySelector(':scope > div > div:first-child')
  4287. let $qtText = $heading?.nextElementSibling?.querySelector('[lang]')
  4288. let text = $qtText && Array.from($qtText.childNodes, node => {
  4289. if (node.nodeType == 1) {
  4290. if (node.nodeName == 'IMG') return node.alt
  4291. return node.textContent
  4292. }
  4293. return node.nodeValue
  4294. }).join('')
  4295. return {quotedBy, user, time, text}
  4296. }
  4297.  
  4298. /**
  4299. * Attempts to determine the type of a timeline Tweet given the element with
  4300. * data-testid="tweet" on it, falling back to TWEET if it doesn't appear to be
  4301. * one of the particular types we care about.
  4302. * @param {HTMLElement} $tweet
  4303. * @param {?boolean} checkSocialContext
  4304. * @returns {import("./types").TweetType}
  4305. */
  4306. function getTweetType($tweet, checkSocialContext = false) {
  4307. if ($tweet.closest(Selectors.PROMOTED_TWEET_CONTAINER)) {
  4308. return 'PROMOTED_TWEET'
  4309. }
  4310. // Assume social context tweets are Retweets
  4311. if ($tweet.querySelector('[data-testid="socialContext"]')) {
  4312. if (checkSocialContext) {
  4313. let svgPath = $tweet.querySelector('svg path')?.getAttribute('d') ?? ''
  4314. if (svgPath.startsWith('M7 4.5C7 3.12 8.12 2 9.5 2h5C1')) return 'PINNED_TWEET'
  4315. }
  4316. // Quoted tweets from accounts you blocked or muted are displayed as an
  4317. // <article> with "This Tweet is unavailable."
  4318. if ($tweet.querySelector('article')) {
  4319. return 'UNAVAILABLE_RETWEET'
  4320. }
  4321. // Quoted tweets are preceded by visually-hidden "Quote" text
  4322. if ($tweet.querySelector('div[id^="id__"] > div[dir] > span')?.textContent.includes(getString('QUOTE'))) {
  4323. return 'RETWEETED_QUOTE_TWEET'
  4324. }
  4325. return 'RETWEET'
  4326. }
  4327. // Quoted tweets are preceded by visually-hidden "Quote" text
  4328. if ($tweet.querySelector('div[id^="id__"] > div[dir] > span')?.textContent.includes(getString('QUOTE'))) {
  4329. return 'QUOTE_TWEET'
  4330. }
  4331. // Quoted tweets from accounts you blocked or muted are displayed as an
  4332. // <article> with "This Tweet is unavailable."
  4333. if ($tweet.querySelector('article')) {
  4334. return 'UNAVAILABLE_QUOTE_TWEET'
  4335. }
  4336. return 'TWEET'
  4337. }
  4338.  
  4339. // Add 1 every time this gets broken: 6
  4340. function getVerifiedProps($svg) {
  4341. let propsGetter = (props) => props?.children?.props?.children?.[0]?.[0]?.props
  4342. let $parent = $svg.parentElement.parentElement
  4343. // Verified badge button on the profile screen
  4344. if (isOnProfilePage() && $svg.parentElement.getAttribute('role') == 'button') {
  4345. $parent = $svg.closest('span').parentElement
  4346. }
  4347. // Link variant in "user followed/liked/retweeted" notifications
  4348. else if (isOnNotificationsPage() && $parent.getAttribute('role') == 'link') {
  4349. propsGetter = (props) => {
  4350. let linkChildren = props?.children?.props?.children?.[0]
  4351. return linkChildren?.[linkChildren.length - 1]?.props
  4352. }
  4353. }
  4354. if ($parent.wrappedJSObject) {
  4355. $parent = $parent.wrappedJSObject
  4356. }
  4357. let reactPropsKey = Object.keys($parent).find(key => key.startsWith('__reactProps$'))
  4358. let props = propsGetter($parent[reactPropsKey])
  4359. if (!props) {
  4360. warn('React props not found for', $svg)
  4361. }
  4362. else if (!('isBlueVerified' in props)) {
  4363. warn('isBlueVerified not in React props for', $svg, {props})
  4364. }
  4365. return props
  4366. }
  4367.  
  4368. /**
  4369. * @param {HTMLElement} $popup
  4370. * @returns {{tookAction: boolean, onPopupClosed?: () => void}}
  4371. */
  4372. function handlePopup($popup) {
  4373. let result = {tookAction: false, onPopupClosed: null}
  4374.  
  4375. if (changingSortReplies) {
  4376. let $dialog = /** @type {HTMLElement} */ ($popup.querySelector(`[data-testid="${desktop ? 'HoverCard' : 'sheetDialog'}"]`))
  4377. if ($dialog) {
  4378. let $menuItems = /** @type {NodeListOf<HTMLElement>} */ ($dialog.querySelectorAll('div[role="menuitem"]'))
  4379. if ($menuItems[0].previousElementSibling?.textContent == getString('SORT_REPLIES')) {
  4380. log('sortReplies: changing Sort replies to', config.sortReplies)
  4381. $menuItems[{recent: 1, liked: 2}[config.sortReplies]]?.click()
  4382. } else {
  4383. warn('sortReplies: dialog does not contain "Sort replies" heading')
  4384. }
  4385. result.tookAction = true
  4386. changingSortReplies = false
  4387. return result
  4388. } else {
  4389. warn('sortReplies: could not find Sort replies dialog')
  4390. changingSortReplies = false
  4391. }
  4392. }
  4393.  
  4394. if (desktop && !isDesktopComposeTweetModalOpen && location.pathname.startsWith(PagePaths.COMPOSE_TWEET)) {
  4395. log('compose tweet modal opened')
  4396. isDesktopComposeTweetModalOpen = true
  4397. observeDesktopComposeTweetModal($popup)
  4398. return {
  4399. tookAction: true,
  4400. onPopupClosed() {
  4401. log('compose tweet modal closed')
  4402. isDesktopComposeTweetModalOpen = false
  4403. // The Tweet button will re-render if the modal was opened to edit
  4404. // multiple Tweets on the Home timeline.
  4405. if (config.replaceLogo && isOnHomeTimelinePage()) {
  4406. tweakTweetButton()
  4407. }
  4408. }
  4409. }
  4410. }
  4411.  
  4412. if (desktop && !isDesktopMediaModalOpen && URL_MEDIA_RE.test(location.pathname) && currentPath != location.pathname) {
  4413. log('media modal opened')
  4414. isDesktopMediaModalOpen = true
  4415. observeDesktopModalTimeline($popup)
  4416. return {
  4417. tookAction: true,
  4418. onPopupClosed() {
  4419. log('media modal closed')
  4420. isDesktopMediaModalOpen = false
  4421. disconnectAllModalObservers()
  4422. }
  4423. }
  4424. }
  4425.  
  4426. if (config.replaceLogo) {
  4427. let $retweetDropdownItem = $popup.querySelector('div:is([data-testid="retweetConfirm"], [data-testid="repostConfirm"])')
  4428. if ($retweetDropdownItem) {
  4429. tweakRetweetDropdown($retweetDropdownItem, 'div:is([data-testid="retweetConfirm"], [data-testid="repostConfirm"])', 'RETWEET')
  4430. return {tookAction: true}
  4431. }
  4432.  
  4433. let $unretweetDropdownItem = $popup.querySelector('div:is([data-testid="unretweetConfirm"], [data-testid="unrepostConfirm"])')
  4434. if ($unretweetDropdownItem) {
  4435. tweakRetweetDropdown($unretweetDropdownItem, 'div:is([data-testid="unretweetConfirm"], [data-testid="unrepostConfirm"])', 'UNDO_RETWEET')
  4436. return {tookAction: true}
  4437. }
  4438.  
  4439. let $hoverLabel = $popup.querySelector('span[data-testid="HoverLabel"] > span')
  4440. if ($hoverLabel?.textContent == getString('REPOST')) {
  4441. $hoverLabel.textContent = getString('RETWEET')
  4442. }
  4443. }
  4444.  
  4445. if (isOnListPage()) {
  4446. let $switchSvg = $popup.querySelector(`svg path[d="M3 2h18.61l-3.5 7 3.5 7H5v6H3V2zm2 12h13.38l-2.5-5 2.5-5H5v10z"]`)
  4447. if ($switchSvg) {
  4448. addToggleListRetweetsMenuItem($popup.querySelector(`[role="menuitem"]`))
  4449. return {tookAction: true}
  4450. }
  4451. }
  4452.  
  4453. if (config.mutableQuoteTweets) {
  4454. if (quotedTweet) {
  4455. let $blockMenuItem = /** @type {HTMLElement} */ ($popup.querySelector(Selectors.BLOCK_MENU_ITEM))
  4456. if ($blockMenuItem) {
  4457. addMuteQuotesMenuItems($blockMenuItem)
  4458. result.tookAction = true
  4459. // Clear the quoted tweet when the popup closes
  4460. result.onPopupClosed = () => {
  4461. quotedTweet = null
  4462. }
  4463. } else {
  4464. quotedTweet = null
  4465. }
  4466. }
  4467. }
  4468.  
  4469. if (config.fastBlock) {
  4470. if (blockMenuItemSeen && $popup.querySelector('[data-testid="confirmationSheetConfirm"]')) {
  4471. log('fast blocking')
  4472. ;/** @type {HTMLElement} */ ($popup.querySelector('[data-testid="confirmationSheetConfirm"]')).click()
  4473. result.tookAction = true
  4474. }
  4475. else if ($popup.querySelector(Selectors.BLOCK_MENU_ITEM)) {
  4476. log('preparing for fast blocking')
  4477. blockMenuItemSeen = true
  4478. // Create a nested observer for mobile, as it reuses the popup element
  4479. result.tookAction = !mobile
  4480. } else {
  4481. blockMenuItemSeen = false
  4482. }
  4483. }
  4484.  
  4485. if (config.hideTwitterBlueUpsells) {
  4486. // The "Pin to your profile" menu item is currently the only one which opens
  4487. // a sheet dialog.
  4488. if (pinMenuItemSeen && $popup.querySelector('[data-testid="sheetDialog"]')) {
  4489. log('pin to your profile modal opened')
  4490. $popup.classList.add('PinModal')
  4491. result.tookAction = true
  4492. }
  4493. else if ($popup.querySelector('[data-testid="highlighOnPin"]')) {
  4494. log('preparing to hide Twitter Blue upsell when pinning a tweet')
  4495. pinMenuItemSeen = true
  4496. // Create a nested observer for mobile, as it reuses the popup element
  4497. result.tookAction = !mobile
  4498. } else {
  4499. pinMenuItemSeen = false
  4500. }
  4501. }
  4502.  
  4503. if (config.addAddMutedWordMenuItem) {
  4504. let linkSelector = 'a[href$="/settings"]'
  4505. let $link = /** @type {HTMLElement} */ ($popup.querySelector(linkSelector))
  4506. if ($link) {
  4507. addAddMutedWordMenuItem($link, linkSelector)
  4508. result.tookAction = true
  4509. }
  4510. }
  4511.  
  4512. if (config.twitterBlueChecks != 'ignore') {
  4513. // User typeahead dropdown
  4514. let $typeaheadDropdown = /** @type {HTMLElement} */ ($popup.querySelector('div[id^="typeaheadDropdown"]'))
  4515. if ($typeaheadDropdown) {
  4516. log('typeahead dropdown appeared')
  4517. let observer = observeElement($typeaheadDropdown, () => {
  4518. processBlueChecks($typeaheadDropdown)
  4519. }, 'popup typeahead dropdown')
  4520. return {
  4521. tookAction: true,
  4522. onPopupClosed() {
  4523. log('typeahead dropdown closed')
  4524. observer.disconnect()
  4525. }
  4526. }
  4527. }
  4528. }
  4529.  
  4530. if (config.hideGrokNav || config.twitterBlueChecks != 'ignore') {
  4531. // User hovercard popup
  4532. let $hoverCard = /** @type {HTMLElement} */ ($popup.querySelector('[data-testid="HoverCard"]'))
  4533. if ($hoverCard) {
  4534. result.tookAction = true
  4535. getElement('div[data-testid^="UserAvatar-Container"]', {
  4536. context: $hoverCard,
  4537. name: 'user hovercard contents',
  4538. timeout: 500,
  4539. }).then(($contents) => {
  4540. if (!$contents) return
  4541. if (config.hideGrokNav) {
  4542. // Tag Grok "Profile Summary" button
  4543. let $grokButton = $popup.querySelector('[data-testid="HoverCard"] > div > div > div:last-child:has(> button)')
  4544. if ($grokButton) {
  4545. $grokButton.classList.add('GrokButton')
  4546. }
  4547. }
  4548. if (config.twitterBlueChecks != 'ignore') {
  4549. processBlueChecks($popup)
  4550. }
  4551. })
  4552. }
  4553. }
  4554.  
  4555. // Verified account popup when you press the check button on a profile page
  4556. if (config.twitterBlueChecks == 'replace' && isOnProfilePage()) {
  4557. if (mobile) {
  4558. let $verificationBadge = /** @type {HTMLElement} */ ($popup.querySelector('[data-testid="sheetDialog"] [data-testid="verificationBadge"]'))
  4559. if ($verificationBadge) {
  4560. result.tookAction = true
  4561. let $headerBlueCheck = document.querySelector(`body.Profile ${Selectors.MOBILE_TIMELINE_HEADER} .tnt_blue_check`)
  4562. if ($headerBlueCheck) {
  4563. blueCheck($verificationBadge)
  4564. }
  4565. }
  4566. } else {
  4567. let $hoverCard = /** @type {HTMLElement} */ ($popup.querySelector('[data-testid="HoverCard"]'))
  4568. if ($hoverCard) {
  4569. result.tookAction = true
  4570. getElement(':scope > div > div > div > svg[data-testid="verificationBadge"]', {
  4571. context: $hoverCard,
  4572. name: 'verified account hovercard verification badge',
  4573. timeout: 500,
  4574. }).then(($verificationBadge) => {
  4575. if (!$verificationBadge) return
  4576.  
  4577. let $headerBlueCheck = document.querySelector(`body.Profile ${Selectors.PRIMARY_COLUMN} > div > div:first-of-type h2 .tnt_blue_check`)
  4578. if (!$headerBlueCheck) return
  4579.  
  4580. // Wait for the hovercard to render its contents
  4581. let popupRenderObserver = observeElement($popup, (mutations) => {
  4582. if (!mutations.length) return
  4583. blueCheck($popup.querySelector('svg[data-testid="verificationBadge"]'))
  4584. popupRenderObserver.disconnect()
  4585. }, 'verified popup render', {childList: true, subtree: true})
  4586. })
  4587. }
  4588. }
  4589. }
  4590.  
  4591. return result
  4592. }
  4593.  
  4594. function isBlueVerified($svg) {
  4595. let props = getVerifiedProps($svg)
  4596. return Boolean(props && props.isBlueVerified && !(
  4597. props.verifiedType || (
  4598. props.affiliateBadgeInfo?.userLabelType == 'BusinessLabel' &&
  4599. props.affiliateBadgeInfo?.description == 'X'
  4600. )
  4601. ))
  4602. }
  4603.  
  4604. /**
  4605. * @returns {import("./types").VerifiedType}
  4606. */
  4607. function getVerifiedType($svg) {
  4608. let props = getVerifiedProps($svg)
  4609. if (props) {
  4610. if (props.affiliateBadgeInfo?.userLabelType == 'BusinessLabel' &&
  4611. props.affiliateBadgeInfo?.description == 'X')
  4612. // Ignore Twitter associated checks
  4613. return null
  4614. if (props.verifiedType == 'Business')
  4615. return 'VERIFIED_ORG'
  4616. if (props.isBlueVerified)
  4617. return 'BLUE'
  4618. }
  4619. return null
  4620. }
  4621.  
  4622. /**
  4623. * Checks if a tweet is preceded by an element creating a vertical reply line.
  4624. * @param {HTMLElement} $tweet
  4625. * @returns {boolean}
  4626. */
  4627. function isReplyToPreviousTweet($tweet) {
  4628. let $replyLine = $tweet.firstElementChild?.firstElementChild?.firstElementChild?.firstElementChild?.firstElementChild?.firstElementChild
  4629. if ($replyLine) {
  4630. return getComputedStyle($replyLine).width == '2px'
  4631. }
  4632. }
  4633.  
  4634. /**
  4635. * @returns {{disconnect()}}
  4636. */
  4637. function onPopup($popup) {
  4638. log('popup appeared', $popup, location.pathname)
  4639.  
  4640. // If handlePopup did something, we don't need to observe nested popups
  4641. let {tookAction, onPopupClosed} = handlePopup($popup)
  4642. if (tookAction) {
  4643. return onPopupClosed ? {disconnect: onPopupClosed} : null
  4644. }
  4645.  
  4646. /** @type {HTMLElement} */
  4647. let $nestedPopup
  4648.  
  4649. let nestedObserver = observeElement($popup, (mutations) => {
  4650. mutations.forEach((mutation) => {
  4651. mutation.addedNodes.forEach((/** @type {HTMLElement} */ $el) => {
  4652. log('nested popup appeared', $el)
  4653. $nestedPopup = $el
  4654. ;({onPopupClosed} = handlePopup($el))
  4655. })
  4656. mutation.removedNodes.forEach((/** @type {HTMLElement} */ $el) => {
  4657. if ($el !== $nestedPopup) return
  4658. if (onPopupClosed) {
  4659. log('cleaning up after nested popup removed')
  4660. onPopupClosed()
  4661. }
  4662. })
  4663. })
  4664. }, 'nested popup observer')
  4665.  
  4666. let disconnect = nestedObserver.disconnect.bind(nestedObserver)
  4667. nestedObserver.disconnect = () => {
  4668. if (onPopupClosed) {
  4669. log('cleaning up after nested popup observer disconnected')
  4670. onPopupClosed()
  4671. }
  4672. disconnect()
  4673. }
  4674.  
  4675. return nestedObserver
  4676. }
  4677.  
  4678. /**
  4679. * @param {HTMLElement} $timeline
  4680. * @param {string} page
  4681. * @param {import("./types").TimelineOptions?} options
  4682. */
  4683. function onTimelineChange($timeline, page, options = {}) {
  4684. let startTime = Date.now()
  4685. let {classifyTweets = true, hideHeadings = true, isUserTimeline = false} = options
  4686.  
  4687. let isOnHomeTimeline = isOnHomeTimelinePage()
  4688. let isOnListTimeline = isOnListPage()
  4689. let isOnProfileTimeline = isOnProfilePage()
  4690. let timelineHasSpecificHandling = isOnHomeTimeline || isOnListTimeline || isOnProfileTimeline
  4691.  
  4692. if (config.twitterBlueChecks != 'ignore' && (isUserTimeline || !timelineHasSpecificHandling)) {
  4693. processBlueChecks($timeline)
  4694. }
  4695.  
  4696. if (isSafari && config.replaceLogo && isOnNotificationsPage()) {
  4697. processTwitterLogos($timeline)
  4698. }
  4699.  
  4700. if (isUserTimeline || !classifyTweets) return
  4701.  
  4702. let itemTypes = {}
  4703. let hiddenItemCount = 0
  4704. let hiddenItemTypes = {}
  4705.  
  4706. /** @type {?boolean} */
  4707. let hidPreviousItem = null
  4708. /** @type {{$item: Element, hideItem?: boolean}[]} */
  4709. let changes = []
  4710.  
  4711. for (let $item of $timeline.children) {
  4712. /** @type {?import("./types").TimelineItemType} */
  4713. let itemType = null
  4714. /** @type {?boolean} */
  4715. let hideItem = null
  4716. /** @type {?HTMLElement} */
  4717. let $tweet = $item.querySelector(Selectors.TWEET)
  4718. /** @type {boolean} */
  4719. let isReply = false
  4720. /** @type {boolean} */
  4721. let isBlueTweet = false
  4722.  
  4723. if ($tweet != null) {
  4724. itemType = getTweetType($tweet, isOnProfileTimeline)
  4725. if (timelineHasSpecificHandling) {
  4726. isReply = isReplyToPreviousTweet($tweet)
  4727. if (isReply && hidPreviousItem != null) {
  4728. hideItem = hidPreviousItem
  4729. } else {
  4730. if (isOnHomeTimeline) {
  4731. hideItem = shouldHideHomeTimelineItem(itemType, page)
  4732. if (config.mutableQuoteTweets && !hideItem && itemType == 'QUOTE_TWEET' && config.hideQuotesFrom.length > 0) {
  4733. let $quotedByLink = /** @type {HTMLAnchorElement} */ ($tweet.querySelector('[data-testid="User-Name"] a'))
  4734. let quotedBy = $quotedByLink?.pathname.substring(1)
  4735. if (quotedBy) {
  4736. hideItem = config.hideQuotesFrom.includes(quotedBy)
  4737. } else {
  4738. warn('hideQuotesFrom: unable to get quote tweet user')
  4739. }
  4740. }
  4741. }
  4742. else if (isOnListTimeline) {
  4743. hideItem = shouldHideListTimelineItem(itemType)
  4744. }
  4745. else if (isOnProfileTimeline) {
  4746. hideItem = shouldHideProfileTimelineItem(itemType)
  4747. }
  4748. }
  4749.  
  4750. if (!hideItem && config.mutableQuoteTweets && (itemType == 'QUOTE_TWEET' || itemType == 'RETWEETED_QUOTE_TWEET')) {
  4751. if (config.mutedQuotes.length > 0) {
  4752. let quotedTweet = getQuotedTweetDetails($tweet)
  4753. hideItem = config.mutedQuotes.some(muted => muted.user == quotedTweet.user && muted.time == quotedTweet.time)
  4754. }
  4755. if (!hideItem) {
  4756. addCaretMenuListenerForQuoteTweet($tweet)
  4757. }
  4758. }
  4759.  
  4760. if (config.twitterBlueChecks != 'ignore') {
  4761. for (let $svg of $tweet.querySelectorAll(Selectors.VERIFIED_TICK)) {
  4762. let isBlueCheck = isBlueVerified($svg)
  4763. if (!isBlueCheck) continue
  4764.  
  4765. blueCheck($svg)
  4766.  
  4767. // Don't count a tweet as blue if the check is in a quoted tweet
  4768. let userProfileLink = $svg.closest('a[role="link"]:not([href^="/i/status"])')
  4769. if (!userProfileLink) continue
  4770.  
  4771. isBlueTweet = true
  4772. }
  4773. }
  4774. }
  4775.  
  4776. if (!hideItem && config.restoreLinkHeadlines) {
  4777. restoreLinkHeadline($tweet)
  4778. }
  4779. }
  4780. else if (!timelineHasSpecificHandling) {
  4781. if ($item.querySelector(':scope > div > div > div > article')) {
  4782. itemType = 'UNAVAILABLE'
  4783. }
  4784. }
  4785.  
  4786. if (!timelineHasSpecificHandling) {
  4787. if (itemType != null) {
  4788. hideItem = shouldHideOtherTimelineItem(itemType)
  4789. }
  4790. }
  4791.  
  4792. // Special handling for non-Tweet timeline items
  4793. if (itemType == null) {
  4794. if ($item.querySelector('[data-testid="inlinePrompt"]')) {
  4795. itemType = 'INLINE_PROMPT'
  4796. hideItem = config.hideInlinePrompts || (
  4797. config.hideTwitterBlueUpsells && Boolean($item.querySelector('a[href^="/i/premium"]')) ||
  4798. config.hideMonetizationNav && Boolean($item.querySelector('a[href="/settings/monetization"]'))
  4799. )
  4800. } else if ($item.querySelector(Selectors.TIMELINE_HEADING)) {
  4801. itemType = 'HEADING'
  4802. hideItem = hideHeadings && config.hideWhoToFollowEtc
  4803. }
  4804. }
  4805.  
  4806. if (debug && itemType != null) {
  4807. $item.firstElementChild.dataset.itemType = `${itemType}${isReply ? ' / REPLY' : ''}${isBlueTweet ? ' / BLUE' : ''}`
  4808. }
  4809.  
  4810. // Assume a non-identified item following an identified item is related
  4811. if (itemType == null && hidPreviousItem != null) {
  4812. hideItem = hidPreviousItem
  4813. itemType = 'SUBSEQUENT_ITEM'
  4814. }
  4815.  
  4816. if (itemType != null) {
  4817. itemTypes[itemType] ||= 0
  4818. itemTypes[itemType]++
  4819. }
  4820.  
  4821. if (hideItem) {
  4822. hiddenItemCount++
  4823. hiddenItemTypes[itemType] ||= 0
  4824. hiddenItemTypes[itemType]++
  4825. }
  4826.  
  4827. if (hideItem != null && $item.firstElementChild) {
  4828. let hidden = $item.firstElementChild.classList.contains('HiddenTweet')
  4829. if (hidden != hideItem) {
  4830. changes.push({$item, hideItem})
  4831. }
  4832. }
  4833.  
  4834. hidPreviousItem = hideItem
  4835. }
  4836.  
  4837. for (let change of changes) {
  4838. change.$item.firstElementChild.classList.toggle('HiddenTweet', change.hideItem)
  4839. }
  4840.  
  4841. log(
  4842. `processed ${$timeline.children.length} timeline item${s($timeline.children.length)} in ${Date.now() - startTime}ms`,
  4843. itemTypes, `hid ${hiddenItemCount}`, hiddenItemTypes
  4844. )
  4845. }
  4846.  
  4847. /**
  4848. * @param {HTMLElement} $timeline
  4849. * @param {import("./types").IndividualTweetTimelineOptions} options
  4850. */
  4851. function onIndividualTweetTimelineChange($timeline, options) {
  4852. let startTime = Date.now()
  4853.  
  4854. let itemTypes = {}
  4855. let hiddenItemCount = 0
  4856. let hiddenItemTypes = {}
  4857.  
  4858. /** @type {?boolean} */
  4859. let hidPreviousItem = null
  4860. /** @type {boolean} */
  4861. let hideAllSubsequentItems = false
  4862. /** @type {string} */
  4863. let opScreenName = /^\/([a-zA-Z\d_]{1,20})\//.exec(location.pathname)[1].toLowerCase()
  4864. /** @type {{$item: Element, hideItem?: boolean}[]} */
  4865. let changes = []
  4866. /** @type {import("./types").UserInfoObject} */
  4867. let userInfo = getUserInfo()
  4868. /** @type {?HTMLElement} */
  4869. let $focusedTweet
  4870.  
  4871. for (let $item of $timeline.children) {
  4872. /** @type {?import("./types").TimelineItemType} */
  4873. let itemType = null
  4874. /** @type {?boolean} */
  4875. let hideItem = null
  4876. /** @type {?HTMLElement} */
  4877. let $tweet = $item.querySelector(Selectors.TWEET)
  4878. /** @type {boolean} */
  4879. let isFocusedTweet = false
  4880. /** @type {boolean} */
  4881. let isReply = false
  4882. /** @type {import("./types").VerifiedType} */
  4883. let tweetVerifiedType = null
  4884. /** @type {?string} */
  4885. let screenName = null
  4886.  
  4887. if (hideAllSubsequentItems) {
  4888. hideItem = true
  4889. itemType = 'DISCOVER_MORE_TWEET'
  4890. }
  4891. else if ($tweet != null) {
  4892. isFocusedTweet = $tweet.tabIndex == -1
  4893. isReply = isReplyToPreviousTweet($tweet)
  4894. if (isFocusedTweet) {
  4895. itemType = 'FOCUSED_TWEET'
  4896. hideItem = false
  4897. $focusedTweet = $tweet
  4898. } else {
  4899. itemType = getTweetType($tweet)
  4900. if (isReply && hidPreviousItem != null) {
  4901. hideItem = hidPreviousItem
  4902. } else {
  4903. hideItem = shouldHideIndividualTweetTimelineItem(itemType)
  4904. }
  4905. }
  4906.  
  4907. if (!hideItem && config.restoreLinkHeadlines) {
  4908. restoreLinkHeadline($tweet)
  4909. }
  4910.  
  4911. if (!hideItem && (config.twitterBlueChecks != 'ignore' || config.hideTwitterBlueReplies)) {
  4912. for (let $svg of $tweet.querySelectorAll(Selectors.VERIFIED_TICK)) {
  4913. let verifiedType = getVerifiedType($svg)
  4914. if (!verifiedType) continue
  4915.  
  4916. if (config.twitterBlueChecks != 'ignore' && verifiedType == 'BLUE') {
  4917. blueCheck($svg)
  4918. }
  4919.  
  4920. // Don't count a tweet as verified if the check is in a quoted tweet
  4921. let $userProfileLink = /** @type {HTMLAnchorElement} */ ($svg.closest('a[role="link"]:not([href^="/i/status"])'))
  4922. if (!$userProfileLink) continue
  4923.  
  4924. tweetVerifiedType = verifiedType
  4925. screenName = $userProfileLink.href.split('/').pop()
  4926. }
  4927.  
  4928. // Replies to the focused tweet don't have the reply indicator
  4929. if (tweetVerifiedType && !isFocusedTweet && !isReply && screenName.toLowerCase() != opScreenName) {
  4930. itemType = `${tweetVerifiedType}_REPLY`
  4931. if (!hideItem) {
  4932. let user = userInfo[screenName]
  4933. let shouldHideBasedOnVerifiedType = config.hideTwitterBlueReplies && (
  4934. tweetVerifiedType == 'BLUE' ||
  4935. tweetVerifiedType == 'VERIFIED_ORG' && !config.showBlueReplyVerifiedAccounts
  4936. )
  4937. hideItem = shouldHideBasedOnVerifiedType && (user == null || !(
  4938. user.following && !config.hideBlueReplyFollowing ||
  4939. user.followedBy && !config.hideBlueReplyFollowedBy ||
  4940. config.showBlueReplyFollowersCount && user.followersCount >= Number(config.showBlueReplyFollowersCountAmount)
  4941. ))
  4942. }
  4943. }
  4944. }
  4945. }
  4946. else {
  4947. let $article = $item.querySelector('article')
  4948. if ($article) {
  4949. // Deleted or private, unless…
  4950. itemType = 'UNAVAILABLE'
  4951. let $button = $article.querySelector('[role="button"]')
  4952. if ($button) {
  4953. if ($button.textContent == getString('SHOW')) {
  4954. itemType = 'SHOW_MORE'
  4955. }
  4956. else if ($button.textContent == getString('VIEW')) {
  4957. // "This Tweet is from an account you (blocked|muted)." with a View button
  4958. hideItem = config.hideUnavailableQuoteTweets
  4959. }
  4960. }
  4961. else if ($article.textContent == getString('POST_UNAVAILABLE')) {
  4962. // Likely blocked or muted
  4963. hideItem = config.hideUnavailableQuoteTweets
  4964. }
  4965. } else {
  4966. // We need to identify "Show more replies" so it doesn't get hidden if the
  4967. // item immediately before it was hidden.
  4968. let $button = $item.querySelector('button[role="button"]')
  4969. if ($button) {
  4970. if ($button?.textContent == getString('SHOW_MORE_REPLIES')) {
  4971. itemType = 'SHOW_MORE'
  4972. }
  4973. } else {
  4974. let $heading = $item.querySelector(Selectors.TIMELINE_HEADING)
  4975. if ($heading) {
  4976. // Discover More headings have a description next to them
  4977. if ($heading.nextElementSibling &&
  4978. $heading.nextElementSibling.tagName == 'DIV' &&
  4979. $heading.nextElementSibling.getAttribute('dir') != null) {
  4980. itemType = 'DISCOVER_MORE_HEADING'
  4981. hideItem = config.hideMoreTweets
  4982. hideAllSubsequentItems = config.hideMoreTweets
  4983. } else {
  4984. itemType = 'HEADING'
  4985. }
  4986. }
  4987. }
  4988. }
  4989. }
  4990.  
  4991. if (debug && itemType != null) {
  4992. $item.firstElementChild.dataset.itemType = `${itemType}${isReply ? ' / REPLY' : ''}`
  4993. }
  4994.  
  4995. // Assume a non-identified item following an identified item is related
  4996. if (itemType == null && hidPreviousItem != null) {
  4997. hideItem = hidPreviousItem
  4998. itemType = 'SUBSEQUENT_ITEM'
  4999. }
  5000.  
  5001. if (itemType != null) {
  5002. itemTypes[itemType] ||= 0
  5003. itemTypes[itemType]++
  5004. }
  5005.  
  5006. if (hideItem) {
  5007. hiddenItemCount++
  5008. hiddenItemTypes[itemType] ||= 0
  5009. hiddenItemTypes[itemType]++
  5010. }
  5011.  
  5012. if (isFocusedTweet) {
  5013. // Tweets prior to the focused tweet should never be hidden
  5014. changes = []
  5015. hiddenItemCount = 0
  5016. hiddenItemTypes = {}
  5017. }
  5018. else if (hideItem != null && $item.firstElementChild) {
  5019. let hidden = $item.firstElementChild.classList.contains('HiddenTweet')
  5020. if (hidden != hideItem) {
  5021. changes.push({$item, hideItem})
  5022. }
  5023. }
  5024.  
  5025. hidPreviousItem = hideItem
  5026. }
  5027.  
  5028. for (let change of changes) {
  5029. change.$item.firstElementChild.classList.toggle('HiddenTweet', change.hideItem)
  5030. }
  5031.  
  5032. tweakFocusedTweet($focusedTweet, options)
  5033.  
  5034. log(
  5035. `processed ${$timeline.children.length} thread item${s($timeline.children.length)} in ${Date.now() - startTime}ms`,
  5036. itemTypes, `hid ${hiddenItemCount}`, hiddenItemTypes
  5037. )
  5038. }
  5039.  
  5040. /**
  5041. * Title format (including notification count):
  5042. * - LTR: (3) ${title} / X
  5043. * - RTL: (3) X \ ${title}
  5044. * @param {string} title
  5045. */
  5046. function onTitleChange(title) {
  5047. log('title changed', {title, path: location.pathname})
  5048.  
  5049. if (checkforDisabledHomeTimeline()) return
  5050.  
  5051. // Ignore leading notification counts in titles
  5052. let notificationCount = ''
  5053. if (TITLE_NOTIFICATION_RE.test(title)) {
  5054. notificationCount = TITLE_NOTIFICATION_RE.exec(title)[0]
  5055. title = title.replace(TITLE_NOTIFICATION_RE, '')
  5056. }
  5057.  
  5058. if (config.replaceLogo && Boolean(notificationCount) != Boolean(currentNotificationCount)) {
  5059. observeFavicon.updatePip(Boolean(notificationCount))
  5060. }
  5061.  
  5062. let homeNavigationWasUsed = homeNavigationIsBeingUsed
  5063. homeNavigationIsBeingUsed = false
  5064.  
  5065. if (title == 'X' || title == getString('TWITTER')) {
  5066. // Mobile uses "Twitter" when viewing media - we need to let these process
  5067. // so the next page will be re-processed when the media is closed.
  5068. if (mobile && (URL_MEDIA_RE.test(location.pathname) || URL_MEDIAVIEWER_RE.test(location.pathname))) {
  5069. log('viewing media on mobile')
  5070. }
  5071. // Going to the root Settings page on desktop when the sidebar is hidden
  5072. // sets an empty title.
  5073. else if (desktop && location.pathname == '/settings' && currentPath != '/settings') {
  5074. log('viewing root Settings page')
  5075. }
  5076. else if (location.pathname.startsWith(PagePaths.BOOKMARKS) && !currentPath.startsWith(PagePaths.BOOKMARKS)) {
  5077. log('viewing Bookmarks page')
  5078. }
  5079. // Ignore Flash of Uninitialised Title when navigating to a page for the
  5080. // first time.
  5081. else {
  5082. log('ignoring Flash of Uninitialised Title')
  5083. return
  5084. }
  5085. }
  5086.  
  5087. // Remove " / Twitter" or "Twitter \ " from the title
  5088. let newPage = title
  5089. if (newPage != 'X' && newPage != getString('TWITTER')) {
  5090. newPage = title.slice(...ltr ? [0, title.lastIndexOf('/') - 1] : [title.indexOf('\\') + 2])
  5091. }
  5092.  
  5093. let hasDesktopModalBeenOpenedOrClosed = desktop && (
  5094. // Timeline settings dialog opened
  5095. location.pathname == PagePaths.TIMELINE_SETTINGS ||
  5096. // Timeline settings dialog closed
  5097. currentPath == PagePaths.TIMELINE_SETTINGS ||
  5098. // Media modal opened
  5099. URL_MEDIA_RE.test(location.pathname) ||
  5100. // Media modal closed
  5101. URL_MEDIA_RE.test(currentPath) ||
  5102. // "Send via Direct Message" dialog opened
  5103. location.pathname == PagePaths.COMPOSE_MESSAGE ||
  5104. // "Send via Direct Message" dialog closed
  5105. currentPath == PagePaths.COMPOSE_MESSAGE ||
  5106. // Compose Tweet dialog opened
  5107. location.pathname == PagePaths.COMPOSE_TWEET ||
  5108. // Compose Tweet dialog closed
  5109. currentPath == PagePaths.COMPOSE_TWEET
  5110. )
  5111.  
  5112. if (newPage == currentPage) {
  5113. // XXX After initial migration to x.com, Twitter has a bug where viewing a
  5114. // user profile makes the title sticky, so we also check the pathname.
  5115. // Remove this when we can, as unexpected modals on desktop will cause
  5116. // the underlying page to be reprocessed incorrectly.
  5117. if (location.pathname != currentPath && !hasDesktopModalBeenOpenedOrClosed) {
  5118. warn('Twitter bug: title is the same but path has changed', {from: currentPath, to: location.pathname})
  5119. }
  5120. else {
  5121. log(`ignoring duplicate title change`)
  5122. currentNotificationCount = notificationCount
  5123. return
  5124. }
  5125. }
  5126.  
  5127. // Search terms are shown in the title
  5128. if (currentPath == PagePaths.SEARCH && location.pathname == PagePaths.SEARCH) {
  5129. log('ignoring title change on Search page')
  5130. currentNotificationCount = notificationCount
  5131. return
  5132. }
  5133.  
  5134. // On desktop, stay on the separated tweets timeline when…
  5135. if (desktop && currentPage == separatedTweetsTimelineTitle &&
  5136. // …the title has changed back to the Home timeline…
  5137. (newPage == getString('HOME')) &&
  5138. // …the Home nav link or Following / Home header _wasn't_ clicked and…
  5139. !homeNavigationWasUsed &&
  5140. (
  5141. // …a modal which changes the pathname has been opened or closed.
  5142. hasDesktopModalBeenOpenedOrClosed ||
  5143. // …the notification count in the title changed.
  5144. notificationCount != currentNotificationCount
  5145. )) {
  5146. log('ignoring title change on separated tweets timeline')
  5147. currentNotificationCount = notificationCount
  5148. currentPath = location.pathname
  5149. setTitle(separatedTweetsTimelineTitle)
  5150. return
  5151. }
  5152.  
  5153. // Restore display of the separated tweets timelne if it's the last one we
  5154. // saw, and the user navigated back home without using the Home navigation
  5155. // item.
  5156. if (location.pathname == PagePaths.HOME &&
  5157. currentPath != PagePaths.HOME &&
  5158. !homeNavigationWasUsed &&
  5159. lastHomeTimelineTitle != null &&
  5160. separatedTweetsTimelineTitle != null &&
  5161. lastHomeTimelineTitle == separatedTweetsTimelineTitle) {
  5162. log('restoring display of the separated tweets timeline')
  5163. currentNotificationCount = notificationCount
  5164. currentPath = location.pathname
  5165. setTitle(separatedTweetsTimelineTitle)
  5166. return
  5167. }
  5168.  
  5169. // Assumption: all non-FOUT, non-duplicate title changes are navigation, which
  5170. // need the page to be re-processed.
  5171.  
  5172. currentPage = newPage
  5173. currentNotificationCount = notificationCount
  5174. currentPath = location.pathname
  5175.  
  5176. if (isOnHomeTimelinePage()) {
  5177. lastHomeTimelineTitle = currentPage
  5178. }
  5179.  
  5180. log('processing new page')
  5181.  
  5182. processCurrentPage()
  5183. }
  5184.  
  5185. /**
  5186. * Processes all Twitter Blue checks inside an element.
  5187. * @param {HTMLElement} $el
  5188. */
  5189. function processBlueChecks($el) {
  5190. for (let $svg of $el.querySelectorAll(`${Selectors.VERIFIED_TICK}:not(.tnt_blue_check)`)) {
  5191. if (isBlueVerified($svg)) {
  5192. blueCheck($svg)
  5193. }
  5194. }
  5195. }
  5196.  
  5197. /**
  5198. * Processes all Twitter logos inside an element.
  5199. */
  5200. function processTwitterLogos($el) {
  5201. for (let $svgPath of $el.querySelectorAll(Selectors.X_LOGO_PATH)) {
  5202. twitterLogo($svgPath)
  5203. }
  5204. }
  5205.  
  5206. function processCurrentPage() {
  5207. if (pageObservers.length > 0) {
  5208. log(
  5209. `disconnecting ${pageObservers.length} page observer${s(pageObservers.length)}`,
  5210. pageObservers.map(observer => observer['name'])
  5211. )
  5212. pageObservers.forEach(observer => observer.disconnect())
  5213. pageObservers = []
  5214. }
  5215.  
  5216. // Hooks for styling pages
  5217. $body.classList.toggle('Bookmarks', isOnBookmarksPage())
  5218. $body.classList.toggle('Community', isOnCommunityPage())
  5219. $body.classList.toggle('Explore', isOnExplorePage())
  5220. $body.classList.toggle('HideSidebar', shouldHideSidebar())
  5221. $body.classList.toggle('List', isOnListPage())
  5222. $body.classList.toggle('HomeTimeline', isOnHomeTimelinePage())
  5223. $body.classList.toggle('Notifications', isOnNotificationsPage())
  5224. $body.classList.toggle('Profile', isOnProfilePage())
  5225. if (!isOnProfilePage()) {
  5226. $body.classList.remove('OwnProfile', 'PremiumProfile')
  5227. }
  5228. $body.classList.toggle('ProfileFollows', isOnFollowListPage())
  5229. if (!isOnFollowListPage()) {
  5230. $body.classList.remove('Subscriptions')
  5231. }
  5232. $body.classList.toggle('QuoteTweets', isOnQuoteTweetsPage())
  5233. $body.classList.toggle('Tweet', isOnIndividualTweetPage())
  5234. $body.classList.toggle('Search', isOnSearchPage())
  5235. $body.classList.toggle('Settings', isOnSettingsPage())
  5236. $body.classList.toggle('MobileMedia', mobile && URL_MEDIA_RE.test(location.pathname))
  5237. $body.classList.toggle('MediaViewer', mobile && URL_MEDIAVIEWER_RE.test(location.pathname))
  5238. $body.classList.remove('SeparatedTweets')
  5239.  
  5240. if (desktop) {
  5241. let shouldObserveSidebarForConfig = (
  5242. config.twitterBlueChecks != 'ignore' ||
  5243. config.fullWidthContent ||
  5244. config.hideExploreNav && config.hideExploreNavWithSidebar
  5245. )
  5246. if (shouldObserveSidebarForConfig && !isOnMessagesPage() && !isOnSettingsPage()) {
  5247. observeSidebar()
  5248. } else {
  5249. $body.classList.remove('Sidebar')
  5250. }
  5251. if (isSafari && config.replaceLogo) {
  5252. tweakDesktopLogo()
  5253. }
  5254. }
  5255.  
  5256. if (isSafari && config.replaceLogo) {
  5257. tweakHomeIcon()
  5258. }
  5259.  
  5260. if (config.twitterBlueChecks != 'ignore' && (isOnSearchPage() || isOnExplorePage())) {
  5261. observeSearchForm()
  5262. }
  5263.  
  5264. if (isOnHomeTimelinePage()) {
  5265. tweakHomeTimelinePage()
  5266. }
  5267. else {
  5268. removeMobileTimelineHeaderElements()
  5269. }
  5270.  
  5271. if (isOnProfilePage()) {
  5272. tweakProfilePage()
  5273. }
  5274. else if (isOnFollowListPage()) {
  5275. tweakFollowListPage()
  5276. }
  5277. else if (isOnIndividualTweetPage()) {
  5278. tweakIndividualTweetPage()
  5279. }
  5280. else if (isOnNotificationsPage()) {
  5281. tweakNotificationsPage()
  5282. }
  5283. else if (isOnSearchPage()) {
  5284. tweakSearchPage()
  5285. }
  5286. else if (URL_TWEET_ENGAGEMENT_RE.test(currentPath)) {
  5287. tweakTweetEngagementPage()
  5288. }
  5289. else if (isOnListPage()) {
  5290. tweakListPage()
  5291. }
  5292. else if (isOnExplorePage()) {
  5293. tweakExplorePage()
  5294. }
  5295. else if (isOnBookmarksPage()) {
  5296. tweakBookmarksPage()
  5297. }
  5298. else if (isOnCommunitiesPage()) {
  5299. tweakCommunitiesPage()
  5300. }
  5301. else if (isOnCommunityPage()) {
  5302. tweakCommunityPage()
  5303. }
  5304. else if (isOnCommunityMembersPage()) {
  5305. tweakCommunityMembersPage()
  5306. }
  5307. else if (isOnDisplaySettingsPage() || isOnAccessibilitySettingsPage()) {
  5308. tweakDisplaySettingsPage()
  5309. }
  5310.  
  5311. // On mobile, these are pages instead of modals
  5312. if (mobile) {
  5313. if (currentPath == PagePaths.COMPOSE_TWEET) {
  5314. tweakMobileComposeTweetPage()
  5315. }
  5316. else if (URL_MEDIAVIEWER_RE.test(currentPath)) {
  5317. tweakMobileMediaViewerPage()
  5318. }
  5319. }
  5320. }
  5321.  
  5322. /**
  5323. * The mobile version of Twitter reuses heading elements between screens, so we
  5324. * always remove any elements which could be there from the previous page and
  5325. * re-add them later when needed.
  5326. */
  5327. function removeMobileTimelineHeaderElements() {
  5328. if (mobile) {
  5329. document.querySelector('#tnt_separated_tweets_tab')?.remove()
  5330. }
  5331. }
  5332.  
  5333. /**
  5334. * @param {HTMLElement} $tweet
  5335. */
  5336. function restoreLinkHeadline($tweet) {
  5337. let $link = /** @type {HTMLElement} */ ($tweet.querySelector('div[data-testid="card.layoutLarge.media"] > a[rel][aria-label]'))
  5338. if ($link && !$link.dataset.headlineRestored) {
  5339. let [site, ...rest] = $link.getAttribute('aria-label').split(' ')
  5340. let headline = rest.join(' ')
  5341. $link.lastElementChild?.classList.add('tnt_overlay_headline')
  5342. $link.insertAdjacentHTML('beforeend', `<div class="tnt_link_headline ${fontFamilyRule?.selectorText?.replace('.', '') || 'tnt_font_family'}" style="border-top: 1px solid var(--border-color); padding: 14px;">
  5343. <div style="color: var(--color); margin-bottom: 2px;">${site}</div>
  5344. <div style="color: var(--color-emphasis)">${headline}</div>
  5345. </div>`)
  5346. $link.dataset.headlineRestored = 'true'
  5347. }
  5348. }
  5349.  
  5350. /**
  5351. * @param {HTMLElement} $focusedTweet
  5352. */
  5353. function restoreTweetInteractionsLinks($focusedTweet) {
  5354. if (!config.restoreQuoteTweetsLink && !config.restoreOtherInteractionLinks) return
  5355.  
  5356. let [tweetLink, tweetId] = location.pathname.match(/^\/[a-zA-Z\d_]{1,20}\/status\/(\d+)/) ?? []
  5357. let tweetInfo = getTweetInfo(tweetId)
  5358. log('focused tweet', {tweetLink, tweetId, tweetInfo})
  5359. if (!tweetInfo) return
  5360.  
  5361. let shouldDisplayLinks = (
  5362. (config.restoreQuoteTweetsLink && tweetInfo.quote_count > 0) ||
  5363. (config.restoreOtherInteractionLinks && (tweetInfo.retweet_count > 0 || tweetInfo.favorite_count > 0))
  5364. )
  5365. let $existingLinks = $focusedTweet.querySelector('#tntInteractionLinks')
  5366. if (!shouldDisplayLinks || $existingLinks) {
  5367. if (!shouldDisplayLinks) $existingLinks?.remove()
  5368. return
  5369. }
  5370.  
  5371. let $group = $focusedTweet.querySelector('[role="group"][id^="id__"]')
  5372. if (!$group) return warn('focused tweet action bar not found')
  5373.  
  5374. $group.parentElement.insertAdjacentHTML('beforebegin', `
  5375. <div id="tntInteractionLinks">
  5376. <div class="${fontFamilyRule?.selectorText?.replace('.', '') || 'tnt_font_family'}" style="padding: 16px 4px; border-top: 1px solid var(--border-color); display: flex; gap: 20px;">
  5377. ${tweetInfo.quote_count > 0 ? `<a id="tntQuoteTweetsLink" class="quoteTweets" href="${tweetLink}/quotes" dir="auto" role="link">
  5378. <span id="tntQuoteTweetCount">
  5379. ${Intl.NumberFormat(lang, {notation: tweetInfo.quote_count < 10000 ? 'standard' : 'compact', compactDisplay: 'short'}).format(tweetInfo.quote_count)}
  5380. </span>
  5381. <span>${getString(tweetInfo.quote_count == 1 ? (config.replaceLogo ? 'QUOTE_TWEET' : 'QUOTE') : (config.replaceLogo ? 'QUOTE_TWEETS' : 'QUOTES'))}</span>
  5382. </a>` : ''}
  5383. ${tweetInfo.retweet_count > 0 ? `<a id="tntRetweetsLink" data-tab="2" href="${tweetLink}/retweets" dir="auto" role="link">
  5384. <span>${getString(config.replaceLogo ? 'RETWEETS' : 'REPOSTS')}</span>
  5385. </a>` : ''}
  5386. ${tweetInfo.favorite_count > 0 ? `<a id="tntLikesLink" data-tab="3" href="${tweetLink}/likes" dir="auto" role="link">
  5387. <span>${getString('LIKES')}</span>
  5388. </a>` : ''}
  5389. </div>
  5390. </div>
  5391. `)
  5392.  
  5393. let links = /** @type {NodeListOf<HTMLAnchorElement>} */ ($focusedTweet.querySelectorAll('#tntInteractionLinks a'))
  5394. links.forEach(($link) => {
  5395. $link.addEventListener('click', async (e) => {
  5396. let $caret = /** @type {HTMLElement} */ ($focusedTweet.querySelector('[data-testid="caret"]'))
  5397. if (!$caret) return warn('focused tweet menu caret not found')
  5398.  
  5399. log('clicking "View post engagements" menu item')
  5400. e.preventDefault()
  5401. $caret.click()
  5402. let $tweetEngagements = await getElement('#layers a[data-testid="tweetEngagements"]', {
  5403. name: 'View post engagements menu item',
  5404. stopIf: pageIsNot(currentPage),
  5405. timeout: 500,
  5406. })
  5407. if ($tweetEngagements) {
  5408. tweetInteractionsTab = $link.dataset.tab || null
  5409. $tweetEngagements.click()
  5410. } else {
  5411. warn('falling back to full page refresh')
  5412. location.href = $link.href
  5413. }
  5414. })
  5415. })
  5416. }
  5417.  
  5418. /**
  5419. * Sets the page name in <title>, retaining any current notification count.
  5420. * @param {string} page
  5421. */
  5422. function setTitle(page) {
  5423. let name = config.replaceLogo ? getString('TWITTER') : 'X'
  5424. document.title = ltr ? (
  5425. `${currentNotificationCount}${page} / ${name}`
  5426. ) : (
  5427. `${currentNotificationCount}${name} \\ ${page}`
  5428. )
  5429. }
  5430.  
  5431. /**
  5432. * @param {import("./types").TimelineItemType} type
  5433. * @returns {boolean}
  5434. */
  5435. function shouldHideIndividualTweetTimelineItem(type) {
  5436. switch (type) {
  5437. case 'QUOTE_TWEET':
  5438. case 'RETWEET':
  5439. case 'RETWEETED_QUOTE_TWEET':
  5440. case 'TWEET':
  5441. return false
  5442. case 'UNAVAILABLE_QUOTE_TWEET':
  5443. case 'UNAVAILABLE_RETWEET':
  5444. return config.hideUnavailableQuoteTweets
  5445. default:
  5446. return true
  5447. }
  5448. }
  5449.  
  5450. /**
  5451. * @param {import("./types").TimelineItemType} type
  5452. * @returns {boolean}
  5453. */
  5454. function shouldHideListTimelineItem(type) {
  5455. switch (type) {
  5456. case 'RETWEET':
  5457. case 'RETWEETED_QUOTE_TWEET':
  5458. return config.listRetweets == 'hide'
  5459. case 'UNAVAILABLE_QUOTE_TWEET':
  5460. return config.hideUnavailableQuoteTweets
  5461. case 'UNAVAILABLE_RETWEET':
  5462. return config.hideUnavailableQuoteTweets || config.listRetweets == 'hide'
  5463. default:
  5464. return false
  5465. }
  5466. }
  5467.  
  5468. /**
  5469. * @param {import("./types").TimelineItemType} type
  5470. * @param {string} page
  5471. * @returns {boolean}
  5472. */
  5473. function shouldHideHomeTimelineItem(type, page) {
  5474. switch (type) {
  5475. case 'QUOTE_TWEET':
  5476. return shouldHideSharedTweet(config.quoteTweets, page)
  5477. case 'RETWEET':
  5478. return selectedHomeTabIndex >= 2 ? config.listRetweets == 'hide' : shouldHideSharedTweet(config.retweets, page)
  5479. case 'RETWEETED_QUOTE_TWEET':
  5480. return selectedHomeTabIndex >= 2 ? (
  5481. config.listRetweets == 'hide'
  5482. ) : (
  5483. shouldHideSharedTweet(config.retweets, page) || shouldHideSharedTweet(config.quoteTweets, page)
  5484. )
  5485. case 'TWEET':
  5486. return page == separatedTweetsTimelineTitle
  5487. case 'UNAVAILABLE_QUOTE_TWEET':
  5488. return config.hideUnavailableQuoteTweets || shouldHideSharedTweet(config.quoteTweets, page)
  5489. case 'UNAVAILABLE_RETWEET':
  5490. return config.hideUnavailableQuoteTweets || selectedHomeTabIndex >= 2 ? config.listRetweets == 'hide' : shouldHideSharedTweet(config.retweets, page)
  5491. default:
  5492. return true
  5493. }
  5494. }
  5495.  
  5496. /**
  5497. * @param {import("./types").TimelineItemType} type
  5498. * @returns {boolean}
  5499. */
  5500. function shouldHideProfileTimelineItem(type) {
  5501. switch (type) {
  5502. case 'PINNED_TWEET':
  5503. case 'QUOTE_TWEET':
  5504. case 'TWEET':
  5505. return false
  5506. case 'RETWEET':
  5507. case 'RETWEETED_QUOTE_TWEET':
  5508. return config.hideProfileRetweets
  5509. case 'UNAVAILABLE_QUOTE_TWEET':
  5510. return config.hideUnavailableQuoteTweets
  5511. default:
  5512. return true
  5513. }
  5514. }
  5515.  
  5516. /**
  5517. * @param {import("./types").TimelineItemType} type
  5518. * @returns {boolean}
  5519. */
  5520. function shouldHideOtherTimelineItem(type) {
  5521. switch (type) {
  5522. case 'QUOTE_TWEET':
  5523. case 'RETWEET':
  5524. case 'RETWEETED_QUOTE_TWEET':
  5525. case 'TWEET':
  5526. case 'UNAVAILABLE':
  5527. case 'UNAVAILABLE_QUOTE_TWEET':
  5528. case 'UNAVAILABLE_RETWEET':
  5529. return false
  5530. default:
  5531. return true
  5532. }
  5533. }
  5534.  
  5535. /**
  5536. * @param {import("./types").SharedTweetsConfig} config
  5537. * @param {string} page
  5538. * @returns {boolean}
  5539. */
  5540. function shouldHideSharedTweet(config, page) {
  5541. switch (config) {
  5542. case 'hide': return true
  5543. case 'ignore': return page == separatedTweetsTimelineTitle
  5544. case 'separate': return page != separatedTweetsTimelineTitle
  5545. }
  5546. }
  5547.  
  5548. async function tweakBookmarksPage() {
  5549. if (config.twitterBlueChecks != 'ignore' || config.restoreLinkHeadlines) {
  5550. observeTimeline(currentPage)
  5551. }
  5552. }
  5553.  
  5554. async function tweakExplorePage() {
  5555. if (!config.hideExplorePageContents) return
  5556.  
  5557. let $searchInput = await getElement('input[data-testid="SearchBox_Search_Input"]', {
  5558. name: 'explore page search input',
  5559. stopIf: () => !isOnExplorePage(),
  5560. })
  5561. if (!$searchInput) return
  5562.  
  5563. log('focusing search input')
  5564. $searchInput.focus()
  5565.  
  5566. if (mobile) {
  5567. // The back button appears after the search input is focused on mobile. When
  5568. // you tap it or otherwise navigate back, it's replaced with the slide-out
  5569. // menu button and Explore page contents are shown - we want to skip that.
  5570. let $backButton = await getElement('div[data-testid="app-bar-back"]', {
  5571. name: 'back button',
  5572. stopIf: () => !isOnExplorePage(),
  5573. })
  5574. if (!$backButton) return
  5575.  
  5576. pageObservers.push(
  5577. observeElement($backButton.parentElement, (mutations) => {
  5578. mutations.forEach((mutation) => {
  5579. mutation.addedNodes.forEach((/** @type {HTMLElement} */ $el) => {
  5580. if ($el.querySelector('[data-testid="DashButton_ProfileIcon_Link"]')) {
  5581. log('slide-out menu button appeared, going back to skip Explore page')
  5582. history.go(-2)
  5583. }
  5584. })
  5585. })
  5586. }, 'back button parent')
  5587. )
  5588. }
  5589. }
  5590.  
  5591. function tweakCommunitiesPage() {
  5592. observeTimeline(currentPage)
  5593. }
  5594.  
  5595. function tweakCommunityPage() {
  5596. if (config.twitterBlueChecks != 'ignore') {
  5597. observeTimeline(currentPage, {
  5598. classifyTweets: false,
  5599. isTabbed: true,
  5600. tabbedTimelineContainerSelector: `${Selectors.PRIMARY_COLUMN} > div > div:last-child`,
  5601. onTimelineAppeared() {
  5602. // The About tab has static content at the top which can include a check
  5603. if (/\/about\/?$/.test(location.pathname)) {
  5604. processBlueChecks(document.querySelector(Selectors.PRIMARY_COLUMN))
  5605. }
  5606. }
  5607. })
  5608. }
  5609. }
  5610.  
  5611. function tweakCommunityMembersPage() {
  5612. if (config.twitterBlueChecks != 'ignore') {
  5613. observeTimeline(currentPage, {
  5614. classifyTweets: false,
  5615. isTabbed: true,
  5616. timelineSelector: 'div[data-testid="primaryColumn"] > div > div:last-child',
  5617. })
  5618. }
  5619. }
  5620.  
  5621. function tweakDisplaySettingsPage() {
  5622. (async () => {
  5623. let $colorRerenderBoundary = await getElement('#react-root > div > div')
  5624.  
  5625. pageObservers.push(
  5626. observeElement($colorRerenderBoundary, () => {
  5627. let newThemeColor = getThemeColorFromState()
  5628. if (newThemeColor == themeColor) return
  5629.  
  5630. log('Color setting changed')
  5631. themeColor = newThemeColor
  5632. configureThemeCss()
  5633. observePopups()
  5634. observeSideNavTweetButton()
  5635. }, 'Color change re-render boundary')
  5636. )
  5637. })()
  5638.  
  5639. if (desktop) {
  5640. pageObservers.push(
  5641. observeElement($html, () => {
  5642. if (!$html.style.fontSize) return
  5643.  
  5644. if ($html.style.fontSize != fontSize) {
  5645. fontSize = $html.style.fontSize
  5646. log(`<html> fontSize has changed to ${fontSize}`)
  5647. configureDynamicCss()
  5648. observePopups()
  5649. observeSideNavTweetButton()
  5650. }
  5651. }, '<html> style attribute for font size changes', {
  5652. attributes: true,
  5653. attributeFilter: ['style']
  5654. })
  5655. )
  5656. }
  5657. }
  5658.  
  5659. /**
  5660. * @param {HTMLElement} $focusedTweet
  5661. * @param {import("./types").IndividualTweetTimelineOptions} options
  5662. */
  5663. async function tweakFocusedTweet($focusedTweet, options) {
  5664. let {observers} = options
  5665. if ($focusedTweet) {
  5666. restoreTweetInteractionsLinks($focusedTweet)
  5667.  
  5668. if (desktop && config.replaceLogo && !isObserving(observers, 'tweet editor')) {
  5669. let $editorRoot = await getElement('.DraftEditor-root', {
  5670. context: $focusedTweet.parentElement,
  5671. name: 'tweet editor in focused tweet',
  5672. timeout: 500,
  5673. })
  5674. if ($editorRoot && !isObserving(observers, 'tweet editor')) {
  5675. observers.unshift(
  5676. observeElement($editorRoot, () => {
  5677. if ($editorRoot.firstElementChild.classList.contains('public-DraftEditorPlaceholder-root')) {
  5678. let $placeholder = $editorRoot.querySelector('.public-DraftEditorPlaceholder-inner')
  5679. if ($placeholder) {
  5680. $placeholder.textContent = getString('TWEET_YOUR_REPLY')
  5681. }
  5682. }
  5683. }, 'tweet editor')
  5684. )
  5685. }
  5686. }
  5687. }
  5688. else {
  5689. disconnectObserver('tweet editor', observers)
  5690. }
  5691. }
  5692.  
  5693. async function tweakFollowListPage() {
  5694. // These tabs are dynamic as "Followers you know" only appears when applicable
  5695. let $tabs = await getElement(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav`, {
  5696. name: 'Following tabs',
  5697. stopIf: pageIsNot(currentPage),
  5698. })
  5699. if (!$tabs) return
  5700.  
  5701. let $subscriptionsTabLink = $tabs.querySelector('div[role="tablist"] a[href$="/subscriptions"]')
  5702. if ($subscriptionsTabLink) {
  5703. $body.classList.add('Subscriptions')
  5704. }
  5705.  
  5706. if (config.hideVerifiedNotificationsTab) {
  5707. let isVerifiedTabSelected = Boolean($tabs.querySelector('div[role="tablist"] > div:nth-child(1) > a[aria-selected="true"]'))
  5708. if (isVerifiedTabSelected) {
  5709. log('switching to Following tab')
  5710. $tabs.querySelector(`div[role="tablist"] > div:nth-last-child(${$subscriptionsTabLink ? 3 : 2}) > a`)?.click()
  5711. }
  5712. }
  5713.  
  5714. if (config.twitterBlueChecks != 'ignore') {
  5715. observeTimeline(currentPage, {
  5716. classifyTweets: false,
  5717. })
  5718. }
  5719. }
  5720.  
  5721. async function tweakIndividualTweetPage() {
  5722. observeIndividualTweetTimeline(currentPage)
  5723.  
  5724. if (config.replaceLogo) {
  5725. (async () => {
  5726. let $headingText = await getElement(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} h2 span`, {
  5727. name: 'tweet thread heading',
  5728. stopIf: pageIsNot(currentPage)
  5729. })
  5730. if ($headingText && $headingText.textContent != getString('TWEET')) {
  5731. $headingText.textContent = getString('TWEET')
  5732. }
  5733. })()
  5734. }
  5735.  
  5736. setDefaultSortReplies()
  5737. }
  5738.  
  5739. function tweakListPage() {
  5740. observeTimeline(currentPage, {
  5741. hideHeadings: false,
  5742. })
  5743. }
  5744.  
  5745. async function tweakDesktopLogo() {
  5746. let $logoPath = await getElement(`h1 ${Selectors.X_LOGO_PATH}, h1 ${Selectors.X_DARUMA_LOGO_PATH}`, {
  5747. name: 'desktop nav logo',
  5748. timeout: 5000,
  5749. })
  5750. if ($logoPath) {
  5751. twitterLogo($logoPath)
  5752. }
  5753. }
  5754.  
  5755. async function tweakHomeIcon() {
  5756. let $homeIconPath = await getElement(`${Selectors.NAV_HOME_LINK} svg path`, {name: 'Home icon', stopIf: pageIsNot(currentPage)})
  5757. if ($homeIconPath) {
  5758. homeIcon($homeIconPath)
  5759. }
  5760. }
  5761.  
  5762. async function tweakTweetBox() {
  5763. // Restore "What's happening?" placeholder
  5764. if (config.replaceLogo && !isObserving(pageObservers, 'tweet editor')) {
  5765. let $editorRoot = await getElement(`${desktop ? 'div[data-testid="primaryColumn"]': 'main'} .DraftEditor-root`, {
  5766. name: 'tweet editor',
  5767. stopIf: pageIsNot(currentPage),
  5768. })
  5769. if ($editorRoot && !isObserving(pageObservers, 'tweet editor')) {
  5770. pageObservers.unshift(
  5771. observeElement($editorRoot, () => {
  5772. if ($editorRoot.firstElementChild.classList.contains('public-DraftEditorPlaceholder-root')) {
  5773. let $placeholder = $editorRoot.querySelector('.public-DraftEditorPlaceholder-inner')
  5774. if ($placeholder) {
  5775. $placeholder.textContent = getString('WHATS_HAPPENING')
  5776. }
  5777. }
  5778. }, 'tweet editor')
  5779. )
  5780. }
  5781. }
  5782.  
  5783. // Observe username typeahead dropdowns to replace Blue checks
  5784. if (config.twitterBlueChecks != 'ignore') {
  5785. let $tweetTextarea = await getElement(`${desktop ? 'div[data-testid="primaryColumn"]': 'main'} [data-testid^="tweetTextarea"]`, {
  5786. name: 'tweet textarea',
  5787. stopIf: pageIsNot(currentPage),
  5788. })
  5789. if (!$tweetTextarea) return
  5790.  
  5791. /** @type {HTMLElement} */
  5792. let $typeaheadDropdown
  5793.  
  5794. pageObservers.push(
  5795. observeElement($tweetTextarea.parentElement.parentElement.parentElement.parentElement, (mutations) => {
  5796. for (let mutation of mutations) {
  5797. if ($typeaheadDropdown && mutations.some(mutation => Array.from(mutation.removedNodes).includes($typeaheadDropdown))) {
  5798. disconnectPageObserver('tweet textarea typeahead dropdown')
  5799. $typeaheadDropdown = null
  5800. }
  5801. for (let $addedNode of mutation.addedNodes) {
  5802. if ($addedNode instanceof HTMLElement && $addedNode.getAttribute('id')?.startsWith('typeaheadDropdown')) {
  5803. $typeaheadDropdown = $addedNode
  5804. pageObservers.push(
  5805. observeElement($typeaheadDropdown, () => {
  5806. processBlueChecks($typeaheadDropdown)
  5807. }, 'tweet textarea typeahead dropdown')
  5808. )
  5809. }
  5810. }
  5811. }
  5812. }, 'tweet textarea typeahead dropdown container')
  5813. )
  5814. }
  5815.  
  5816. if (config.replaceLogo) {
  5817. tweakTweetButton()
  5818. }
  5819. }
  5820.  
  5821. async function tweakTweetButton() {
  5822. let $tweetButton = await getElement(`${desktop ? 'div[data-testid="primaryColumn"]': 'main'} button[data-testid^="tweetButton"]`, {
  5823. name: 'tweet button',
  5824. stopIf: pageIsNot(currentPage),
  5825. })
  5826. if ($tweetButton) {
  5827. let $text = $tweetButton.querySelector('span > span')
  5828. if ($text) {
  5829. setTweetButtonText($text)
  5830. } else {
  5831. warn('could not find tweet button text')
  5832. }
  5833. }
  5834. }
  5835.  
  5836. function tweakHomeTimelinePage() {
  5837. if (desktop) {
  5838. tweakTweetBox()
  5839. }
  5840.  
  5841. let $timelineTabs = document.querySelector(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav`)
  5842.  
  5843. // Hook for styling when on the separated tweets tab
  5844. $body.classList.toggle('SeparatedTweets', isOnSeparatedTweetsTimeline())
  5845.  
  5846. if ($timelineTabs == null) {
  5847. warn('could not find timeline tabs')
  5848. return
  5849. }
  5850.  
  5851. tweakTimelineTabs($timelineTabs)
  5852. if (mobile && isSafari && config.replaceLogo) {
  5853. processTwitterLogos(document.querySelector(Selectors.MOBILE_TIMELINE_HEADER))
  5854. }
  5855.  
  5856. function updateSelectedHomeTabIndex() {
  5857. let $selectedHomeTabLink = $timelineTabs.querySelector('div[role="tablist"] a[aria-selected="true"]')
  5858. if ($selectedHomeTabLink) {
  5859. selectedHomeTabIndex = Array.from($selectedHomeTabLink.parentElement.parentElement.children).indexOf($selectedHomeTabLink.parentElement)
  5860. log({selectedHomeTabIndex})
  5861. } else {
  5862. warn('could not find selected Home tab link')
  5863. selectedHomeTabIndex = -1
  5864. }
  5865. }
  5866.  
  5867. updateSelectedHomeTabIndex()
  5868.  
  5869. // If there are pinned lists, the timeline tabs <nav> will be replaced when they load
  5870. pageObservers.push(
  5871. observeElement($timelineTabs.parentElement, (mutations) => {
  5872. let timelineTabsReplaced = mutations.some(mutation => Array.from(mutation.removedNodes).includes($timelineTabs))
  5873. if (timelineTabsReplaced) {
  5874. log('timeline tabs replaced')
  5875. $timelineTabs = document.querySelector(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav`)
  5876. tweakTimelineTabs($timelineTabs)
  5877. }
  5878. }, 'timeline tabs nav container')
  5879. )
  5880.  
  5881. observeTimeline(currentPage, {
  5882. isTabbed: true,
  5883. onTabChanged: () => {
  5884. updateSelectedHomeTabIndex()
  5885. wasForYouTabSelected = selectedHomeTabIndex == 0
  5886. },
  5887. tabbedTimelineContainerSelector: 'div[data-testid="primaryColumn"] > div > div:last-child',
  5888. })
  5889. }
  5890.  
  5891. function tweakMobileComposeTweetPage() {
  5892. tweakTweetBox()
  5893. }
  5894.  
  5895. function tweakMobileMediaViewerPage() {
  5896. if (config.twitterBlueChecks == 'ignore') return
  5897.  
  5898. let $timeline = /** @type {HTMLElement} */ (document.querySelector('[data-testid="vss-scroll-view"] > div'))
  5899. if (!$timeline) {
  5900. warn('media viewer timeline not found')
  5901. return
  5902. }
  5903.  
  5904. observeElement($timeline, (mutations) => {
  5905. for (let mutation of mutations) {
  5906. if (!mutation.addedNodes) continue
  5907. for (let $addedNode of mutation.addedNodes) {
  5908. if ($addedNode.querySelector?.('div[data-testid^="immersive-tweet-ui-content-container"]')) {
  5909. processBlueChecks($addedNode)
  5910. }
  5911. }
  5912. }
  5913. }, 'media viewer timeline', {childList: true, subtree: true})
  5914. }
  5915.  
  5916. async function tweakTimelineTabs($timelineTabs) {
  5917. $timelineTabs.classList.add('TimelineTabs')
  5918. let $followingTabLink = /** @type {HTMLElement} */ ($timelineTabs.querySelector('div[role="tablist"] > div:nth-child(2) > a'))
  5919.  
  5920. if (config.alwaysUseLatestTweets && !document.title.startsWith(separatedTweetsTimelineTitle)) {
  5921. let isForYouTabSelected = Boolean($timelineTabs.querySelector('div[role="tablist"] > div:first-child > a[aria-selected="true"]'))
  5922. if (isForYouTabSelected && (!wasForYouTabSelected || config.hideForYouTimeline)) {
  5923. log('switching to Following timeline')
  5924. $followingTabLink.click()
  5925. wasForYouTabSelected = false
  5926. } else {
  5927. wasForYouTabSelected = isForYouTabSelected
  5928. }
  5929. }
  5930.  
  5931. if (shouldShowSeparatedTweetsTab()) {
  5932. let $newTab = /** @type {HTMLElement} */ ($timelineTabs.querySelector('#tnt_separated_tweets_tab'))
  5933. if ($newTab) {
  5934. log('separated tweets timeline tab already present')
  5935. $newTab.querySelector('span').textContent = separatedTweetsTimelineTitle
  5936. }
  5937. else {
  5938. log('inserting separated tweets tab')
  5939. $newTab = /** @type {HTMLElement} */ ($followingTabLink.parentElement.cloneNode(true))
  5940. $newTab.id = 'tnt_separated_tweets_tab'
  5941. $newTab.querySelector('span').textContent = separatedTweetsTimelineTitle
  5942. let $link = $newTab.querySelector('a')
  5943. $link.removeAttribute('aria-selected')
  5944.  
  5945. // This script assumes navigation has occurred when the document title
  5946. // changes, so by changing the title we fake navigation to a non-existent
  5947. // page representing the separated tweets timeline.
  5948. $link.addEventListener('click', (e) => {
  5949. e.preventDefault()
  5950. e.stopPropagation()
  5951. if (!document.title.startsWith(separatedTweetsTimelineTitle)) {
  5952. // The separated tweets tab belongs to the Following tab
  5953. let isFollowingTabSelected = Boolean($timelineTabs.querySelector('div[role="tablist"] > div:nth-child(2) > a[aria-selected="true"]'))
  5954. if (!isFollowingTabSelected) {
  5955. log('switching to the Following tab for separated tweets')
  5956. $followingTabLink.click()
  5957. }
  5958. setTitle(separatedTweetsTimelineTitle)
  5959. }
  5960. window.scrollTo({top: 0})
  5961. })
  5962. $followingTabLink.parentElement.insertAdjacentElement('afterend', $newTab)
  5963.  
  5964. // Return to the Home timeline when any other tab is clicked
  5965. $followingTabLink.parentElement.parentElement.addEventListener('click', () => {
  5966. if (location.pathname == '/home' && !document.title.startsWith(getString('HOME'))) {
  5967. log('setting title to Home')
  5968. homeNavigationIsBeingUsed = true
  5969. setTitle(getString('HOME'))
  5970. }
  5971. })
  5972.  
  5973. // Return to the Home timeline when the Home nav link is clicked
  5974. let $homeNavLink = await getElement(Selectors.NAV_HOME_LINK, {
  5975. name: 'home nav link',
  5976. stopIf: pathIsNot(currentPath),
  5977. })
  5978. if ($homeNavLink && !$homeNavLink.dataset.tweakNewTwitterListener) {
  5979. $homeNavLink.addEventListener('click', () => {
  5980. homeNavigationIsBeingUsed = true
  5981. if (location.pathname == '/home' && !document.title.startsWith(getString('HOME'))) {
  5982. setTitle(getString('HOME'))
  5983. }
  5984. })
  5985. $homeNavLink.dataset.tweakNewTwitterListener = 'true'
  5986. }
  5987. }
  5988. } else {
  5989. removeMobileTimelineHeaderElements()
  5990. }
  5991. }
  5992.  
  5993. function tweakNotificationsPage() {
  5994. let $navigationTabs = document.querySelector(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav`)
  5995. if ($navigationTabs == null) {
  5996. warn('could not find Notifications tabs')
  5997. return
  5998. }
  5999.  
  6000. if (config.hideVerifiedNotificationsTab) {
  6001. let isVerifiedTabSelected = Boolean($navigationTabs.querySelector('div[role="tablist"] > div:nth-child(2) > a[aria-selected="true"]'))
  6002. if (isVerifiedTabSelected) {
  6003. log('switching to All tab')
  6004. $navigationTabs.querySelector('div[role="tablist"] > div:nth-child(1) > a')?.click()
  6005. }
  6006. }
  6007.  
  6008. if (config.twitterBlueChecks != 'ignore' || config.restoreLinkHeadlines) {
  6009. observeTimeline(currentPage, {
  6010. isTabbed: true,
  6011. tabbedTimelineContainerSelector: 'div[data-testid="primaryColumn"] > div > div:last-child',
  6012. })
  6013. }
  6014. }
  6015.  
  6016. async function tweakProfilePage() {
  6017. let $initialContent = await getElement(desktop ? Selectors.PRIMARY_COLUMN : Selectors.MOBILE_TIMELINE_HEADER, {
  6018. name: 'initial profile content',
  6019. stopIf: pageIsNot(currentPage),
  6020. })
  6021. if (!$initialContent) return
  6022.  
  6023. if (config.twitterBlueChecks != 'ignore') {
  6024. processBlueChecks($initialContent)
  6025. }
  6026.  
  6027. let tab = currentPath.match(URL_PROFILE_RE)?.[2] || 'tweets'
  6028. log(`on ${tab} tab`)
  6029. observeTimeline(currentPage, {
  6030. isUserTimeline: tab == 'affiliates'
  6031. })
  6032.  
  6033. getElement('a[href="/settings/profile"]', {
  6034. name: 'edit profile button',
  6035. stopIf: pageIsNot(currentPage),
  6036. timeout: 500,
  6037. }).then($editProfileButton => {
  6038. $body.classList.toggle('OwnProfile', Boolean($editProfileButton))
  6039. })
  6040. let $headerVerifiedIcon = document.querySelector(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.TIMELINE_HEADING} [data-testid="icon-verified"]`)
  6041. $body.classList.toggle('PremiumProfile', Boolean($headerVerifiedIcon))
  6042.  
  6043. if (config.replaceLogo || config.hideSubscriptions) {
  6044. let $profileTabs = await getElement(`${Selectors.PRIMARY_COLUMN} nav`, {
  6045. name: 'profile tabs',
  6046. stopIf: pageIsNot(currentPage),
  6047. })
  6048. if (!$profileTabs) return
  6049. // The Profile tabs <nav> can be replaced
  6050. pageObservers.push(
  6051. observeElement($profileTabs.parentElement, async (mutations) => {
  6052. if (mutations.length > 0) {
  6053. let $newProfileTabs = findAddedNode(mutations, ($el) => $el instanceof HTMLElement && $el.tagName == 'NAV')
  6054. if ($newProfileTabs == null) return
  6055. $profileTabs = /** @type {HTMLElement} */ ($newProfileTabs)
  6056. }
  6057. if (config.replaceLogo) {
  6058. let $tweetsTabText = await getElement('[data-testid="ScrollSnap-List"] > [role="presentation"]:first-child div[dir] > span:first-child', {
  6059. context: $profileTabs,
  6060. name: 'Tweets tab text',
  6061. stopIf: pageIsNot(currentPage),
  6062. })
  6063. if ($tweetsTabText && $tweetsTabText.textContent != getString('TWEETS')) {
  6064. $tweetsTabText.textContent = getString('TWEETS')
  6065. }
  6066. }
  6067. if (config.hideSubscriptions) {
  6068. let $subscriptionsTabLink = await getElement('a[href$="/superfollows"]', {
  6069. context: $profileTabs,
  6070. name: 'Subscriptions tab link',
  6071. stopIf: pageIsNot(currentPage),
  6072. timeout: 1000,
  6073. })
  6074. if ($subscriptionsTabLink) {
  6075. $subscriptionsTabLink.parentElement.classList.add('SubsTab')
  6076. }
  6077. }
  6078. }, 'profile tabs', {childList: true})
  6079. )
  6080. }
  6081. }
  6082.  
  6083. /**
  6084. * @param {Element} $dropdownItem
  6085. * @param {string} dropdownItemSelector
  6086. * @param {import("./types").LocaleKey} localeKey
  6087. */
  6088. async function tweakRetweetDropdown($dropdownItem, dropdownItemSelector, localeKey) {
  6089. log('tweaking Retweet/Quote Tweet dropdown')
  6090.  
  6091. if (desktop) {
  6092. $dropdownItem = await getElement(`
  6093. #layers div[data-testid="Dropdown"] ${dropdownItemSelector}
  6094. `, {
  6095. name: 'rendered menu item',
  6096. timeout: 100,
  6097. })
  6098. if (!$dropdownItem) return
  6099. }
  6100.  
  6101. let $text = $dropdownItem.querySelector('div[dir] > span')
  6102. if ($text) $text.textContent = getString(localeKey)
  6103.  
  6104. let $quoteTweetText = $dropdownItem.nextElementSibling?.querySelector('div[dir] > span')
  6105. if ($quoteTweetText) $quoteTweetText.textContent = getString('QUOTE_TWEET')
  6106. }
  6107.  
  6108. function tweakSearchPage() {
  6109. let $searchTabs = document.querySelector(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav`)
  6110. if ($searchTabs != null) {
  6111. if (config.defaultToLatestSearch) {
  6112. let isTopTabSelected = Boolean($searchTabs.querySelector('div[role="tablist"] > div:nth-child(1) > a[aria-selected="true"]'))
  6113. if (isTopTabSelected) {
  6114. log('switching to Latest tab')
  6115. $searchTabs.querySelector('div[role="tablist"] > div:nth-child(2) > a')?.click()
  6116. }
  6117. }
  6118. } else {
  6119. warn('could not find Search tabs')
  6120. }
  6121.  
  6122. observeTimeline(currentPage, {
  6123. hideHeadings: false,
  6124. isTabbed: true,
  6125. tabbedTimelineContainerSelector: 'div[data-testid="primaryColumn"] > div > div:last-child',
  6126. })
  6127. }
  6128.  
  6129. function tweakTweetEngagementPage() {
  6130. if (config.replaceLogo) {
  6131. let $headingText = document.querySelector(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} h2 span`)
  6132. if ($headingText) {
  6133. if ($headingText.textContent != getString('TWEET_INTERACTIONS')) {
  6134. $headingText.textContent = getString('TWEET_INTERACTIONS')
  6135. }
  6136. } else {
  6137. warn('could not find Post engagement heading')
  6138. }
  6139. }
  6140.  
  6141. let $tabs = document.querySelector(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav`)
  6142. if ($tabs == null) {
  6143. warn('could not find Post engagement tabs')
  6144. return
  6145. }
  6146.  
  6147. if (tweetInteractionsTab) {
  6148. log('switching to tab', tweetInteractionsTab)
  6149. $tabs.querySelector(`div[role="tablist"] > div:nth-child(${tweetInteractionsTab}) > a`)?.click()
  6150. tweetInteractionsTab = null
  6151. }
  6152.  
  6153. if (config.replaceLogo) {
  6154. let $quoteTweetsTabText = $tabs.querySelector('div[role="tablist"] > div:nth-child(1) div[dir] > span')
  6155. if ($quoteTweetsTabText) $quoteTweetsTabText.textContent = getString('QUOTE_TWEETS')
  6156. let $retweetsTabText = $tabs.querySelector('div[role="tablist"] > div:nth-child(2) div[dir] > span')
  6157. if ($retweetsTabText) $retweetsTabText.textContent = getString('RETWEETS')
  6158. }
  6159.  
  6160. if (config.twitterBlueChecks != 'ignore') {
  6161. observeTimeline(currentPage, {classifyTweets: false})
  6162. }
  6163. }
  6164. //#endregion
  6165.  
  6166. //#region Main
  6167. async function main() {
  6168. let $settings = /** @type {HTMLScriptElement} */ (document.querySelector('script#tnt_settings'))
  6169. if ($settings) {
  6170. try {
  6171. Object.assign(config, JSON.parse($settings.innerText))
  6172. } catch(e) {
  6173. error('error parsing initial settings', e)
  6174. }
  6175.  
  6176. let settingsChangeObserver = new MutationObserver(() => {
  6177. /** @type {Partial<import("./types").Config>} */
  6178. let configChanges
  6179. try {
  6180. configChanges = JSON.parse($settings.innerText)
  6181. } catch(e) {
  6182. error('error parsing incoming settings change', e)
  6183. return
  6184. }
  6185.  
  6186. if ('debug' in configChanges) {
  6187. log('disabling debug mode')
  6188. debug = configChanges.debug
  6189. log('enabled debug mode')
  6190. configureThemeCss()
  6191. return
  6192. }
  6193.  
  6194. Object.assign(config, configChanges)
  6195. configChanged(configChanges)
  6196. })
  6197. settingsChangeObserver.observe($settings, {childList: true})
  6198. }
  6199.  
  6200. if (config.debug) {
  6201. debug = true
  6202. }
  6203.  
  6204. observeTitle()
  6205.  
  6206. let $loadingStyle
  6207. if (config.replaceLogo) {
  6208. getElement('html', {name: 'html element'}).then(($html) => {
  6209. $loadingStyle = document.createElement('style')
  6210. $loadingStyle.dataset.insertedBy = 'control-panel-for-twitter'
  6211. $loadingStyle.dataset.role = 'loading-logo'
  6212. $loadingStyle.textContent = dedent(`
  6213. ${Selectors.X_LOGO_PATH} {
  6214. fill: ${isSafari ? 'transparent' : THEME_BLUE};
  6215. d: path("${Svgs.TWITTER_LOGO_PATH}");
  6216. }
  6217. .tnt_logo {
  6218. fill: ${THEME_BLUE};
  6219. }
  6220. `)
  6221. $html.appendChild($loadingStyle)
  6222. })
  6223.  
  6224. if (isSafari) {
  6225. getElement(Selectors.X_LOGO_PATH, {name: 'pre-loading indicator logo', timeout: 1000}).then(($logoPath) => {
  6226. if ($logoPath) {
  6227. twitterLogo($logoPath)
  6228. }
  6229. })
  6230. }
  6231.  
  6232. observeFavicon()
  6233. }
  6234.  
  6235. let $appWrapper = await getElement('#layers + div', {name: 'app wrapper'})
  6236.  
  6237. $html = document.querySelector('html')
  6238. $body = document.body
  6239. $reactRoot = document.querySelector('#react-root')
  6240. lang = $html.lang
  6241. dir = $html.dir
  6242. ltr = dir == 'ltr'
  6243. let lastFlexDirection
  6244.  
  6245. observeElement($appWrapper, () => {
  6246. let flexDirection = getComputedStyle($appWrapper).flexDirection
  6247.  
  6248. mobile = flexDirection == 'column'
  6249. desktop = !mobile
  6250.  
  6251. /** @type {'mobile' | 'desktop'} */
  6252. let version = mobile ? 'mobile' : 'desktop'
  6253.  
  6254. if (version != config.version) {
  6255. log('setting version to', version)
  6256. config.version = version
  6257. // Let the options page know which version is being used
  6258. storeConfigChanges({version})
  6259. }
  6260.  
  6261. if (lastFlexDirection == null) {
  6262. log('initial config', {config, lang, version})
  6263.  
  6264. // One-time setup
  6265. checkReactNativeStylesheet()
  6266. observeBodyBackgroundColor()
  6267. let initialThemeColor = getThemeColorFromState()
  6268. if (initialThemeColor) {
  6269. themeColor = initialThemeColor
  6270. }
  6271. if (desktop) {
  6272. fontSize = $html.style.fontSize
  6273. if (!fontSize) {
  6274. warn('initial fontSize not set on <html>')
  6275. }
  6276. }
  6277.  
  6278. // Repeatable configuration setup
  6279. configureSeparatedTweetsTimelineTitle()
  6280. configureCss()
  6281. configureDynamicCss()
  6282. configureThemeCss()
  6283. observePopups()
  6284. observeSideNavTweetButton()
  6285.  
  6286. // Start taking action on page changes
  6287. observingPageChanges = true
  6288.  
  6289. // Delay removing loading icon styles to avoid Flash of X
  6290. if ($loadingStyle) {
  6291. setTimeout(() => $loadingStyle.remove(), 1000)
  6292. }
  6293. }
  6294. else if (flexDirection != lastFlexDirection) {
  6295. configChanged({version})
  6296. }
  6297.  
  6298. $body.classList.toggle('Mobile', mobile)
  6299. $body.classList.toggle('Desktop', desktop)
  6300.  
  6301. lastFlexDirection = flexDirection
  6302. }, 'app wrapper class attribute for version changes (mobile ↔ desktop)', {
  6303. attributes: true,
  6304. attributeFilter: ['class']
  6305. })
  6306. }
  6307.  
  6308. /**
  6309. * @param {Partial<import("./types").Config>} changes
  6310. */
  6311. function configChanged(changes) {
  6312. log('config changed', changes)
  6313.  
  6314. if ('version' in changes) {
  6315. fontSize = desktop ? $html.style.fontSize : null
  6316. }
  6317.  
  6318. configureCss()
  6319. configureFont()
  6320. configureDynamicCss()
  6321. configureThemeCss()
  6322. observeFavicon()
  6323. observePopups()
  6324. observeSideNavTweetButton()
  6325.  
  6326. // Only re-process the current page if navigation wasn't already triggered
  6327. // while applying the following config changes (if there were any).
  6328. let navigationTriggered = (
  6329. configureSeparatedTweetsTimelineTitle() ||
  6330. checkforDisabledHomeTimeline()
  6331. )
  6332. if (!navigationTriggered) {
  6333. processCurrentPage()
  6334. }
  6335. }
  6336.  
  6337. main()
  6338. //#endregion
  6339.  
  6340. }()