Control Panel for Twitter

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

当前为 2024-12-24 提交的版本,查看 最新版本

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