Control Panel for Twitter

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

当前为 2025-02-18 提交的版本,查看 最新版本

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