Control Panel for Twitter

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

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

  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 168
  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. ADD_MUTED_WORD: '/settings/add_muted_keyword',
  1681. BOOKMARKS: '/i/bookmarks',
  1682. COMPOSE_MESSAGE: '/messages/compose',
  1683. COMPOSE_TWEET: '/compose/post',
  1684. CONNECT: '/i/connect',
  1685. DISPLAY_SETTINGS: '/settings/display',
  1686. HOME: '/home',
  1687. NOTIFICATION_TIMELINE: '/i/timeline',
  1688. PROFILE_SETTINGS: '/settings/profile',
  1689. SEARCH: '/search',
  1690. TIMELINE_SETTINGS: '/home/pinned/edit',
  1691. }
  1692.  
  1693. /** @enum {string} */
  1694. const Selectors = {
  1695. BLOCK_MENU_ITEM: '[data-testid="block"]',
  1696. DESKTOP_TIMELINE_HEADER: 'div[data-testid="primaryColumn"] > div > div:first-of-type',
  1697. DISPLAY_DONE_BUTTON_DESKTOP: '#layers button[role="button"]:not([aria-label])',
  1698. DISPLAY_DONE_BUTTON_MOBILE: 'main button[role="button"]:not([aria-label])',
  1699. MESSAGES_DRAWER: 'div[data-testid="DMDrawer"]',
  1700. MODAL_TIMELINE: 'section > h1 + div[aria-label] > div',
  1701. MOBILE_TIMELINE_HEADER: 'div[data-testid="TopNavBar"]',
  1702. NAV_HOME_LINK: 'a[data-testid="AppTabBar_Home_Link"]',
  1703. PRIMARY_COLUMN: 'div[data-testid="primaryColumn"]',
  1704. PRIMARY_NAV_DESKTOP: 'header nav',
  1705. PRIMARY_NAV_MOBILE: '#layers nav',
  1706. PROMOTED_TWEET_CONTAINER: '[data-testid="placementTracking"]',
  1707. SIDEBAR: 'div[data-testid="sidebarColumn"]',
  1708. SIDEBAR_WRAPPERS: 'div[data-testid="sidebarColumn"] > div > div > div > div > div',
  1709. SORT_REPLIES_PATH: 'svg path[d="M14 6V3h2v8h-2V8H3V6h11zm7 2h-3.5V6H21v2zM8 16v-3h2v8H8v-3H3v-2h5zm13 2h-9.5v-2H21v2z"]',
  1710. TIMELINE: 'div[data-testid="primaryColumn"] section > h1 + div[aria-label] > div',
  1711. TIMELINE_HEADING: 'h2[role="heading"]',
  1712. TWEET: '[data-testid="tweet"]',
  1713. VERIFIED_TICK: 'svg[data-testid="icon-verified"]',
  1714. 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"]',
  1715. }
  1716.  
  1717. /** @enum {string} */
  1718. const Svgs = {
  1719. 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',
  1720. 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>',
  1721. 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>',
  1722. 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>',
  1723. 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',
  1724. 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',
  1725. 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',
  1726. 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',
  1727. 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',
  1728. }
  1729.  
  1730. /** @enum {string} */
  1731. const Images = {
  1732. 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',
  1733. 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==',
  1734. }
  1735.  
  1736. const THEME_BLUE = 'rgb(29, 155, 240)'
  1737. const THEME_COLORS = new Map([
  1738. ['blue500', THEME_BLUE],
  1739. ['yellow500', 'rgb(255, 212, 0)'],
  1740. ['magenta500', 'rgb(249, 24, 128)'],
  1741. ['purple500', 'rgb(120, 86, 255)'],
  1742. ['orange500', 'rgb(255, 122, 0)'],
  1743. ['green500', 'rgb(0, 186, 124)'],
  1744. ])
  1745. // <body> pseudo-selector for pages the full-width content feature works on
  1746. const FULL_WIDTH_BODY_PSEUDO = ':is(.Community, .List, .HomeTimeline)'
  1747. // Matches any notification count at the start of the title
  1748. const TITLE_NOTIFICATION_RE = /^\(\d+\+?\) /
  1749. // The Communities nav item takes you to /yourusername/communities
  1750. const URL_COMMUNITIES_RE = /^\/[a-zA-Z\d_]{1,20}\/communities\/?$/
  1751. const URL_COMMUNITY_RE = /^\/i\/communities\/\d+(?:\/about)?\/?$/
  1752. const URL_COMMUNITY_MEMBERS_RE = /^\/i\/communities\/\d+\/(?:members|moderators)\/?$/
  1753. const URL_DISCOVER_COMMUNITIES_RE = /^\/i\/communities\/suggested\/?/
  1754. const URL_LIST_RE = /\/i\/lists\/\d+\/?$/
  1755. const URL_MEDIA_RE = /\/(?:photo|video)\/\d\/?$/
  1756. const URL_MEDIAVIEWER_RE = /^\/[a-zA-Z\d_]{1,20}\/status\/\d+\/mediaviewer$/i
  1757. // Matches URLs which show one of the tabs on a user profile page
  1758. const URL_PROFILE_RE = /^\/([a-zA-Z\d_]{1,20})(?:\/(affiliates|with_replies|superfollows|highlights|articles|media|likes))?\/?$/
  1759. // Matches URLs which show a user's Followers you know / Followers / Following tab
  1760. const URL_PROFILE_FOLLOWS_RE = /^\/[a-zA-Z\d_]{1,20}\/(?:verified_followers|follow(?:ing|ers|ers_you_follow)|creator-subscriptions\/subscriptions)\/?$/
  1761. const URL_TWEET_RE = /^\/([a-zA-Z\d_]{1,20})\/status\/(\d+)\/?$/
  1762. const URL_TWEET_ENGAGEMENT_RE = /^\/[a-zA-Z\d_]{1,20}\/status\/\d+\/(quotes|retweets|reposts|likes)\/?$/
  1763.  
  1764. // The Twitter Media Assist exension adds a new button at the end of the action
  1765. // bar (#346)
  1766. const TWITTER_MEDIA_ASSIST_BUTTON_SELECTOR = '.tva-download-icon, .tva-modal-download-icon'
  1767. //#endregion
  1768.  
  1769. //#region Variables
  1770. /**
  1771. * The quoted Tweet associated with a caret menu that's just been opened.
  1772. * @type {import("./types").QuotedTweet}
  1773. */
  1774. let quotedTweet = null
  1775.  
  1776. /** `true` when a 'Block @${user}' menu item was seen in the last popup. */
  1777. let blockMenuItemSeen = false
  1778.  
  1779. /** `true` if we're opening the Sort replies menu to change settings. */
  1780. let changingSortReplies = false
  1781.  
  1782. /** Notification count in the title (including trailing space), e.g. `'(1) '`. */
  1783. let currentNotificationCount = ''
  1784.  
  1785. /** Title of the current page, without the `' / Twitter'` suffix. */
  1786. let currentPage = ''
  1787.  
  1788. /** Current `location.pathname`. */
  1789. let currentPath = ''
  1790.  
  1791. /**
  1792. * React Native stylesheet rule for the blur filter for sensitive content.
  1793. * @type {CSSStyleRule}
  1794. */
  1795. let filterBlurRule = null
  1796.  
  1797. /**
  1798. * React Native stylesheett rule for the Chirp font-family.
  1799. * @type {CSSStyleRule}
  1800. */
  1801. let fontFamilyRule = null
  1802.  
  1803. /** @type {string} */
  1804. let fontSize = null
  1805.  
  1806. /** Set to `true` when a Home/Following heading or Home nav link is used. */
  1807. let homeNavigationIsBeingUsed = false
  1808.  
  1809. /** Set to `true` when the media modal is open on desktop. */
  1810. let isDesktopMediaModalOpen = false
  1811.  
  1812. /** Set to `true` when the compose tweet modal is open on desktop. */
  1813. let isDesktopComposeTweetModalOpen = false
  1814.  
  1815. /**
  1816. * Cache for the last page title which was used for the Home timeline.
  1817. * @type {string}
  1818. */
  1819. let lastHomeTimelineTitle = null
  1820.  
  1821. /**
  1822. * MutationObservers active on the current modal.
  1823. * @type {import("./types").Disconnectable[]}
  1824. */
  1825. let modalObservers = []
  1826.  
  1827. /**
  1828. * `true` after the app has initialised.
  1829. * @type {boolean}
  1830. */
  1831. let observingPageChanges = false
  1832.  
  1833. /**
  1834. * MutationObservers active on the current page, or anything else we want to
  1835. * clean up when the user moves off the current page.
  1836. * @type {import("./types").NamedMutationObserver[]}
  1837. */
  1838. let pageObservers = []
  1839.  
  1840. /** `true` when a 'Pin to your profile' menu item was seen in the last popup. */
  1841. let pinMenuItemSeen = false
  1842.  
  1843. /** @type {number} */
  1844. let selectedHomeTabIndex = -1
  1845.  
  1846. /**
  1847. * Title for the fake timeline used to separate out retweets and quote tweets.
  1848. * @type {string}
  1849. */
  1850. let separatedTweetsTimelineTitle = null
  1851.  
  1852. /**
  1853. * The current "Color" setting.
  1854. * @type {string}
  1855. */
  1856. let themeColor = THEME_BLUE
  1857.  
  1858. /**
  1859. * Tab to switch to after navigating to the Tweet interactions page.
  1860. * @type {string}
  1861. */
  1862. let tweetInteractionsTab = null
  1863.  
  1864. /**
  1865. * `true` when "For you" was the last tab selected on the Home timeline.
  1866. */
  1867. let wasForYouTabSelected = false
  1868.  
  1869. function isOnBookmarksPage() {
  1870. return currentPath.startsWith(PagePaths.BOOKMARKS)
  1871. }
  1872.  
  1873. function isOnCommunitiesPage() {
  1874. return URL_COMMUNITIES_RE.test(currentPath)
  1875. }
  1876.  
  1877. function isOnCommunityPage() {
  1878. return URL_COMMUNITY_RE.test(currentPath)
  1879. }
  1880.  
  1881. function isOnCommunityMembersPage() {
  1882. return URL_COMMUNITY_MEMBERS_RE.test(currentPath)
  1883. }
  1884.  
  1885. function isOnDiscoverCommunitiesPage() {
  1886. return URL_DISCOVER_COMMUNITIES_RE.test(currentPath)
  1887. }
  1888.  
  1889. function isOnDisplaySettingsPage() {
  1890. return currentPath == PagePaths.DISPLAY_SETTINGS
  1891. }
  1892.  
  1893. function isOnExplorePage() {
  1894. return currentPath == '/explore' || currentPath.startsWith('/explore/')
  1895. }
  1896.  
  1897. function isOnFollowListPage() {
  1898. return URL_PROFILE_FOLLOWS_RE.test(currentPath)
  1899. }
  1900.  
  1901. function isOnIndividualTweetPage() {
  1902. return URL_TWEET_RE.test(currentPath)
  1903. }
  1904.  
  1905. function isOnListPage() {
  1906. return URL_LIST_RE.test(currentPath)
  1907. }
  1908.  
  1909. function isOnHomeTimelinePage() {
  1910. return currentPath == PagePaths.HOME
  1911. }
  1912.  
  1913. function isOnMessagesPage() {
  1914. return currentPath.startsWith('/messages')
  1915. }
  1916.  
  1917. function isOnNotificationsPage() {
  1918. return currentPath.startsWith('/notifications')
  1919. }
  1920.  
  1921. function isOnProfilePage() {
  1922. let profilePathUsername = currentPath.match(URL_PROFILE_RE)?.[1]
  1923. if (!profilePathUsername) return false
  1924. // twitter.com/user and its sub-URLs put @user in the title
  1925. return currentPage.toLowerCase().includes(`${ltr ? '@' : ''}${profilePathUsername.toLowerCase()}${!ltr ? '@' : ''}`)
  1926. }
  1927.  
  1928. function isOnQuoteTweetsPage() {
  1929. let match = currentPath.match(URL_TWEET_ENGAGEMENT_RE)
  1930. return match?.[1] == 'quotes'
  1931. }
  1932.  
  1933. function isOnSearchPage() {
  1934. return currentPath.startsWith('/search') || currentPath.startsWith('/hashtag/')
  1935. }
  1936.  
  1937. function isOnSeparatedTweetsTimeline() {
  1938. return currentPage == separatedTweetsTimelineTitle
  1939. }
  1940.  
  1941. function isOnSettingsPage() {
  1942. return currentPath.startsWith('/settings')
  1943. }
  1944.  
  1945. function shouldHideSidebar() {
  1946. return isOnExplorePage() || isOnDiscoverCommunitiesPage()
  1947. }
  1948.  
  1949. function shouldShowSeparatedTweetsTab() {
  1950. return config.retweets == 'separate' || config.quoteTweets == 'separate'
  1951. }
  1952. //#endregion
  1953.  
  1954. //#region Utility functions
  1955. /**
  1956. * @param {string} role
  1957. * @return {HTMLStyleElement}
  1958. */
  1959. function addStyle(role) {
  1960. let $style = document.createElement('style')
  1961. $style.dataset.insertedBy = 'control-panel-for-twitter'
  1962. $style.dataset.role = role
  1963. document.head.appendChild($style)
  1964. return $style
  1965. }
  1966.  
  1967. /**
  1968. * @param {Element} $svg
  1969. */
  1970. function blueCheck($svg) {
  1971. if (!$svg) {
  1972. warn('blueCheck was given', $svg)
  1973. return
  1974. }
  1975. $svg.classList.add('tnt_blue_check')
  1976. // Safari doesn't support using `d: path(…)` to replace paths in an SVG, so
  1977. // we have to manually patch the path in it.
  1978. if (isSafari && config.twitterBlueChecks == 'replace') {
  1979. $svg.firstElementChild.firstElementChild.setAttribute('d', Svgs.BLUE_LOGO_PATH)
  1980. }
  1981. }
  1982.  
  1983. /**
  1984. * @param {Element} $svgPath
  1985. */
  1986. function twitterLogo($svgPath) {
  1987. // Safari doesn't support using `d: path(…)` to replace paths in an SVG, so
  1988. // we have to manually patch the path in it.
  1989. $svgPath.setAttribute('d', Svgs.TWITTER_LOGO_PATH)
  1990. $svgPath.parentElement.classList.add('tnt_logo')
  1991. }
  1992.  
  1993. /**
  1994. * @param {Element} $svgPath
  1995. */
  1996. function homeIcon($svgPath) {
  1997. // Safari doesn't support using `d: path(…)` to replace paths in an SVG, so
  1998. // we have to manually patch the path in it.
  1999. let replacementPath = {
  2000. [Svgs.X_HOME_ACTIVE_PATH]: Svgs.TWITTER_HOME_ACTIVE_PATH,
  2001. [Svgs.X_HOME_INACTIVE_PATH]: Svgs.TWITTER_HOME_INACTIVE_PATH,
  2002. }[$svgPath.getAttribute('d')]
  2003. if (replacementPath) {
  2004. $svgPath.setAttribute('d', replacementPath)
  2005. }
  2006. }
  2007.  
  2008. /**
  2009. * @param {string} str
  2010. * @return {string}
  2011. */
  2012. function dedent(str) {
  2013. str = str.replace(/^[ \t]*\r?\n/, '')
  2014. let indent = /^[ \t]+/m.exec(str)
  2015. if (indent) str = str.replace(new RegExp('^' + indent[0], 'gm'), '')
  2016. return str.replace(/(\r?\n)[ \t]+$/, '$1')
  2017. }
  2018.  
  2019. /**
  2020. * @param {string} name
  2021. * @param {import("./types").Disconnectable[]} observers
  2022. */
  2023. function disconnectObserver(name, observers) {
  2024. for (let i = observers.length -1; i >= 0; i--) {
  2025. let observer = observers[i]
  2026. if ('name' in observer && observer.name == name) {
  2027. observer.disconnect()
  2028. observers.splice(i, 1)
  2029. log(`disconnected ${name} ${observers === pageObservers ? 'page' : 'modal'} observer`)
  2030. }
  2031. }
  2032. }
  2033.  
  2034. function disconnectModalObserver(name) {
  2035. disconnectObserver(name, modalObservers)
  2036. }
  2037.  
  2038. function disconnectAllModalObservers() {
  2039. if (modalObservers.length > 0) {
  2040. log(
  2041. `disconnecting ${modalObservers.length} modal observer${s(modalObservers.length)}`,
  2042. modalObservers.map(observer => observer['name'])
  2043. )
  2044. modalObservers.forEach(observer => observer.disconnect())
  2045. modalObservers = []
  2046. }
  2047. }
  2048.  
  2049. function disconnectPageObserver(name) {
  2050. disconnectObserver(name, pageObservers)
  2051. }
  2052.  
  2053. /**
  2054. * @param {MutationRecord[]} mutations
  2055. * @param {($el: Node) => boolean | HTMLElement} fn - return `true` to use [$el]
  2056. * as the result, or return a different HTMLElement to use it as the result.
  2057. * @returns {Node | HTMLElement | null}
  2058. */
  2059. function findAddedNode(mutations, fn) {
  2060. for (let mutation of mutations) {
  2061. for (let el of mutation.addedNodes) {
  2062. let result = fn(el)
  2063. if (result) {
  2064. return result === true ? el : result
  2065. }
  2066. }
  2067. }
  2068. return null
  2069. }
  2070.  
  2071. /**
  2072. * @param {string} selector
  2073. * @param {{
  2074. * name?: string
  2075. * stopIf?: () => boolean
  2076. * timeout?: number
  2077. * context?: Document | HTMLElement
  2078. * }?} options
  2079. * @returns {Promise<HTMLElement | null>}
  2080. */
  2081. function getElement(selector, {
  2082. name = null,
  2083. stopIf = null,
  2084. timeout = Infinity,
  2085. context = document,
  2086. } = {}) {
  2087. return new Promise((resolve) => {
  2088. let startTime = Date.now()
  2089. let rafId
  2090. let timeoutId
  2091.  
  2092. function stop($element, reason) {
  2093. if ($element == null) {
  2094. warn(`stopped waiting for ${name || selector} after ${reason}`)
  2095. }
  2096. else if (Date.now() > startTime) {
  2097. log(`${name || selector} appeared after ${Date.now() - startTime}ms`)
  2098. }
  2099. if (rafId) {
  2100. cancelAnimationFrame(rafId)
  2101. }
  2102. if (timeoutId) {
  2103. clearTimeout(timeoutId)
  2104. }
  2105. resolve($element)
  2106. }
  2107.  
  2108. if (timeout !== Infinity) {
  2109. timeoutId = setTimeout(stop, timeout, null, `${timeout}ms timeout`)
  2110. }
  2111.  
  2112. function queryElement() {
  2113. let $element = context.querySelector(selector)
  2114. if ($element) {
  2115. stop($element)
  2116. }
  2117. else if (stopIf?.() === true) {
  2118. stop(null, 'stopIf condition met')
  2119. }
  2120. else {
  2121. rafId = requestAnimationFrame(queryElement)
  2122. }
  2123. }
  2124.  
  2125. queryElement()
  2126. })
  2127. }
  2128.  
  2129. function getState() {
  2130. let wrapped = $reactRoot.firstElementChild.wrappedJSObject || $reactRoot.firstElementChild
  2131. let reactPropsKey = Object.keys(wrapped).find(key => key.startsWith('__reactProps'))
  2132. if (reactPropsKey) {
  2133. let state = wrapped[reactPropsKey].children?.props?.children?.props?.store?.getState()
  2134. if (state) return state
  2135. warn('React state not found')
  2136. } else {
  2137. warn('React prop key not found')
  2138. }
  2139. }
  2140.  
  2141. function getStateEntities() {
  2142. let state = getState()
  2143. if (state) {
  2144. if (state.entities) return state.entities
  2145. warn('React state entities not found')
  2146. }
  2147. }
  2148.  
  2149. function getThemeColorFromState() {
  2150. let color = getState()?.settings?.local?.themeColor
  2151. if (color) {
  2152. if (THEME_COLORS.has(color)) return THEME_COLORS.get(color)
  2153. warn(color, 'not found in THEME_COLORS')
  2154. } else {
  2155. warn('could not get settings.local.themeColor from React state')
  2156. }
  2157. }
  2158.  
  2159. /**
  2160. * Gets cached tweet info from React state.
  2161. */
  2162. function getTweetInfo(id) {
  2163. let tweetEntities = getStateEntities()?.tweets?.entities
  2164. if (tweetEntities) {
  2165. let tweetInfo = tweetEntities[id]
  2166. if (!tweetInfo) {
  2167. warn('tweet info not found')
  2168. }
  2169. return tweetInfo
  2170. } else {
  2171. warn('tweet entities not found')
  2172. }
  2173. }
  2174.  
  2175. /**
  2176. * Gets cached user info from React state.
  2177. * @returns {import("./types").UserInfoObject}
  2178. */
  2179. function getUserInfo() {
  2180. /** @type {import("./types").UserInfoObject} */
  2181. let userInfo = {}
  2182. let userEntities = getStateEntities()?.users?.entities
  2183. if (userEntities) {
  2184. for (let user of Object.values(userEntities)) {
  2185. userInfo[user.screen_name] = {
  2186. following: user.following,
  2187. followedBy: user.followed_by,
  2188. followersCount: user.followers_count,
  2189. }
  2190. }
  2191. } else {
  2192. warn('user entities not found')
  2193. }
  2194. return userInfo
  2195. }
  2196.  
  2197. /**
  2198. * @param {import("./types").Disconnectable[]} observers
  2199. * @param {string} name
  2200. */
  2201. function isObserving(observers, name) {
  2202. return observers.some(observer => 'name' in observer && observer.name == name)
  2203. }
  2204.  
  2205. function log(...args) {
  2206. if (debug) {
  2207. let page = currentPage?.replace(/(\r?\n)+/g, ' ')
  2208. console.log(`${page ? `(${
  2209. page.length < 42 ? page : page.slice(0, 42) + '…'
  2210. })` : ''}`, ...args)
  2211. }
  2212. }
  2213.  
  2214. function warn(...args) {
  2215. if (debug) {
  2216. console.log(`❗ ${currentPage ? `(${currentPage})` : ''}`, ...args)
  2217. }
  2218. }
  2219.  
  2220. function error(...args) {
  2221. console.log(`❌ ${currentPage ? `(${currentPage})` : ''}`, ...args)
  2222. }
  2223.  
  2224. /**
  2225. * @param {() => boolean} condition
  2226. * @returns {() => boolean}
  2227. */
  2228. function not(condition) {
  2229. return () => !condition()
  2230. }
  2231.  
  2232. /**
  2233. * Convenience wrapper for the MutationObserver API - the callback is called
  2234. * immediately to support using an observer and its options as a trigger for any
  2235. * change, without looking at MutationRecords.
  2236. * @param {Node} $element
  2237. * @param {MutationCallback} callback
  2238. * @param {string} name
  2239. * @param {MutationObserverInit} options
  2240. * @return {import("./types").NamedMutationObserver}
  2241. */
  2242. function observeElement($element, callback, name, options = {childList: true}) {
  2243. if (name) {
  2244. if (options.childList && callback.length > 0) {
  2245. log(`observing ${name}`, $element)
  2246. } else {
  2247. log (`observing ${name}`)
  2248. }
  2249. }
  2250.  
  2251. let observer = new MutationObserver(callback)
  2252. callback([], observer)
  2253. observer.observe($element, options)
  2254. observer['name'] = name
  2255. return observer
  2256. }
  2257.  
  2258. /**
  2259. * @param {string} page
  2260. * @returns {() => boolean}
  2261. */
  2262. function pageIsNot(page) {
  2263. return function() {
  2264. let pageChanged = page != currentPage
  2265. if (pageChanged) {
  2266. log('pageIsNot', {page, currentPage})
  2267. }
  2268. return pageChanged
  2269. }
  2270. }
  2271.  
  2272. /**
  2273. * @param {string} path
  2274. * @returns {() => boolean}
  2275. */
  2276. function pathIsNot(path) {
  2277. return () => path != currentPath
  2278. }
  2279.  
  2280. /**
  2281. * @param {number} n
  2282. * @returns {string}
  2283. */
  2284. function s(n) {
  2285. return n == 1 ? '' : 's'
  2286. }
  2287.  
  2288. /**
  2289. * @param {Element} $tweetButtonText
  2290. */
  2291. function setTweetButtonText($tweetButtonText) {
  2292. let currentText = $tweetButtonText.textContent
  2293. if (currentText == getString('TWEET') || currentText == getString('TWEET_ALL')) return
  2294. $tweetButtonText.textContent = currentText == getString('POST_ALL') ? getString('TWEET_ALL') : getString('TWEET')
  2295. }
  2296.  
  2297. function storeConfigChanges(changes) {
  2298. window.postMessage({type: 'tntConfigChange', changes})
  2299. }
  2300. //#endregion
  2301.  
  2302. //#region Global observers
  2303. const checkReactNativeStylesheet = (() => {
  2304. /** @type {number} */
  2305. let startTime
  2306.  
  2307. return function checkReactNativeStylesheet() {
  2308. startTime ??= Date.now()
  2309.  
  2310. let $style = /** @type {HTMLStyleElement} */ (document.querySelector('style#react-native-stylesheet'))
  2311. if (!$style) {
  2312. warn('React Native stylesheet not found')
  2313. return
  2314. }
  2315.  
  2316. for (let rule of $style.sheet.cssRules) {
  2317. if (!(rule instanceof CSSStyleRule)) continue
  2318.  
  2319. if (fontFamilyRule == null &&
  2320. rule.style.fontFamily?.includes('TwitterChirp') &&
  2321. !rule.style.fontFamily.includes('TwitterChirpExtendedHeavy')) {
  2322. fontFamilyRule = rule
  2323. log('found Chirp fontFamily CSS rule in React Native stylesheet')
  2324. configureFont()
  2325. }
  2326.  
  2327. if (filterBlurRule == null && rule.style.filter?.includes('blur(30px)')) {
  2328. filterBlurRule = rule
  2329. log('found filter: blur(30px) rule in React Native stylesheet', filterBlurRule)
  2330. configureDynamicCss()
  2331. }
  2332. }
  2333.  
  2334. let elapsedTime = Date.now() - startTime
  2335. if (fontFamilyRule == null || filterBlurRule == null) {
  2336. if (elapsedTime < 3000) {
  2337. setTimeout(checkReactNativeStylesheet, 100)
  2338. } else {
  2339. warn(`stopped checking React Native stylesheet after ${elapsedTime}ms`)
  2340. }
  2341. } else {
  2342. log(`finished checking React Native stylesheet in ${elapsedTime}ms`)
  2343. }
  2344. }
  2345. })()
  2346.  
  2347. /**
  2348. * When the "Background" setting is changed, <body>'s backgroundColor is changed
  2349. * and the app is re-rendered, so we need to re-process the current page.
  2350. */
  2351. function observeBodyBackgroundColor() {
  2352. let lastBackgroundColor = null
  2353.  
  2354. observeElement($body, () => {
  2355. let backgroundColor = $body.style.backgroundColor
  2356. if (backgroundColor == lastBackgroundColor) return
  2357.  
  2358. $body.classList.toggle('Default', backgroundColor == 'rgb(255, 255, 255)')
  2359. $body.classList.toggle('Dim', backgroundColor == 'rgb(21, 32, 43)')
  2360. $body.classList.toggle('LightsOut', backgroundColor == 'rgb(0, 0, 0)')
  2361.  
  2362. if (lastBackgroundColor != null) {
  2363. log('Background setting changed - re-processing current page')
  2364. observePopups()
  2365. observeSideNavTweetButton()
  2366. processCurrentPage()
  2367. }
  2368. lastBackgroundColor = backgroundColor
  2369. }, '<body> style attribute for background colour changes', {
  2370. attributes: true,
  2371. attributeFilter: ['style']
  2372. })
  2373. }
  2374.  
  2375. async function observeDesktopComposeTweetModal($popup) {
  2376. let $modalDialog = await getElement('div[role="dialog"][aria-labelledby]', {
  2377. context: $popup,
  2378. stopIf: () => !isDesktopComposeTweetModalOpen
  2379. })
  2380. if (!$modalDialog) return
  2381.  
  2382. /** @type {import("./types").Disconnectable} */
  2383. let tweetButtonObserver
  2384.  
  2385. function disconnectTweetButtonObserver() {
  2386. if (tweetButtonObserver) {
  2387. log('disconnecting tweet button dialog observer')
  2388. tweetButtonObserver.disconnect()
  2389. modalObservers.splice(modalObservers.indexOf(tweetButtonObserver), 1)
  2390. tweetButtonObserver = null
  2391. }
  2392. }
  2393.  
  2394. let waitingForTweetButton = false
  2395.  
  2396. modalObservers.push(
  2397. observeElement($modalDialog, async () => {
  2398. if (waitingForTweetButton) return
  2399.  
  2400. waitingForTweetButton = true
  2401. let $tweetButtonText = await getElement('button[data-testid="tweetButton"] span > span', {
  2402. context: $modalDialog,
  2403. name: 'tweet button',
  2404. timeout: 500,
  2405. })
  2406. waitingForTweetButton = false
  2407.  
  2408. if (!$tweetButtonText) {
  2409. disconnectTweetButtonObserver()
  2410. return
  2411. }
  2412.  
  2413. setTweetButtonText($tweetButtonText)
  2414.  
  2415. // The button will be moved around when multiple Tweets are being edited
  2416. tweetButtonObserver = observeElement($modalDialog, (mutations) => {
  2417. for (let mutation of mutations) {
  2418. for (let $addedNode of mutation.addedNodes) {
  2419. let $tweetButtonText = $addedNode.querySelector?.('button[data-testid="tweetButton"] span > span')
  2420. if ($tweetButtonText) {
  2421. setTweetButtonText($tweetButtonText)
  2422. }
  2423. }
  2424. }
  2425. }, 'tweet button dialog', {childList: true, subtree: true})
  2426. modalObservers.push(tweetButtonObserver)
  2427. }, 'compose tweet modal dialog')
  2428. )
  2429. }
  2430.  
  2431. /**
  2432. * @param {HTMLElement} $popup
  2433. */
  2434. async function observeDesktopModalTimeline($popup) {
  2435. // Media modals remember if they were previously collapsed, so we could be
  2436. // waiting for the initial timeline to be either rendered or expanded.
  2437. let $initialTimeline = await getElement(Selectors.MODAL_TIMELINE, {
  2438. context: $popup,
  2439. name: 'initial modal timeline',
  2440. stopIf: () => !isDesktopMediaModalOpen,
  2441. })
  2442.  
  2443. if ($initialTimeline == null) return
  2444.  
  2445. /**
  2446. * @param {HTMLElement} $timeline
  2447. */
  2448. function observeModalTimelineItems($timeline) {
  2449. disconnectModalObserver('modal timeline')
  2450. modalObservers.push(
  2451. observeElement($timeline, () => onIndividualTweetTimelineChange($timeline, {observers: modalObservers}), 'modal timeline')
  2452. )
  2453. setDefaultSortReplies()
  2454.  
  2455. // If other media in the modal is clicked, the timeline is replaced.
  2456. disconnectModalObserver('modal timeline parent')
  2457. modalObservers.push(
  2458. observeElement($timeline.parentElement, (mutations) => {
  2459. mutations.forEach((mutation) => {
  2460. mutation.addedNodes.forEach((/** @type {HTMLElement} */ $newTimeline) => {
  2461. log('modal timeline replaced')
  2462. disconnectModalObserver('modal timeline')
  2463. modalObservers.push(
  2464. observeElement($newTimeline, () => onIndividualTweetTimelineChange($newTimeline, {observers: modalObservers}), 'modal timeline')
  2465. )
  2466. setDefaultSortReplies()
  2467. })
  2468. })
  2469. }, 'modal timeline parent')
  2470. )
  2471. }
  2472.  
  2473. /**
  2474. * @param {HTMLElement} $timeline
  2475. */
  2476. function observeModalTimeline($timeline) {
  2477. // If the inital timeline doesn't have a style attribute it's a placeholder
  2478. if ($timeline.hasAttribute('style')) {
  2479. observeModalTimelineItems($timeline)
  2480. }
  2481. else {
  2482. log('waiting for modal timeline')
  2483. let startTime = Date.now()
  2484. modalObservers.push(
  2485. observeElement($timeline.parentElement, (mutations) => {
  2486. mutations.forEach((mutation) => {
  2487. mutation.addedNodes.forEach((/** @type {HTMLElement} */ $timeline) => {
  2488. disconnectModalObserver('modal timeline parent')
  2489. if (Date.now() > startTime) {
  2490. log(`modal timeline appeared after ${Date.now() - startTime}ms`, $timeline)
  2491. }
  2492. observeModalTimelineItems($timeline)
  2493. })
  2494. })
  2495. }, 'modal timeline parent')
  2496. )
  2497. }
  2498. }
  2499.  
  2500. // The modal timeline can be expanded and collapsed
  2501. let $expandedContainer = $initialTimeline.closest('[aria-expanded="true"]')
  2502. modalObservers.push(
  2503. observeElement($expandedContainer.parentElement, async (mutations) => {
  2504. if (mutations.some(mutation => mutation.removedNodes.length > 0)) {
  2505. log('modal timeline collapsed')
  2506. disconnectModalObserver('modal timeline parent')
  2507. disconnectModalObserver('modal timeline')
  2508. }
  2509. else if (mutations.some(mutation => mutation.addedNodes.length > 0)) {
  2510. log('modal timeline expanded')
  2511. let $timeline = await getElement(Selectors.MODAL_TIMELINE, {
  2512. context: $popup,
  2513. name: 'expanded modal timeline',
  2514. stopIf: () => !isDesktopMediaModalOpen,
  2515. })
  2516. if ($timeline == null) return
  2517. observeModalTimeline($timeline)
  2518. }
  2519. }, 'collapsible modal timeline container')
  2520. )
  2521.  
  2522. observeModalTimeline($initialTimeline)
  2523. }
  2524.  
  2525. const observeFavicon = (() => {
  2526. /** @type {HTMLElement} */
  2527. let $shortcutIcon
  2528. /** @type {MutationObserver} */
  2529. let shortcutIconObserver
  2530.  
  2531. async function observeFavicon() {
  2532. $shortcutIcon ??= await getElement('link[rel="shortcut icon"]', {name: 'shortcut icon'})
  2533.  
  2534. if (!config.replaceLogo) {
  2535. if (shortcutIconObserver != null) {
  2536. shortcutIconObserver.disconnect()
  2537. shortcutIconObserver = null
  2538. if ($shortcutIcon.getAttribute('href').startsWith('data:')) {
  2539. $shortcutIcon.setAttribute('href', `//abs.twimg.com/favicons/twitter${currentNotificationCount ? '-pip' : ''}.3.ico`)
  2540. }
  2541. }
  2542. return
  2543. }
  2544.  
  2545. shortcutIconObserver = observeElement($shortcutIcon, () => {
  2546. let href = $shortcutIcon.getAttribute('href')
  2547. if (href.startsWith('data:')) return
  2548. $shortcutIcon.setAttribute('href', href.includes('pip') ? Images.TWITTER_PIP_FAVICON : Images.TWITTER_FAVICON)
  2549. }, 'shortcut icon href', {
  2550. attributes: true,
  2551. attributeFilter: ['href']
  2552. })
  2553. }
  2554.  
  2555. observeFavicon.updatePip = function(showPip) {
  2556. if (!$shortcutIcon) return
  2557. let icon = showPip ? Images.TWITTER_PIP_FAVICON : Images.TWITTER_FAVICON
  2558. if ($shortcutIcon.getAttribute('href') != icon) {
  2559. $shortcutIcon.setAttribute('href', icon)
  2560. }
  2561. }
  2562.  
  2563. return observeFavicon
  2564. })()
  2565.  
  2566. /**
  2567. * Twitter displays popups in the #layers element. It also reuses open popups
  2568. * in certain cases rather than creating one from scratch, so we also need to
  2569. * deal with nested popups, e.g. if you hover over the caret menu in a Tweet, a
  2570. * popup will be created to display a "More" tootip and clicking to open the
  2571. * menu will create a nested element in the existing popup, whereas clicking the
  2572. * caret quickly without hovering over it will display the menu in new popup.
  2573. * Use of nested popups can also differ between desktop and mobile, so features
  2574. * need to be mindful of that.
  2575. */
  2576. const observePopups = (() => {
  2577. /** @type {MutationObserver} */
  2578. let popupObserver
  2579. /** @type {WeakMap<HTMLElement, {disconnect()}>} */
  2580. let nestedObservers = new WeakMap()
  2581.  
  2582. return async function observePopups() {
  2583. if (popupObserver) {
  2584. popupObserver.disconnect()
  2585. popupObserver = null
  2586. }
  2587.  
  2588. let $layers = await getElement('#layers', {
  2589. name: 'layers',
  2590. })
  2591.  
  2592. // There can be only one
  2593. if (popupObserver) {
  2594. popupObserver.disconnect()
  2595. }
  2596.  
  2597. popupObserver = observeElement($layers, (mutations) => {
  2598. mutations.forEach((mutation) => {
  2599. mutation.addedNodes.forEach((/** @type {HTMLElement} */ $el) => {
  2600. let nestedObserver = onPopup($el)
  2601. if (nestedObserver) {
  2602. nestedObservers.set($el, nestedObserver)
  2603. }
  2604. })
  2605. mutation.removedNodes.forEach((/** @type {HTMLElement} */ $el) => {
  2606. if (nestedObservers.has($el)) {
  2607. nestedObservers.get($el).disconnect()
  2608. nestedObservers.delete($el)
  2609. }
  2610. })
  2611. })
  2612. }, 'popup container')
  2613. }
  2614. })()
  2615.  
  2616. async function observeTitle() {
  2617. let $title = await getElement('title', {name: '<title>'})
  2618. observeElement($title, () => {
  2619. let title = $title.textContent
  2620. if (config.replaceLogo && (ltr ? /X$/ : /^(?:\(\d+\+?\) )?X/).test(title)) {
  2621. let newTitle = title.replace(ltr ? /X$/ : 'X', getString('TWITTER'))
  2622. document.title = newTitle
  2623. // If Twitter is opened in the background, changing the title might not
  2624. // re-fire the title MutationObserver, preventing the initial page from
  2625. // being processed.
  2626. if (!currentPage) {
  2627. onTitleChange(newTitle)
  2628. }
  2629. return
  2630. }
  2631. if (observingPageChanges) {
  2632. onTitleChange(title)
  2633. }
  2634. }, '<title>')
  2635. }
  2636. //#endregion
  2637.  
  2638. //#region Page observers
  2639. async function observeSidebar() {
  2640. let $primaryColumn = await getElement(Selectors.PRIMARY_COLUMN, {
  2641. name: 'primary column'
  2642. })
  2643. let $sidebarContainer = $primaryColumn.parentElement
  2644. pageObservers.push(
  2645. observeElement($sidebarContainer, () => {
  2646. let $sidebar = $sidebarContainer.querySelector(Selectors.SIDEBAR)
  2647. log(`sidebar ${$sidebar ? 'appeared' : 'disappeared'}`)
  2648. $body.classList.toggle('Sidebar', Boolean($sidebar))
  2649. if ($sidebar && config.twitterBlueChecks != 'ignore' && !isOnSearchPage() && !isOnExplorePage()) {
  2650. observeSearchForm()
  2651. }
  2652. }, 'sidebar container')
  2653. )
  2654. }
  2655.  
  2656. const observeSideNavTweetButton = (() => {
  2657. /** @type {MutationObserver} */
  2658. let observer
  2659.  
  2660. return async function observeSideNavTweetButton() {
  2661. if (observer) {
  2662. observer.disconnect()
  2663. observer = null
  2664. }
  2665.  
  2666. if (!desktop || !config.replaceLogo) return
  2667.  
  2668. // This element is updated when text is added or removed on resize
  2669. let $buttonTextContainer = await getElement('a[data-testid="SideNav_NewTweet_Button"] > div > span', {
  2670. name: 'sidenav tweet button text container',
  2671. })
  2672. observer = observeElement($buttonTextContainer, () => {
  2673. if ($buttonTextContainer.childElementCount > 0) {
  2674. let $buttonText = /** @type {HTMLElement} */ ($buttonTextContainer.querySelector('span > span'))
  2675. if ($buttonText) {
  2676. setTweetButtonText($buttonText)
  2677. } else {
  2678. warn('could not find tweet button text')
  2679. }
  2680. }
  2681. }, 'sidenav tweet button')
  2682. }
  2683. })()
  2684.  
  2685. async function observeSearchForm() {
  2686. let $searchForm = await getElement('form[role="search"]', {
  2687. name: 'search form',
  2688. stopIf: pageIsNot(currentPage),
  2689. // The sidebar on Profile pages can be really slow
  2690. timeout: 2000,
  2691. })
  2692. if (!$searchForm) return
  2693. let $results = /** @type {HTMLElement} */ ($searchForm.lastElementChild)
  2694. pageObservers.push(
  2695. observeElement($results, () => {
  2696. processBlueChecks($results)
  2697. }, 'search results', {childList: true, subtree: true})
  2698. )
  2699. }
  2700.  
  2701. /**
  2702. * @param {string} page
  2703. * @param {import("./types").TimelineOptions?} options
  2704. */
  2705. async function observeTimeline(page, options = {}) {
  2706. let {
  2707. isTabbed = false,
  2708. onTabChanged = null,
  2709. onTimelineAppeared = null,
  2710. tabbedTimelineContainerSelector = null,
  2711. timelineSelector = Selectors.TIMELINE,
  2712. } = options
  2713.  
  2714. let $timeline = await getElement(timelineSelector, {
  2715. name: 'initial timeline',
  2716. stopIf: pageIsNot(page),
  2717. })
  2718.  
  2719. if ($timeline == null) return
  2720.  
  2721. /**
  2722. * @param {HTMLElement} $timeline
  2723. */
  2724. function observeTimelineItems($timeline) {
  2725. disconnectPageObserver('timeline')
  2726. pageObservers.push(
  2727. observeElement($timeline, () => onTimelineChange($timeline, page, options), 'timeline')
  2728. )
  2729. onTimelineAppeared?.()
  2730. if (isTabbed) {
  2731. // When a tab which has been viewed before is revisited, the timeline is
  2732. // replaced.
  2733. disconnectPageObserver('timeline parent')
  2734. pageObservers.push(
  2735. observeElement($timeline.parentElement, (mutations) => {
  2736. mutations.forEach((mutation) => {
  2737. mutation.addedNodes.forEach((/** @type {HTMLElement} */ $newTimeline) => {
  2738. disconnectPageObserver('timeline')
  2739. log('tab changed')
  2740. onTabChanged?.()
  2741. pageObservers.push(
  2742. observeElement($newTimeline, () => onTimelineChange($newTimeline, page, options), 'timeline')
  2743. )
  2744. })
  2745. })
  2746. }, 'timeline parent')
  2747. )
  2748. }
  2749. }
  2750.  
  2751. // If the inital timeline doesn't have a style attribute it's a placeholder
  2752. if ($timeline.hasAttribute('style')) {
  2753. observeTimelineItems($timeline)
  2754. }
  2755. else {
  2756. log('waiting for timeline')
  2757. let startTime = Date.now()
  2758. pageObservers.push(
  2759. observeElement($timeline.parentElement, (mutations) => {
  2760. mutations.forEach((mutation) => {
  2761. mutation.addedNodes.forEach((/** @type {HTMLElement} */ $timeline) => {
  2762. disconnectPageObserver('timeline parent')
  2763. if (Date.now() > startTime) {
  2764. log(`timeline appeared after ${Date.now() - startTime}ms`, $timeline)
  2765. }
  2766. observeTimelineItems($timeline)
  2767. })
  2768. })
  2769. }, 'timeline parent')
  2770. )
  2771. }
  2772.  
  2773. // On some tabbed timeline pages, the first time a new tab is navigated to,
  2774. // the element containing the timeline is replaced with a loading spinner.
  2775. if (isTabbed && tabbedTimelineContainerSelector) {
  2776. let $tabbedTimelineContainer = document.querySelector(tabbedTimelineContainerSelector)
  2777. if ($tabbedTimelineContainer) {
  2778. let waitingForNewTimeline = false
  2779. pageObservers.push(
  2780. observeElement($tabbedTimelineContainer, async (mutations) => {
  2781. // This is going to fire twice on a new tab, as the spinner is added
  2782. // then replaced with the new timeline element.
  2783. if (!mutations.some(mutation => mutation.addedNodes.length > 0) || waitingForNewTimeline) return
  2784.  
  2785. waitingForNewTimeline = true
  2786. let $newTimeline = await getElement(timelineSelector, {
  2787. name: 'new timeline',
  2788. stopIf: pageIsNot(page),
  2789. })
  2790. waitingForNewTimeline = false
  2791. if (!$newTimeline) return
  2792.  
  2793. log('tab changed')
  2794. onTabChanged?.()
  2795. observeTimelineItems($newTimeline)
  2796. }, 'tabbed timeline container')
  2797. )
  2798. } else {
  2799. warn('tabbed timeline container not found', tabbedTimelineContainerSelector)
  2800. }
  2801. }
  2802. }
  2803.  
  2804. /**
  2805. * @param {string} page
  2806. */
  2807. async function observeIndividualTweetTimeline(page) {
  2808. let $timeline = await getElement(Selectors.TIMELINE, {
  2809. name: 'initial individual tweet timeline',
  2810. stopIf: pageIsNot(page),
  2811. })
  2812.  
  2813. if ($timeline == null) return
  2814.  
  2815. /**
  2816. * @param {HTMLElement} $timeline
  2817. */
  2818. function observeTimelineItems($timeline) {
  2819. pageObservers.push(
  2820. observeElement($timeline, () => onIndividualTweetTimelineChange($timeline, {observers: pageObservers}), 'individual tweet timeline')
  2821. )
  2822. }
  2823.  
  2824. // If the inital timeline doesn't have a style attribute it's a placeholder
  2825. if ($timeline.hasAttribute('style')) {
  2826. observeTimelineItems($timeline)
  2827. }
  2828. else {
  2829. log('waiting for individual tweet timeline')
  2830. let startTime = Date.now()
  2831. pageObservers.push(
  2832. observeElement($timeline.parentElement, (mutations) => {
  2833. mutations.forEach((mutation) => {
  2834. mutation.addedNodes.forEach((/** @type {HTMLElement} */ $timeline) => {
  2835. disconnectPageObserver('individual tweet timeline parent')
  2836. if (Date.now() > startTime) {
  2837. log(`individual tweet timeline appeared after ${Date.now() - startTime}ms`, $timeline)
  2838. }
  2839. observeTimelineItems($timeline)
  2840. })
  2841. })
  2842. }, 'individual tweet timeline parent')
  2843. )
  2844. }
  2845. }
  2846. //#endregion
  2847.  
  2848. //#region Tweak functions
  2849. /**
  2850. * Add an "Add muted word" menu item after the given link which takes you
  2851. * straight to entering a new muted word (by clicking its way through all the
  2852. * individual screens!).
  2853. * @param {HTMLElement} $link
  2854. * @param {string} linkSelector
  2855. */
  2856. async function addAddMutedWordMenuItem($link, linkSelector) {
  2857. log('adding "Add muted word" menu item')
  2858.  
  2859. // Wait for the dropdown to appear on desktop
  2860. if (desktop) {
  2861. $link = await getElement(`#layers div[data-testid="Dropdown"] ${linkSelector}`, {
  2862. name: 'rendered menu item',
  2863. timeout: 100,
  2864. })
  2865. if (!$link) return
  2866. }
  2867.  
  2868. let $addMutedWord = /** @type {HTMLElement} */ ($link.parentElement.cloneNode(true))
  2869. $addMutedWord.classList.add('tnt_menu_item')
  2870. $addMutedWord.querySelector('a').href = PagePaths.ADD_MUTED_WORD
  2871. $addMutedWord.querySelector('span').textContent = getString('ADD_MUTED_WORD')
  2872. $addMutedWord.querySelector('svg').innerHTML = Svgs.MUTE
  2873. $addMutedWord.addEventListener('click', (e) => {
  2874. e.preventDefault()
  2875. addMutedWord()
  2876. })
  2877. $link.parentElement.insertAdjacentElement('beforebegin', $addMutedWord)
  2878. }
  2879.  
  2880. function addCaretMenuListenerForQuoteTweet($tweet) {
  2881. let $caret = /** @type {HTMLElement} */ ($tweet.querySelector('[data-testid="caret"]'))
  2882. if ($caret && !$caret.dataset.tweakNewTwitterListener) {
  2883. $caret.addEventListener('click', () => {
  2884. quotedTweet = getQuotedTweetDetails($tweet, {getText: true})
  2885. })
  2886. $caret.dataset.tweakNewTwitterListener = 'true'
  2887. }
  2888. }
  2889.  
  2890. /**
  2891. * @param {HTMLElement} $blockMenuItem
  2892. */
  2893. async function addMuteQuotesMenuItems($blockMenuItem) {
  2894. log('mutableQuoteTweets: adding "Mute this conversation" and "Turn off Quote Tweets" menu item')
  2895.  
  2896. // Wait for the menu to render properly on desktop
  2897. if (desktop) {
  2898. $blockMenuItem = await getElement(`:scope > div > div > div > ${Selectors.BLOCK_MENU_ITEM}`, {
  2899. context: $blockMenuItem.parentElement,
  2900. name: 'rendered block menu item',
  2901. timeout: 100,
  2902. })
  2903. if (!$blockMenuItem) return
  2904. }
  2905.  
  2906. let $muteQuotes = /** @type {HTMLElement} */ ($blockMenuItem.previousElementSibling.cloneNode(true))
  2907. $muteQuotes.classList.add('tnt_menu_item')
  2908. $muteQuotes.querySelector('span').textContent = getString('MUTE_THIS_CONVERSATION')
  2909. $muteQuotes.addEventListener('click', (e) => {
  2910. e.preventDefault()
  2911. log('mutableQuoteTweets: muting quotes of a tweet', quotedTweet)
  2912. config.mutedQuotes = config.mutedQuotes.concat(quotedTweet)
  2913. storeConfigChanges({mutedQuotes: config.mutedQuotes})
  2914. processCurrentPage()
  2915. // Dismiss the menu
  2916. let $menuLayer = /** @type {HTMLElement} */ ($blockMenuItem.closest('[role="group"]')?.firstElementChild?.firstElementChild)
  2917. if (!$menuLayer) {
  2918. warn('mutableQuoteTweets: could not find menu layer to dismiss menu')
  2919. }
  2920. $menuLayer?.click()
  2921. })
  2922.  
  2923. if (quotedTweet?.quotedBy) {
  2924. let $toggleQuotes = /** @type {HTMLElement} */ ($blockMenuItem.previousElementSibling.cloneNode(true))
  2925. $toggleQuotes.classList.add('tnt_menu_item')
  2926. $toggleQuotes.querySelector('span').textContent = getString(`TURN_OFF_QUOTE_TWEETS`)
  2927. $toggleQuotes.querySelector('svg').innerHTML = Svgs.RETWEETS_OFF
  2928. $toggleQuotes.addEventListener('click', (e) => {
  2929. e.preventDefault()
  2930. log('mutableQuoteTweets: toggling quotes from', quotedTweet.quotedBy)
  2931. if (config.hideQuotesFrom.includes(quotedTweet.quotedBy)) {
  2932. config.hideQuotesFrom = config.hideQuotesFrom.filter(user => user != quotedTweet.quotedBy)
  2933. } else {
  2934. config.hideQuotesFrom = config.hideQuotesFrom.concat(quotedTweet.quotedBy)
  2935. }
  2936. storeConfigChanges({hideQuotesFrom: config.hideQuotesFrom})
  2937. processCurrentPage()
  2938. // Dismiss the menu
  2939. let $menuLayer = /** @type {HTMLElement} */ ($blockMenuItem.closest('[role="group"]')?.firstElementChild?.firstElementChild)
  2940. if (!$menuLayer) {
  2941. warn('mutableQuoteTweets: could not find menu layer to dismiss menu')
  2942. }
  2943. $menuLayer?.click()
  2944. })
  2945. $blockMenuItem.insertAdjacentElement('beforebegin', $toggleQuotes)
  2946. } else {
  2947. warn('mutableQuoteTweets: quotedBy not available when Tweet menu was opened')
  2948. }
  2949.  
  2950. $blockMenuItem.insertAdjacentElement('beforebegin', $muteQuotes)
  2951. }
  2952.  
  2953. async function addMutedWord() {
  2954. if (!document.querySelector('a[href="/settings')) {
  2955. let $settingsAndSupport = /** @type {HTMLElement} */ (document.querySelector('[data-testid="settingsAndSupport"]'))
  2956. $settingsAndSupport?.click()
  2957. }
  2958.  
  2959. for (let path of [
  2960. '/settings',
  2961. '/settings/privacy_and_safety',
  2962. '/settings/mute_and_block',
  2963. '/settings/muted_keywords',
  2964. '/settings/add_muted_keyword',
  2965. ]) {
  2966. let $link = await getElement(`a[href="${path}"]`, {timeout: 500})
  2967. if (!$link) return
  2968. $link.click()
  2969. }
  2970. let $input = await getElement('input[name="keyword"]')
  2971. setTimeout(() => $input.focus(), 100)
  2972. }
  2973.  
  2974. /**
  2975. * Add a "Turn on/off Retweets" menu item to a List's menu.
  2976. * @param {HTMLElement} $switchMenuItem
  2977. */
  2978. async function addToggleListRetweetsMenuItem($switchMenuItem) {
  2979. log('adding "Turn on/off Retweets" menu item')
  2980.  
  2981. // Wait for the menu to render properly on desktop
  2982. if (desktop) {
  2983. $switchMenuItem = await getElement(':scope > div > div > div > [role="menuitem"]', {
  2984. context: $switchMenuItem.parentElement,
  2985. name: 'rendered switch menu item',
  2986. timeout: 100,
  2987. })
  2988. if (!$switchMenuItem) return
  2989. }
  2990.  
  2991. let $toggleRetweets = /** @type {HTMLElement} */ ($switchMenuItem.cloneNode(true))
  2992. $toggleRetweets.classList.add('tnt_menu_item')
  2993. $toggleRetweets.querySelector('span').textContent = getString(`TURN_${config.listRetweets == 'ignore' ? 'OFF' : 'ON'}_RETWEETS`)
  2994. $toggleRetweets.querySelector('svg').innerHTML = config.listRetweets == 'ignore' ? Svgs.RETWEETS_OFF : Svgs.RETWEET
  2995. // Remove subtitle if the cloned menu item has one
  2996. $toggleRetweets.querySelector('div[dir] + div[dir]')?.remove()
  2997. $toggleRetweets.addEventListener('click', (e) => {
  2998. e.preventDefault()
  2999. log('toggling list retweets')
  3000. config.listRetweets = config.listRetweets == 'ignore' ? 'hide' : 'ignore'
  3001. storeConfigChanges({listRetweets: config.listRetweets})
  3002. processCurrentPage()
  3003. // Dismiss the menu
  3004. let $menuLayer = /** @type {HTMLElement} */ ($switchMenuItem.closest('[role="group"]')?.firstElementChild?.firstElementChild)
  3005. if (!$menuLayer) {
  3006. log('could not find menu layer to dismiss menu')
  3007. }
  3008. $menuLayer?.click()
  3009. })
  3010.  
  3011. $switchMenuItem.insertAdjacentElement('beforebegin', $toggleRetweets)
  3012. }
  3013.  
  3014. /**
  3015. * Redirects away from the Home timeline if we're on it and it's been disabled.
  3016. * @returns {boolean} `true` if redirected as a result of this call
  3017. */
  3018. function checkforDisabledHomeTimeline() {
  3019. if (config.disableHomeTimeline && location.pathname == PagePaths.HOME) {
  3020. log(`Home timeline disabled, redirecting to /${config.disabledHomeTimelineRedirect}`)
  3021. let primaryNavSelector = desktop ? Selectors.PRIMARY_NAV_DESKTOP : Selectors.PRIMARY_NAV_MOBILE
  3022. void (async () => {
  3023. let $navLink = await getElement(`${primaryNavSelector} a[href="/${config.disabledHomeTimelineRedirect}"]`, {
  3024. name: `${config.disabledHomeTimelineRedirect} nav link`,
  3025. stopIf: () => location.pathname != PagePaths.HOME,
  3026. })
  3027. if (!$navLink) return
  3028. $navLink.click()
  3029. })()
  3030. return true
  3031. }
  3032. }
  3033.  
  3034. //#region CSS
  3035. const configureCss = (() => {
  3036. let $style
  3037.  
  3038. return function configureCss() {
  3039. $style ??= addStyle('features')
  3040. let cssRules = [`
  3041. .tnt_font_family {
  3042. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  3043. }
  3044. `]
  3045. let hideCssSelectors = []
  3046. let menuRole = `[role="${desktop ? 'menu' : 'dialog'}"]`
  3047.  
  3048. // Theme colours for custom UI items
  3049. cssRules.push(`
  3050. body.Default {
  3051. --border-color: rgb(239, 243, 244);
  3052. --color: rgb(83, 100, 113);
  3053. --color-emphasis: rgb(15, 20, 25);
  3054. --hover-bg-color: rgb(247, 249, 249);
  3055. }
  3056. body.Dim {
  3057. --border-color: rgb(56, 68, 77);
  3058. --color: rgb(139, 152, 165);
  3059. --color-emphasis: rgb(247, 249, 249);
  3060. --hover-bg-color: rgb(30, 39, 50);
  3061. }
  3062. body.LightsOut {
  3063. --border-color: rgb(47, 51, 54);
  3064. --color: rgb(113, 118, 123);
  3065. --color-emphasis: rgb(247, 249, 249);
  3066. --hover-bg-color: rgb(22, 24, 28);
  3067. }
  3068. .tnt_menu_item:hover { background-color: var(--hover-bg-color) !important; }
  3069. `)
  3070.  
  3071. if (config.alwaysUseLatestTweets && config.hideForYouTimeline) {
  3072. cssRules.push(`
  3073. /* Prevent the For you tab container taking up space */
  3074. body.HomeTimeline ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:first-child {
  3075. flex-grow: 0;
  3076. flex-shrink: 1;
  3077. }
  3078. /* Hide the For you tab link */
  3079. body.HomeTimeline ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:first-child > a {
  3080. display: none;
  3081. }
  3082. `)
  3083. if (desktop) {
  3084. // Don't accidentally hide the Media button in the Tweet box toolbar
  3085. cssRules.push(`
  3086. body.HomeTimeline ${Selectors.PRIMARY_COLUMN} div[data-testid="toolBar"] nav div[role="tablist"] > div:first-child {
  3087. flex-shrink: 0;
  3088. }
  3089. `)
  3090. }
  3091. }
  3092. if (config.disableTweetTextFormatting) {
  3093. cssRules.push(`
  3094. div[data-testid="tweetText"] span {
  3095. font-style: normal;
  3096. font-weight: normal;
  3097. }
  3098. `)
  3099. }
  3100. if (config.dropdownMenuFontWeight) {
  3101. cssRules.push(`
  3102. [data-testid="${desktop ? 'Dropdown' : 'sheetDialog'}"] [role="menuitem"] [dir] {
  3103. font-weight: normal;
  3104. }
  3105. `)
  3106. }
  3107. if (config.hideBookmarkButton) {
  3108. // Under timeline tweets
  3109. hideCssSelectors.push(
  3110. 'body:not(.Bookmarks) [data-testid="tweet"][tabindex="0"] [role="group"] > div:has(> button[data-testid$="ookmark"])',
  3111. )
  3112. if (!config.showBookmarkButtonUnderFocusedTweets) {
  3113. // Under the focused tweet
  3114. hideCssSelectors.push(
  3115. '[data-testid="tweet"][tabindex="-1"] [role="group"][id^="id__"] > div:has(> button[data-testid$="ookmark"])',
  3116. )
  3117. }
  3118. }
  3119. if (config.hideListsNav) {
  3120. hideCssSelectors.push(`${menuRole} a[href$="/lists"]`)
  3121. }
  3122. if (config.hideBookmarksNav) {
  3123. hideCssSelectors.push(`${menuRole} a[href$="/bookmarks"]`)
  3124. }
  3125. if (config.hideCommunitiesNav) {
  3126. hideCssSelectors.push(`${menuRole} a[href$="/communities"]`)
  3127. }
  3128. if (config.hideShareTweetButton) {
  3129. hideCssSelectors.push(
  3130. // Under timeline tweets
  3131. `[data-testid="tweet"][tabindex="0"] [role="group"] > div[style]:not(${TWITTER_MEDIA_ASSIST_BUTTON_SELECTOR})`,
  3132. // Under the focused tweet
  3133. `[data-testid="tweet"][tabindex="-1"] [role="group"] > div[style]:not(${TWITTER_MEDIA_ASSIST_BUTTON_SELECTOR})`,
  3134. )
  3135. }
  3136. if (config.hideSubscriptions) {
  3137. hideCssSelectors.push(
  3138. // Subscribe buttons in profile (multiple locations)
  3139. 'body.Profile [role="button"][style*="border-color: rgb(201, 54, 204)"]',
  3140. // Subscriptions count in profile
  3141. 'body.Profile a[href$="/creator-subscriptions/subscriptions"]',
  3142. // Subs tab in profile
  3143. 'body.Profile .SubsTab',
  3144. // Subscribe button in focused tweet
  3145. '[data-testid="tweet"][tabindex="-1"] [data-testid$="-subscribe"]',
  3146. // "Subscribe to" dropdown item (desktop)
  3147. '[data-testid="Dropdown"] > [data-testid="subscribe"]',
  3148. // "Subscribe to" menu item (mobile)
  3149. '[data-testid="sheetDialog"] > [data-testid="subscribe"]',
  3150. // "Subscriber" indicator in replies from subscribers
  3151. '[data-testid="tweet"] [data-testid="icon-subscriber"]',
  3152. // Monetization and Subscriptions items in Settings
  3153. 'body.Settings a[href="/settings/monetization"]',
  3154. 'body.Settings a[href="/settings/manage_subscriptions"]',
  3155. // Subscriptions tab link in Following/Follows
  3156. `body.ProfileFollows.Subscriptions ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:last-child > a`,
  3157. )
  3158. // Subscriptions tab in Following/Follows
  3159. cssRules.push(`
  3160. body.ProfileFollows.Subscriptions ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:last-child {
  3161. flex: 0;
  3162. }
  3163. `)
  3164. }
  3165. if (config.hideMetrics) {
  3166. configureHideMetricsCss(cssRules, hideCssSelectors)
  3167. }
  3168. if (config.hideCommunitiesNav) {
  3169. hideCssSelectors.push(`${menuRole} a[href$="/communities"]`)
  3170. }
  3171. if (config.hideGrokNav) {
  3172. hideCssSelectors.push(
  3173. // In menus
  3174. `${menuRole} a[href$="/i/grok"]`,
  3175. // Under timeline tweets
  3176. `[data-testid="tweet"][tabindex="0"] [role="group"] > div:has(> button[aria-label="${getString('GROK_ACTIONS')}"])`,
  3177. // Under the focused tweet
  3178. `[data-testid="tweet"][tabindex="-1"] [role="group"][id^="id__"] > div:has(> button[aria-label="${getString('GROK_ACTIONS')}"])`,
  3179. )
  3180. }
  3181. if (config.hideMonetizationNav) {
  3182. hideCssSelectors.push(`${menuRole} a[href$="/i/monetization"]`)
  3183. }
  3184. if (config.hideAdsNav) {
  3185. hideCssSelectors.push(`${menuRole} a:is([href*="ads.twitter.com"], [href*="ads.x.com"])`)
  3186. }
  3187. if (config.hideJobsNav) {
  3188. hideCssSelectors.push(
  3189. // Jobs navigation item
  3190. `${menuRole} a[href="/jobs"]`,
  3191. // Jobs section in profiles
  3192. '.Profile [data-testid="jobs"]',
  3193. )
  3194. }
  3195. if (config.hideTweetAnalyticsLinks) {
  3196. hideCssSelectors.push('a[data-testid="analyticsButton"]')
  3197. }
  3198. if (config.hideTwitterBlueUpsells) {
  3199. hideCssSelectors.push(
  3200. // Premium/Verified menu items
  3201. `${menuRole} a:is([href^="/i/premium"], [href^="/i/verified"])`,
  3202. // Analytics menu item
  3203. `${menuRole} a[href="/i/account_analytics"]`,
  3204. // "Highlight on your profile" on your tweets
  3205. '[role="menuitem"][data-testid="highlightUpsell"]',
  3206. // "Edit with Premium" on recent tweets
  3207. '[role="menuitem"][data-testid="editWithTwitterBlue"]',
  3208. // Premium item in Settings
  3209. 'body.Settings a[href^="/i/premium"]',
  3210. // "Highlight your best content instead" on the pin modal
  3211. '.PinModal [data-testid="sheetDialog"] > div > div:last-child > div > div > div:first-child',
  3212. // Highlight button on the pin modal
  3213. '.PinModal [data-testid="sheetDialog"] [role="button"]:first-child:nth-last-child(3)',
  3214. // Misc upsells in your own profile
  3215. `.OwnProfile ${Selectors.PRIMARY_COLUMN} a[href^="/i/premium"]`,
  3216. // Unlock Analytics button in your own profile
  3217. '.OwnProfile [data-testid="analytics-preview"]',
  3218. )
  3219. // Hide Highlights and Articles tabs in your own profile if you don't have Premium
  3220. let profileTabsList = `body.OwnProfile:not(.PremiumProfile) ${Selectors.PRIMARY_COLUMN} nav div[role="tablist"]`
  3221. let upsellTabLinks = 'a:is([href$="/highlights"], [href$="/articles"])'
  3222. cssRules.push(`
  3223. ${profileTabsList} > div:has(> ${upsellTabLinks}) {
  3224. flex: 0;
  3225. }
  3226. ${profileTabsList} > div > ${upsellTabLinks} {
  3227. display: none;
  3228. }
  3229. `)
  3230. // Hide upsell on the Likes tab in your own profile
  3231. cssRules.push(`
  3232. body.OwnProfile ${Selectors.PRIMARY_COLUMN} nav + div:has(a[href^="/i/premium"]) {
  3233. display: none;
  3234. }
  3235. `)
  3236. // Allow Pin and Cancel buttons go to max-width on the pin modal
  3237. cssRules.push(`
  3238. .PinModal [data-testid="sheetDialog"] > div > div:last-child > div > div {
  3239. width: 100%;
  3240. margin-top: 0;
  3241. padding-left: 32px;
  3242. padding-right: 32px;
  3243. }
  3244. `)
  3245. }
  3246. if (config.hideVerifiedNotificationsTab) {
  3247. cssRules.push(`
  3248. body.Notifications ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:nth-child(2),
  3249. body.ProfileFollows ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:nth-child(1) {
  3250. flex: 0;
  3251. }
  3252. body.Notifications ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:nth-child(2) > a,
  3253. body.ProfileFollows ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:nth-child(1) > a {
  3254. display: none;
  3255. }
  3256. `)
  3257. }
  3258. if (config.hideViews) {
  3259. hideCssSelectors.push(
  3260. // "Views" under the focused tweet
  3261. '[data-testid="tweet"][tabindex="-1"] div[dir] + div[aria-hidden="true"]:nth-child(2):nth-last-child(2)',
  3262. '[data-testid="tweet"][tabindex="-1"] div[dir] + div[aria-hidden="true"]:nth-child(2):nth-last-child(2) + div[dir]:last-child'
  3263. )
  3264. }
  3265. if (config.hideWhoToFollowEtc) {
  3266. hideCssSelectors.push(`body.Profile ${Selectors.PRIMARY_COLUMN} aside[role="complementary"]`)
  3267. }
  3268. if (config.reducedInteractionMode) {
  3269. hideCssSelectors.push(
  3270. '[data-testid="tweet"] [role="group"]',
  3271. 'body.Tweet [data-testid="tweet"] + div > div [role="group"]',
  3272. )
  3273. }
  3274. if (config.restoreLinkHeadlines) {
  3275. hideCssSelectors.push(
  3276. // Existing headline overlaid on the card
  3277. '.tnt_overlay_headline',
  3278. // From <domain> link after the card
  3279. 'div[data-testid="card.wrapper"] + a',
  3280. )
  3281. } else {
  3282. hideCssSelectors.push('.tnt_link_headline')
  3283. }
  3284. if (config.restoreQuoteTweetsLink || config.restoreOtherInteractionLinks) {
  3285. cssRules.push(`
  3286. #tntInteractionLinks a {
  3287. text-decoration: none;
  3288. color: var(--color);
  3289. }
  3290. #tntInteractionLinks a:hover span:last-child {
  3291. text-decoration: underline;
  3292. }
  3293. #tntQuoteTweetCount {
  3294. margin-right: 2px;
  3295. font-weight: 700;
  3296. color: var(--color-emphasis);
  3297. }
  3298. /* Replaces the "View post engagements" link under your own tweets */
  3299. a[data-testid="analyticsButton"] {
  3300. display: none;
  3301. }
  3302. `)
  3303. } else {
  3304. hideCssSelectors.push('#tntInteractionLinks')
  3305. }
  3306. if (!config.restoreQuoteTweetsLink) {
  3307. hideCssSelectors.push('#tntQuoteTweetsLink')
  3308. }
  3309. if (!config.restoreOtherInteractionLinks) {
  3310. hideCssSelectors.push('#tntRetweetsLink', '#tntLikesLink')
  3311. }
  3312. if (config.tweakQuoteTweetsPage) {
  3313. // Hide the quoted tweet, which is repeated in every quote tweet
  3314. hideCssSelectors.push('body.QuoteTweets [data-testid="tweet"] [aria-labelledby] > div:last-child')
  3315. }
  3316. if (config.twitterBlueChecks == 'hide') {
  3317. hideCssSelectors.push('.tnt_blue_check')
  3318. }
  3319. if (config.twitterBlueChecks == 'replace') {
  3320. cssRules.push(`
  3321. :is(${Selectors.VERIFIED_TICK}, svg[data-testid="verificationBadge"]).tnt_blue_check path {
  3322. d: path("${Svgs.BLUE_LOGO_PATH}");
  3323. }
  3324. `)
  3325. }
  3326.  
  3327. if (shouldShowSeparatedTweetsTab()) {
  3328. cssRules.push(`
  3329. body.Default {
  3330. --tab-hover: rgba(15, 20, 25, 0.1);
  3331. }
  3332. body.Dim {
  3333. --tab-hover: rgba(247, 249, 249, 0.1);
  3334. }
  3335. body.LightsOut {
  3336. --tab-hover: rgba(231, 233, 234, 0.1);
  3337. }
  3338.  
  3339. /* Tabbed timeline */
  3340. body.Desktop #tnt_separated_tweets_tab:hover,
  3341. body.Mobile:not(.SeparatedTweets) #tnt_separated_tweets_tab:hover,
  3342. body.Mobile #tnt_separated_tweets_tab:active {
  3343. background-color: var(--tab-hover);
  3344. }
  3345. body:not(.SeparatedTweets) #tnt_separated_tweets_tab > a > div > div,
  3346. body.HomeTimeline.SeparatedTweets ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav div[role="tablist"] > div:not(#tnt_separated_tweets_tab) > a > div > div {
  3347. font-weight: normal !important;
  3348. color: var(--color) !important;
  3349. }
  3350. body.SeparatedTweets #tnt_separated_tweets_tab > a > div > div {
  3351. font-weight: bold;
  3352. color: var(--color-emphasis); !important;
  3353. }
  3354. body:not(.SeparatedTweets) #tnt_separated_tweets_tab > a > div > div > div,
  3355. 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 {
  3356. height: 0 !important;
  3357. }
  3358. body.SeparatedTweets #tnt_separated_tweets_tab > a > div > div > div {
  3359. height: 4px !important;
  3360. min-width: 56px;
  3361. width: 100%;
  3362. position: absolute;
  3363. bottom: 0;
  3364. border-radius: 9999px;
  3365. }
  3366. `)
  3367. }
  3368.  
  3369. //#region Desktop-only
  3370. if (desktop) {
  3371. if (config.navDensity == 'comfortable' || config.navDensity == 'compact') {
  3372. cssRules.push(`
  3373. header nav > a,
  3374. header nav > div[data-testid="AppTabBar_More_Menu"] {
  3375. padding-top: 0 !important;
  3376. padding-bottom: 0 !important;
  3377. }
  3378. `)
  3379. }
  3380. if (config.navDensity == 'compact') {
  3381. cssRules.push(`
  3382. header nav > a > div,
  3383. header nav > div[data-testid="AppTabBar_More_Menu"] > div {
  3384. padding-top: 6px !important;
  3385. padding-bottom: 6px !important;
  3386. }
  3387. `)
  3388. }
  3389. if (config.hideSeeNewTweets) {
  3390. hideCssSelectors.push(`body.HomeTimeline ${Selectors.PRIMARY_COLUMN} > div > div:first-child > div[style^="transform"]`)
  3391. }
  3392. if (config.hideTimelineTweetBox) {
  3393. hideCssSelectors.push(`body.HomeTimeline ${Selectors.PRIMARY_COLUMN} > div > div:nth-child(3)`)
  3394. }
  3395. if (config.disableHomeTimeline) {
  3396. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_DESKTOP} a[href="/home"]`)
  3397. }
  3398. if (config.fullWidthContent) {
  3399. cssRules.push(`
  3400. /* Use full width when the sidebar is visible */
  3401. body.Sidebar${FULL_WIDTH_BODY_PSEUDO} ${Selectors.PRIMARY_COLUMN},
  3402. body.Sidebar${FULL_WIDTH_BODY_PSEUDO} ${Selectors.PRIMARY_COLUMN} > div:first-child > div:last-child {
  3403. max-width: 990px;
  3404. }
  3405. /* Make the "What's happening" input keep its original width */
  3406. body.HomeTimeline ${Selectors.PRIMARY_COLUMN} > div:first-child > div:nth-of-type(3) div[role="progressbar"] + div {
  3407. max-width: 598px;
  3408. }
  3409. /* Use full width when the sidebar is not visible */
  3410. body:not(.Sidebar)${FULL_WIDTH_BODY_PSEUDO} header[role="banner"] {
  3411. flex-grow: 0;
  3412. }
  3413. body:not(.Sidebar)${FULL_WIDTH_BODY_PSEUDO} main[role="main"] > div {
  3414. width: 100%;
  3415. }
  3416. body:not(.Sidebar)${FULL_WIDTH_BODY_PSEUDO} ${Selectors.PRIMARY_COLUMN} {
  3417. max-width: unset;
  3418. width: 100%;
  3419. }
  3420. body:not(.Sidebar)${FULL_WIDTH_BODY_PSEUDO} ${Selectors.PRIMARY_COLUMN} > div:first-child > div:first-child div,
  3421. body:not(.Sidebar)${FULL_WIDTH_BODY_PSEUDO} ${Selectors.PRIMARY_COLUMN} > div:first-child > div:last-child {
  3422. max-width: unset;
  3423. }
  3424. `)
  3425. if (!config.fullWidthMedia) {
  3426. // Make media & cards keep their original width
  3427. cssRules.push(`
  3428. 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) {
  3429. max-width: 504px;
  3430. }
  3431. `)
  3432. }
  3433. // Hide the sidebar when present
  3434. hideCssSelectors.push(`body.Sidebar${FULL_WIDTH_BODY_PSEUDO} ${Selectors.SIDEBAR}`)
  3435. }
  3436. if (config.hideAccountSwitcher) {
  3437. cssRules.push(`
  3438. header[role="banner"] > div > div > div > div:last-child {
  3439. flex-shrink: 1 !important;
  3440. align-items: flex-end !important;
  3441. }
  3442. `)
  3443. hideCssSelectors.push(
  3444. '[data-testid="SideNav_AccountSwitcher_Button"] > div:first-child:not(:only-child)',
  3445. '[data-testid="SideNav_AccountSwitcher_Button"] > div:first-child + div',
  3446. )
  3447. }
  3448. if (config.hideExplorePageContents) {
  3449. hideCssSelectors.push(
  3450. // Tabs
  3451. `body.Explore ${Selectors.DESKTOP_TIMELINE_HEADER} nav`,
  3452. // Content
  3453. `body.Explore ${Selectors.TIMELINE}`,
  3454. )
  3455. }
  3456. if (config.hideGrokNav) {
  3457. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_DESKTOP} a[href$="/i/grok"]`)
  3458. }
  3459. if (config.hideJobsNav) {
  3460. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_DESKTOP} a[href="/jobs"]`)
  3461. }
  3462. if (config.hideListsNav) {
  3463. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_DESKTOP} a[href$="/lists"]`)
  3464. }
  3465. if (config.hideProNav) {
  3466. hideCssSelectors.push(`${menuRole} a:is([href*="pro.twitter.com"], [href*="pro.x.com"])`)
  3467. }
  3468. if (config.hideSpacesNav) {
  3469. hideCssSelectors.push(`${menuRole} a[href="/i/spaces/start"]`)
  3470. }
  3471. if (config.hideTwitterBlueUpsells) {
  3472. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_DESKTOP} a:is([href^="/i/premium"], [href^="/i/verified"])`)
  3473. }
  3474. if (config.hideSidebarContent) {
  3475. // Only show the first sidebar item by default
  3476. // Re-show subsequent non-algorithmic sections on specific pages
  3477. cssRules.push(`
  3478. ${Selectors.SIDEBAR_WRAPPERS} > div:not(:first-of-type) {
  3479. display: none;
  3480. }
  3481. body.Search ${Selectors.SIDEBAR_WRAPPERS} > div:nth-of-type(2) {
  3482. display: block;
  3483. }
  3484. `)
  3485. if (config.showRelevantPeople) {
  3486. cssRules.push(`
  3487. body.Tweet ${Selectors.SIDEBAR_WRAPPERS} > div:is(:nth-of-type(2), :nth-of-type(3)) {
  3488. display: block;
  3489. }
  3490. `)
  3491. }
  3492. hideCssSelectors.push(`body.HideSidebar ${Selectors.SIDEBAR}`)
  3493. } else if (config.hideTwitterBlueUpsells) {
  3494. // Hide "Subscribe to premium" individually
  3495. hideCssSelectors.push(
  3496. `body.HomeTimeline ${Selectors.SIDEBAR_WRAPPERS} > div:nth-of-type(3)`
  3497. )
  3498. }
  3499. if (config.hideShareTweetButton) {
  3500. hideCssSelectors.push(
  3501. // In media modal
  3502. `[aria-modal="true"] div > div:first-of-type [role="group"] > div[style]:not([role]):not(${TWITTER_MEDIA_ASSIST_BUTTON_SELECTOR})`,
  3503. )
  3504. }
  3505. if (config.hideExploreNav) {
  3506. // When configured, hide Explore only when the sidebar is showing, or
  3507. // when on a page full-width content is enabled on.
  3508. let bodySelector = `${config.hideExploreNavWithSidebar ? `body.Sidebar${config.fullWidthContent ? `:not(${FULL_WIDTH_BODY_PSEUDO})` : ''} ` : ''}`
  3509. hideCssSelectors.push(`${bodySelector}${Selectors.PRIMARY_NAV_DESKTOP} a[href="/explore"]`)
  3510. }
  3511. if (config.hideBookmarksNav) {
  3512. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_DESKTOP} a[href="/i/bookmarks"]`)
  3513. }
  3514. if (config.hideCommunitiesNav) {
  3515. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_DESKTOP} a[href$="/communities"]`)
  3516. }
  3517. if (config.hideMessagesDrawer) {
  3518. cssRules.push(`${Selectors.MESSAGES_DRAWER} { visibility: hidden; }`)
  3519. }
  3520. if (config.hideViews) {
  3521. hideCssSelectors.push(
  3522. // Under timeline tweets
  3523. '[data-testid="tweet"][tabindex="0"] [role="group"] > div:has(> a[href$="/analytics"])',
  3524. // In media modal
  3525. '[aria-modal="true"] > div > div:first-of-type [role="group"] > div:has(> a[href$="/analytics"])',
  3526. )
  3527. }
  3528. if (config.retweets != 'separate' && config.quoteTweets != 'separate') {
  3529. hideCssSelectors.push('#tnt_separated_tweets_tab')
  3530. }
  3531. }
  3532. //#endregion
  3533.  
  3534. //#region Mobile only
  3535. if (mobile) {
  3536. if (config.disableHomeTimeline) {
  3537. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_MOBILE} a[href="/home"]`)
  3538. }
  3539. if (config.hideSeeNewTweets) {
  3540. hideCssSelectors.push(`body.HomeTimeline ${Selectors.MOBILE_TIMELINE_HEADER} ~ div[style^="transform"]:last-child`)
  3541. }
  3542. if (config.hideExplorePageContents) {
  3543. // Hide explore page contents so we don't get a brief flash of them
  3544. // before automatically switching the page to search mode.
  3545. hideCssSelectors.push(
  3546. // Tabs
  3547. `body.Explore ${Selectors.MOBILE_TIMELINE_HEADER} > div > div:nth-of-type(2)`,
  3548. // Content
  3549. `body.Explore ${Selectors.TIMELINE}`,
  3550. )
  3551. }
  3552. if (config.hideGrokNav) {
  3553. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_MOBILE} a[href="/i/grok"]`)
  3554. }
  3555. if (config.hideCommunitiesNav) {
  3556. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_MOBILE} a[href$="/communities"]`)
  3557. }
  3558. if (config.hideMessagesBottomNavItem) {
  3559. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_MOBILE} a[href="/messages"]`)
  3560. }
  3561. if (config.hideJobsNav) {
  3562. hideCssSelectors.push(`${Selectors.PRIMARY_NAV_MOBILE} a[href="/jobs"]`)
  3563. }
  3564. if (config.hideTwitterBlueUpsells) {
  3565. hideCssSelectors.push(
  3566. `${Selectors.PRIMARY_NAV_MOBILE} a[href^="/i/premium"]`,
  3567. `${Selectors.MOBILE_TIMELINE_HEADER} a[href^="/i/premium"]`,
  3568. )
  3569. }
  3570. if (config.hideShareTweetButton) {
  3571. hideCssSelectors.push(
  3572. // In media modal
  3573. `body.MobileMedia [role="group"] > div[style]:not(${TWITTER_MEDIA_ASSIST_BUTTON_SELECTOR})`,
  3574. )
  3575. }
  3576. if (config.hideViews) {
  3577. hideCssSelectors.push(
  3578. // Under timeline tweets
  3579. '[data-testid="tweet"][tabindex="0"] [role="group"] > div:has(> a[href$="/analytics"])',
  3580. // In media modal
  3581. 'body.MobileMedia [role="group"] > div:has(> a[href$="/analytics"])',
  3582. )
  3583. }
  3584. //#endregion
  3585. }
  3586.  
  3587. if (hideCssSelectors.length > 0) {
  3588. cssRules.push(`
  3589. ${hideCssSelectors.join(',\n')} {
  3590. display: none !important;
  3591. }
  3592. `)
  3593. }
  3594.  
  3595. $style.textContent = cssRules.map(dedent).join('\n')
  3596. }
  3597. })()
  3598.  
  3599. function configureFont() {
  3600. if (!fontFamilyRule) {
  3601. warn('no fontFamilyRule found for configureFont to use')
  3602. return
  3603. }
  3604.  
  3605. if (config.dontUseChirpFont) {
  3606. if (fontFamilyRule.style.fontFamily.includes('TwitterChirp')) {
  3607. fontFamilyRule.style.fontFamily = fontFamilyRule.style.fontFamily.replace(/"?TwitterChirp"?, ?/, '')
  3608. log('disabled Chirp font')
  3609. }
  3610. } else if (!fontFamilyRule.style.fontFamily.includes('TwitterChirp')) {
  3611. fontFamilyRule.style.fontFamily = `"TwitterChirp", ${fontFamilyRule.style.fontFamily}`
  3612. log(`enabled Chirp font`)
  3613. }
  3614. }
  3615.  
  3616. /**
  3617. * @param {string[]} cssRules
  3618. * @param {string[]} hideCssSelectors
  3619. */
  3620. function configureHideMetricsCss(cssRules, hideCssSelectors) {
  3621. if (config.hideFollowingMetrics) {
  3622. // User profile hover card and page metrics
  3623. hideCssSelectors.push(
  3624. ':is(#layers, body.Profile) a:is([href$="/following"], [href$="/verified_followers"]) > span:first-child'
  3625. )
  3626. // Fix display of whitespace after hidden metrics
  3627. cssRules.push(
  3628. ':is(#layers, body.Profile) a:is([href$="/following"], [href$="/verified_followers"]) { white-space: pre-line; }'
  3629. )
  3630. }
  3631.  
  3632. if (config.hideTotalTweetsMetrics) {
  3633. // Tweet count under username header on profile pages
  3634. hideCssSelectors.push(`
  3635. body.Profile ${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} > div > div:first-of-type h2 + div[dir]
  3636. `)
  3637. }
  3638.  
  3639. let timelineMetricSelectors = [
  3640. config.hideReplyMetrics && '[data-testid="reply"]',
  3641. config.hideRetweetMetrics && '[data-testid$="retweet"]',
  3642. config.hideLikeMetrics && '[data-testid$="like"]',
  3643. config.hideBookmarkMetrics && '[data-testid$="bookmark"], [data-testid$="removeBookmark"]',
  3644. ].filter(Boolean).join(', ')
  3645.  
  3646. if (timelineMetricSelectors) {
  3647. cssRules.push(
  3648. `[role="group"] button:is(${timelineMetricSelectors}) span { visibility: hidden; }`
  3649. )
  3650. }
  3651.  
  3652. if (config.hideQuoteTweetMetrics) {
  3653. hideCssSelectors.push('#tntQuoteTweetCount')
  3654. }
  3655. }
  3656.  
  3657. /**
  3658. * CSS which depends on anything we need to get from the page.
  3659. */
  3660. const configureDynamicCss = (() => {
  3661. let $style
  3662.  
  3663. return function configureDynamicCss() {
  3664. $style ??= addStyle('dynamic')
  3665. let cssRules = []
  3666.  
  3667. if (fontSize != null && config.navBaseFontSize) {
  3668. cssRules.push(`
  3669. ${Selectors.PRIMARY_NAV_DESKTOP} div[dir] span { font-size: ${fontSize}; font-weight: normal; }
  3670. ${Selectors.PRIMARY_NAV_DESKTOP} div[dir] { margin-top: -4px; }
  3671. `)
  3672. }
  3673.  
  3674. if (filterBlurRule != null && config.unblurSensitiveContent) {
  3675. cssRules.push(`
  3676. ${filterBlurRule.selectorText} {
  3677. filter: none !important;
  3678. }
  3679. ${filterBlurRule.selectorText} + div {
  3680. display: none !important;
  3681. }
  3682. `)
  3683. }
  3684.  
  3685. $style.textContent = cssRules.map(dedent).join('\n')
  3686. }
  3687. })()
  3688. //#endregion
  3689.  
  3690. /**
  3691. * Configures – or re-configures – the separated tweets timeline title.
  3692. *
  3693. * If we're currently on the separated tweets timeline and…
  3694. * - …its title has changed, the page title will be changed to "navigate" to it.
  3695. * - …the separated tweets timeline is no longer needed, we'll change the page
  3696. * title to "navigate" back to the Home timeline.
  3697. *
  3698. * @returns {boolean} `true` if "navigation" was triggered by this call
  3699. */
  3700. function configureSeparatedTweetsTimelineTitle() {
  3701. let wasOnSeparatedTweetsTimeline = isOnSeparatedTweetsTimeline()
  3702. let previousTitle = separatedTweetsTimelineTitle
  3703.  
  3704. if (config.retweets == 'separate' && config.quoteTweets == 'separate') {
  3705. separatedTweetsTimelineTitle = getString(config.replaceLogo ? 'SHARED_TWEETS' : 'SHARED')
  3706. } else if (config.retweets == 'separate') {
  3707. separatedTweetsTimelineTitle = getString(config.replaceLogo ? 'RETWEETS' : 'REPOSTS')
  3708. } else if (config.quoteTweets == 'separate') {
  3709. separatedTweetsTimelineTitle = getString(config.replaceLogo ? 'QUOTE_TWEETS' : 'QUOTES')
  3710. } else {
  3711. separatedTweetsTimelineTitle = null
  3712. }
  3713.  
  3714. let titleChanged = previousTitle != separatedTweetsTimelineTitle
  3715. if (wasOnSeparatedTweetsTimeline) {
  3716. if (separatedTweetsTimelineTitle == null) {
  3717. log('moving from separated tweets timeline to Home timeline after config change')
  3718. setTitle(getString('HOME'))
  3719. return true
  3720. }
  3721. if (titleChanged) {
  3722. log('applying new separated tweets timeline title after config change')
  3723. setTitle(separatedTweetsTimelineTitle)
  3724. return true
  3725. }
  3726. } else {
  3727. if (titleChanged && previousTitle != null && lastHomeTimelineTitle == previousTitle) {
  3728. log('updating lastHomeTimelineTitle with new separated tweets timeline title')
  3729. lastHomeTimelineTitle = separatedTweetsTimelineTitle
  3730. }
  3731. }
  3732. }
  3733.  
  3734. const configureThemeCss = (() => {
  3735. let $style
  3736.  
  3737. return function configureThemeCss() {
  3738. $style ??= addStyle('theme')
  3739. let cssRules = []
  3740.  
  3741. if (debug) {
  3742. cssRules.push(`
  3743. [data-item-type]::after {
  3744. position: absolute;
  3745. top: 0;
  3746. ${ltr ? 'right': 'left'}: 50px;
  3747. content: attr(data-item-type);
  3748. font-family: ${fontFamilyRule?.style.fontFamily || '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial'};
  3749. background-color: rgb(242, 29, 29);
  3750. color: white;
  3751. font-size: 11px;
  3752. font-weight: bold;
  3753. padding: 4px 6px;
  3754. border-bottom-left-radius: 1em;
  3755. border-bottom-right-radius: 1em;
  3756. }
  3757. `)
  3758. }
  3759.  
  3760. // Active tab colour for custom tabs
  3761. if (themeColor != null && shouldShowSeparatedTweetsTab()) {
  3762. cssRules.push(`
  3763. body.SeparatedTweets #tnt_separated_tweets_tab > a > div > div > div {
  3764. background-color: ${themeColor} !important;
  3765. }
  3766. `)
  3767. }
  3768.  
  3769. if (config.replaceLogo) {
  3770. cssRules.push(`
  3771. ${Selectors.X_LOGO_PATH} {
  3772. fill: ${THEME_BLUE};
  3773. d: path("${Svgs.TWITTER_LOGO_PATH}");
  3774. }
  3775. .tnt_logo {
  3776. fill: ${THEME_BLUE};
  3777. }
  3778. svg path[d="${Svgs.X_HOME_ACTIVE_PATH}"] {
  3779. d: path("${Svgs.TWITTER_HOME_ACTIVE_PATH}");
  3780. }
  3781. svg path[d="${Svgs.X_HOME_INACTIVE_PATH}"] {
  3782. d: path("${Svgs.TWITTER_HOME_INACTIVE_PATH}");
  3783. }
  3784. `)
  3785. }
  3786.  
  3787. if (config.uninvertFollowButtons) {
  3788. // Shared styles for Following and Follow buttons
  3789. cssRules.push(`
  3790. [role="button"][data-testid$="-unfollow"]:not(:hover) {
  3791. border-color: rgba(0, 0, 0, 0) !important;
  3792. }
  3793. [role="button"][data-testid$="-follow"] {
  3794. background-color: rgba(0, 0, 0, 0) !important;
  3795. }
  3796. `)
  3797. if (config.followButtonStyle == 'monochrome' || themeColor == null) {
  3798. cssRules.push(`
  3799. /* Following button */
  3800. body.Default [role="button"][data-testid$="-unfollow"]:not(:hover) {
  3801. background-color: rgb(15, 20, 25) !important;
  3802. }
  3803. body.Default [role="button"][data-testid$="-unfollow"]:not(:hover) > :is(div, span) {
  3804. color: rgb(255, 255, 255) !important;
  3805. }
  3806. body:is(.Dim, .LightsOut) [role="button"][data-testid$="-unfollow"]:not(:hover) {
  3807. background-color: rgb(255, 255, 255) !important;
  3808. }
  3809. body:is(.Dim, .LightsOut) [role="button"][data-testid$="-unfollow"]:not(:hover) > :is(div, span) {
  3810. color: rgb(15, 20, 25) !important;
  3811. }
  3812. /* Follow button */
  3813. body.Default [role="button"][data-testid$="-follow"] {
  3814. border-color: rgb(207, 217, 222) !important;
  3815. }
  3816. body:is(.Dim, .LightsOut) [role="button"][data-testid$="-follow"] {
  3817. border-color: rgb(83, 100, 113) !important;
  3818. }
  3819. body.Default [role="button"][data-testid$="-follow"] > :is(div, span) {
  3820. color: rgb(15, 20, 25) !important;
  3821. }
  3822. body:is(.Dim, .LightsOut) [role="button"][data-testid$="-follow"] > :is(div, span) {
  3823. color: rgb(255, 255, 255) !important;
  3824. }
  3825. body.Default [role="button"][data-testid$="-follow"]:hover {
  3826. background-color: rgba(15, 20, 25, 0.1) !important;
  3827. }
  3828. body:is(.Dim, .LightsOut) [role="button"][data-testid$="-follow"]:hover {
  3829. background-color: rgba(255, 255, 255, 0.1) !important;
  3830. }
  3831. `)
  3832. }
  3833. if (config.followButtonStyle == 'themed' && themeColor != null) {
  3834. cssRules.push(`
  3835. /* Following button */
  3836. [role="button"][data-testid$="-unfollow"]:not(:hover) {
  3837. background-color: ${themeColor} !important;
  3838. }
  3839. [role="button"][data-testid$="-unfollow"]:not(:hover) > :is(div, span) {
  3840. color: rgb(255, 255, 255) !important;
  3841. }
  3842. /* Follow button */
  3843. [role="button"][data-testid$="-follow"] {
  3844. border-color: ${themeColor} !important;
  3845. }
  3846. [role="button"][data-testid$="-follow"] > :is(div, span) {
  3847. color: ${themeColor} !important;
  3848. }
  3849. [role="button"][data-testid$="-follow"]:hover {
  3850. background-color: ${themeColor} !important;
  3851. }
  3852. [role="button"][data-testid$="-follow"]:hover > :is(div, span) {
  3853. color: rgb(255, 255, 255) !important;
  3854. }
  3855. `)
  3856. }
  3857. if (mobile) {
  3858. cssRules.push(`
  3859. body.MediaViewer [role="button"][data-testid$="follow"]:not(:hover) {
  3860. border: revert !important;
  3861. background-color: transparent !important;
  3862. }
  3863. body.MediaViewer [role="button"][data-testid$="follow"]:not(:hover) > div {
  3864. color: ${themeColor} !important;
  3865. }
  3866. `)
  3867. }
  3868. }
  3869.  
  3870. $style.textContent = cssRules.map(dedent).join('\n')
  3871. }
  3872. })()
  3873.  
  3874. async function setDefaultSortReplies() {
  3875. if (config.sortReplies == 'relevant') return
  3876.  
  3877. let $sortRepliesIconPath = await getElement(Selectors.SORT_REPLIES_PATH, {
  3878. name: 'sort replies icon',
  3879. stopIf: pageIsNot(currentPage),
  3880. timeout: 3000,
  3881. })
  3882. if (!$sortRepliesIconPath) return
  3883.  
  3884. let $svg = $sortRepliesIconPath.parentElement.parentElement
  3885. let currentSort = $svg.nextElementSibling?.textContent
  3886. log('sortReplies: replies are sorted by', currentSort)
  3887. if (currentSort != getString('MOST_RELEVANT')) return
  3888.  
  3889. function changeSort() {
  3890. if (changingSortReplies) {
  3891. warn('sortReplies: ignoring additonal changeSort() call')
  3892. return
  3893. }
  3894. changingSortReplies = true
  3895. log('sortReplies: clicking Sort replies dropdown', $svg.parentElement.parentElement)
  3896. setTimeout(() => $svg.parentElement.parentElement.click(), 100)
  3897. }
  3898.  
  3899. let $focusedTweet = $svg.closest('div[data-testid="cellInnerDiv"]')
  3900. if ($focusedTweet.parentElement.childElementCount > 1) {
  3901. changeSort()
  3902. return
  3903. }
  3904.  
  3905. pageObservers.push(
  3906. observeElement($focusedTweet.parentElement, () => {
  3907. if ($focusedTweet.parentElement.childElementCount > 2) {
  3908. log('sortReplies: timeline elements added')
  3909. disconnectPageObserver('sortReplies: individual tweet timeline')
  3910. changeSort()
  3911. }
  3912. }, 'sortReplies: individual tweet timeline')
  3913. )
  3914. }
  3915.  
  3916. /**
  3917. * @param {HTMLElement} $tweet
  3918. * @param {?{getText?: boolean}} options
  3919. * @returns {import("./types").QuotedTweet}
  3920. */
  3921. function getQuotedTweetDetails($tweet, options = {}) {
  3922. let {getText = false} = options
  3923. let $quotedByLink = /** @type {HTMLAnchorElement} */ ($tweet.querySelector('[data-testid="User-Name"] a'))
  3924. let $quotedTweet = $tweet.querySelector('div[id^="id__"] > div[dir] > span').parentElement.nextElementSibling
  3925. let $userName = $quotedTweet?.querySelector('[data-testid="User-Name"]')
  3926. let quotedBy = $quotedByLink?.pathname?.substring(1)
  3927. let user = $userName?.querySelector('[tabindex="-1"]')?.textContent
  3928. let time = $userName?.querySelector('time')?.dateTime
  3929. if (!getText) return {quotedBy, user, time}
  3930.  
  3931. let $heading = $quotedTweet?.querySelector(':scope > div > div:first-child')
  3932. let $qtText = $heading?.nextElementSibling?.querySelector('[lang]')
  3933. let text = $qtText && Array.from($qtText.childNodes, node => {
  3934. if (node.nodeType == 1) {
  3935. if (node.nodeName == 'IMG') return node.alt
  3936. return node.textContent
  3937. }
  3938. return node.nodeValue
  3939. }).join('')
  3940. return {quotedBy, user, time, text}
  3941. }
  3942.  
  3943. /**
  3944. * Attempts to determine the type of a timeline Tweet given the element with
  3945. * data-testid="tweet" on it, falling back to TWEET if it doesn't appear to be
  3946. * one of the particular types we care about.
  3947. * @param {HTMLElement} $tweet
  3948. * @param {?boolean} checkSocialContext
  3949. * @returns {import("./types").TweetType}
  3950. */
  3951. function getTweetType($tweet, checkSocialContext = false) {
  3952. if ($tweet.closest(Selectors.PROMOTED_TWEET_CONTAINER)) {
  3953. return 'PROMOTED_TWEET'
  3954. }
  3955. // Assume social context tweets are Retweets
  3956. if ($tweet.querySelector('[data-testid="socialContext"]')) {
  3957. if (checkSocialContext) {
  3958. let svgPath = $tweet.querySelector('svg path')?.getAttribute('d') ?? ''
  3959. if (svgPath.startsWith('M7 4.5C7 3.12 8.12 2 9.5 2h5C1')) return 'PINNED_TWEET'
  3960. }
  3961. // Quoted tweets from accounts you blocked or muted are displayed as an
  3962. // <article> with "This Tweet is unavailable."
  3963. if ($tweet.querySelector('article')) {
  3964. return 'UNAVAILABLE_RETWEET'
  3965. }
  3966. // Quoted tweets are preceded by visually-hidden "Quote" text
  3967. if ($tweet.querySelector('div[id^="id__"] > div[dir] > span')?.textContent.includes(getString('QUOTE'))) {
  3968. return 'RETWEETED_QUOTE_TWEET'
  3969. }
  3970. return 'RETWEET'
  3971. }
  3972. // Quoted tweets are preceded by visually-hidden "Quote" text
  3973. if ($tweet.querySelector('div[id^="id__"] > div[dir] > span')?.textContent.includes(getString('QUOTE'))) {
  3974. return 'QUOTE_TWEET'
  3975. }
  3976. // Quoted tweets from accounts you blocked or muted are displayed as an
  3977. // <article> with "This Tweet is unavailable."
  3978. if ($tweet.querySelector('article')) {
  3979. return 'UNAVAILABLE_QUOTE_TWEET'
  3980. }
  3981. return 'TWEET'
  3982. }
  3983.  
  3984. // Add 1 every time this gets broken: 6
  3985. function getVerifiedProps($svg) {
  3986. let propsGetter = (props) => props?.children?.props?.children?.[0]?.[0]?.props
  3987. let $parent = $svg.parentElement.parentElement
  3988. // Verified badge button on the profile screen
  3989. if (isOnProfilePage() && $svg.parentElement.getAttribute('role') == 'button') {
  3990. $parent = $svg.closest('span').parentElement
  3991. }
  3992. // Link variant in "user followed/liked/retweeted" notifications
  3993. else if (isOnNotificationsPage() && $parent.getAttribute('role') == 'link') {
  3994. propsGetter = (props) => {
  3995. let linkChildren = props?.children?.props?.children?.[0]
  3996. return linkChildren?.[linkChildren.length - 1]?.props
  3997. }
  3998. }
  3999. if ($parent.wrappedJSObject) {
  4000. $parent = $parent.wrappedJSObject
  4001. }
  4002. let reactPropsKey = Object.keys($parent).find(key => key.startsWith('__reactProps$'))
  4003. let props = propsGetter($parent[reactPropsKey])
  4004. if (!props) {
  4005. warn('React props not found for', $svg)
  4006. }
  4007. else if (!('isBlueVerified' in props)) {
  4008. warn('isBlueVerified not in React props for', $svg, {props})
  4009. }
  4010. return props
  4011. }
  4012.  
  4013. /**
  4014. * @param {HTMLElement} $popup
  4015. * @returns {{tookAction: boolean, onPopupClosed?: () => void}}
  4016. */
  4017. function handlePopup($popup) {
  4018. let result = {tookAction: false, onPopupClosed: null}
  4019.  
  4020. if (changingSortReplies) {
  4021. let $dialog = /** @type {HTMLElement} */ ($popup.querySelector(`[data-testid="${desktop ? 'HoverCard' : 'sheetDialog'}"]`))
  4022. if ($dialog) {
  4023. let $menuItems = /** @type {NodeListOf<HTMLElement>} */ ($dialog.querySelectorAll('div[role="menuitem"]'))
  4024. if ($menuItems[0].previousElementSibling?.textContent == getString('SORT_REPLIES')) {
  4025. log('sortReplies: changing Sort replies to', config.sortReplies)
  4026. $menuItems[{recent: 1, liked: 2}[config.sortReplies]]?.click()
  4027. } else {
  4028. warn('sortReplies: dialog does not contain "Sort replies" heading')
  4029. }
  4030. result.tookAction = true
  4031. changingSortReplies = false
  4032. return result
  4033. } else {
  4034. warn('sortReplies: could not find Sort replies dialog')
  4035. changingSortReplies = false
  4036. }
  4037. }
  4038.  
  4039. if (desktop && !isDesktopComposeTweetModalOpen && location.pathname.startsWith(PagePaths.COMPOSE_TWEET)) {
  4040. log('compose tweet modal opened')
  4041. isDesktopComposeTweetModalOpen = true
  4042. observeDesktopComposeTweetModal($popup)
  4043. return {
  4044. tookAction: true,
  4045. onPopupClosed() {
  4046. log('compose tweet modal closed')
  4047. isDesktopComposeTweetModalOpen = false
  4048. // The Tweet button will re-render if the modal was opened to edit
  4049. // multiple Tweets on the Home timeline.
  4050. if (config.replaceLogo && isOnHomeTimelinePage()) {
  4051. tweakTweetButton()
  4052. }
  4053. }
  4054. }
  4055. }
  4056.  
  4057. if (desktop && !isDesktopMediaModalOpen && URL_MEDIA_RE.test(location.pathname) && currentPath != location.pathname) {
  4058. log('media modal opened')
  4059. isDesktopMediaModalOpen = true
  4060. observeDesktopModalTimeline($popup)
  4061. return {
  4062. tookAction: true,
  4063. onPopupClosed() {
  4064. log('media modal closed')
  4065. isDesktopMediaModalOpen = false
  4066. disconnectAllModalObservers()
  4067. }
  4068. }
  4069. }
  4070.  
  4071. if (config.replaceLogo) {
  4072. let $retweetDropdownItem = $popup.querySelector('div:is([data-testid="retweetConfirm"], [data-testid="repostConfirm"])')
  4073. if ($retweetDropdownItem) {
  4074. tweakRetweetDropdown($retweetDropdownItem, 'div:is([data-testid="retweetConfirm"], [data-testid="repostConfirm"])', 'RETWEET')
  4075. return {tookAction: true}
  4076. }
  4077.  
  4078. let $unretweetDropdownItem = $popup.querySelector('div:is([data-testid="unretweetConfirm"], [data-testid="unrepostConfirm"])')
  4079. if ($unretweetDropdownItem) {
  4080. tweakRetweetDropdown($unretweetDropdownItem, 'div:is([data-testid="unretweetConfirm"], [data-testid="unrepostConfirm"])', 'UNDO_RETWEET')
  4081. return {tookAction: true}
  4082. }
  4083.  
  4084. let $hoverLabel = $popup.querySelector('span[data-testid="HoverLabel"] > span')
  4085. if ($hoverLabel?.textContent == getString('REPOST')) {
  4086. $hoverLabel.textContent = getString('RETWEET')
  4087. }
  4088. }
  4089.  
  4090. if (isOnListPage()) {
  4091. let $switchSvg = $popup.querySelector(`svg path[d="M3 2h18.61l-3.5 7 3.5 7H5v6H3V2zm2 12h13.38l-2.5-5 2.5-5H5v10z"]`)
  4092. if ($switchSvg) {
  4093. addToggleListRetweetsMenuItem($popup.querySelector(`[role="menuitem"]`))
  4094. return {tookAction: true}
  4095. }
  4096. }
  4097.  
  4098. if (config.mutableQuoteTweets) {
  4099. if (quotedTweet) {
  4100. let $blockMenuItem = /** @type {HTMLElement} */ ($popup.querySelector(Selectors.BLOCK_MENU_ITEM))
  4101. if ($blockMenuItem) {
  4102. addMuteQuotesMenuItems($blockMenuItem)
  4103. result.tookAction = true
  4104. // Clear the quoted tweet when the popup closes
  4105. result.onPopupClosed = () => {
  4106. quotedTweet = null
  4107. }
  4108. } else {
  4109. quotedTweet = null
  4110. }
  4111. }
  4112. }
  4113.  
  4114. if (config.fastBlock) {
  4115. if (blockMenuItemSeen && $popup.querySelector('[data-testid="confirmationSheetConfirm"]')) {
  4116. log('fast blocking')
  4117. ;/** @type {HTMLElement} */ ($popup.querySelector('[data-testid="confirmationSheetConfirm"]')).click()
  4118. result.tookAction = true
  4119. }
  4120. else if ($popup.querySelector(Selectors.BLOCK_MENU_ITEM)) {
  4121. log('preparing for fast blocking')
  4122. blockMenuItemSeen = true
  4123. // Create a nested observer for mobile, as it reuses the popup element
  4124. result.tookAction = !mobile
  4125. } else {
  4126. blockMenuItemSeen = false
  4127. }
  4128. }
  4129.  
  4130. if (config.hideTwitterBlueUpsells) {
  4131. // The "Pin to your profile" menu item is currently the only one which opens
  4132. // a sheet dialog.
  4133. if (pinMenuItemSeen && $popup.querySelector('[data-testid="sheetDialog"]')) {
  4134. log('pin to your profile modal opened')
  4135. $popup.classList.add('PinModal')
  4136. result.tookAction = true
  4137. }
  4138. else if ($popup.querySelector('[data-testid="highlighOnPin"]')) {
  4139. log('preparing to hide Twitter Blue upsell when pinning a tweet')
  4140. pinMenuItemSeen = true
  4141. // Create a nested observer for mobile, as it reuses the popup element
  4142. result.tookAction = !mobile
  4143. } else {
  4144. pinMenuItemSeen = false
  4145. }
  4146. }
  4147.  
  4148. if (config.addAddMutedWordMenuItem) {
  4149. let linkSelector = 'a[href$="/settings"]'
  4150. let $link = /** @type {HTMLElement} */ ($popup.querySelector(linkSelector))
  4151. if ($link) {
  4152. addAddMutedWordMenuItem($link, linkSelector)
  4153. result.tookAction = true
  4154. }
  4155. }
  4156.  
  4157. if (config.twitterBlueChecks != 'ignore') {
  4158. // User typeahead dropdown
  4159. let $typeaheadDropdown = /** @type {HTMLElement} */ ($popup.querySelector('div[id^="typeaheadDropdown"]'))
  4160. if ($typeaheadDropdown) {
  4161. log('typeahead dropdown appeared')
  4162. let observer = observeElement($typeaheadDropdown, () => {
  4163. processBlueChecks($typeaheadDropdown)
  4164. }, 'popup typeahead dropdown')
  4165. return {
  4166. tookAction: true,
  4167. onPopupClosed() {
  4168. log('typeahead dropdown closed')
  4169. observer.disconnect()
  4170. }
  4171. }
  4172. }
  4173.  
  4174. // User hovercard popup
  4175. let $hoverCard = /** @type {HTMLElement} */ ($popup.querySelector('[data-testid="HoverCard"]'))
  4176. if ($hoverCard) {
  4177. result.tookAction = true
  4178. getElement('div[data-testid^="UserAvatar-Container"]', {
  4179. context: $hoverCard,
  4180. name: 'user hovercard contents',
  4181. timeout: 500,
  4182. }).then(($contents) => {
  4183. if ($contents) processBlueChecks($popup)
  4184. })
  4185. }
  4186. }
  4187.  
  4188. // Verified account popup when you press the check button on a profile page
  4189. if (config.twitterBlueChecks == 'replace' && isOnProfilePage()) {
  4190. if (mobile) {
  4191. let $verificationBadge = /** @type {HTMLElement} */ ($popup.querySelector('[data-testid="sheetDialog"] [data-testid="verificationBadge"]'))
  4192. if ($verificationBadge) {
  4193. result.tookAction = true
  4194. let $headerBlueCheck = document.querySelector(`body.Profile ${Selectors.MOBILE_TIMELINE_HEADER} .tnt_blue_check`)
  4195. if ($headerBlueCheck) {
  4196. blueCheck($verificationBadge)
  4197. }
  4198. }
  4199. } else {
  4200. let $hoverCard = /** @type {HTMLElement} */ ($popup.querySelector('[data-testid="HoverCard"]'))
  4201. if ($hoverCard) {
  4202. result.tookAction = true
  4203. getElement(':scope > div > div > div > svg[data-testid="verificationBadge"]', {
  4204. context: $hoverCard,
  4205. name: 'verified account hovercard verification badge',
  4206. timeout: 500,
  4207. }).then(($verificationBadge) => {
  4208. if (!$verificationBadge) return
  4209.  
  4210. let $headerBlueCheck = document.querySelector(`body.Profile ${Selectors.PRIMARY_COLUMN} > div > div:first-of-type h2 .tnt_blue_check`)
  4211. if (!$headerBlueCheck) return
  4212.  
  4213. // Wait for the hovercard to render its contents
  4214. let popupRenderObserver = observeElement($popup, (mutations) => {
  4215. if (!mutations.length) return
  4216. blueCheck($popup.querySelector('svg[data-testid="verificationBadge"]'))
  4217. popupRenderObserver.disconnect()
  4218. }, 'verified popup render', {childList: true, subtree: true})
  4219. })
  4220. }
  4221. }
  4222. }
  4223.  
  4224. return result
  4225. }
  4226.  
  4227. function isBlueVerified($svg) {
  4228. let props = getVerifiedProps($svg)
  4229. return Boolean(props && props.isBlueVerified && !(
  4230. props.verifiedType || (
  4231. props.affiliateBadgeInfo?.userLabelType == 'BusinessLabel' &&
  4232. props.affiliateBadgeInfo?.description == 'X'
  4233. )
  4234. ))
  4235. }
  4236.  
  4237. /**
  4238. * @returns {import("./types").VerifiedType}
  4239. */
  4240. function getVerifiedType($svg) {
  4241. let props = getVerifiedProps($svg)
  4242. if (props) {
  4243. if (props.affiliateBadgeInfo?.userLabelType == 'BusinessLabel' &&
  4244. props.affiliateBadgeInfo?.description == 'X')
  4245. // Ignore Twitter associated checks
  4246. return null
  4247. if (props.verifiedType == 'Business')
  4248. return 'VERIFIED_ORG'
  4249. if (props.isBlueVerified)
  4250. return 'BLUE'
  4251. }
  4252. return null
  4253. }
  4254.  
  4255. /**
  4256. * Checks if a tweet is preceded by an element creating a vertical reply line.
  4257. * @param {HTMLElement} $tweet
  4258. * @returns {boolean}
  4259. */
  4260. function isReplyToPreviousTweet($tweet) {
  4261. let $replyLine = $tweet.firstElementChild?.firstElementChild?.firstElementChild?.firstElementChild?.firstElementChild?.firstElementChild
  4262. if ($replyLine) {
  4263. return getComputedStyle($replyLine).width == '2px'
  4264. }
  4265. }
  4266.  
  4267. /**
  4268. * @returns {{disconnect()}}
  4269. */
  4270. function onPopup($popup) {
  4271. log('popup appeared', $popup, location.pathname)
  4272.  
  4273. // If handlePopup did something, we don't need to observe nested popups
  4274. let {tookAction, onPopupClosed} = handlePopup($popup)
  4275. if (tookAction) {
  4276. return onPopupClosed ? {disconnect: onPopupClosed} : null
  4277. }
  4278.  
  4279. /** @type {HTMLElement} */
  4280. let $nestedPopup
  4281.  
  4282. let nestedObserver = observeElement($popup, (mutations) => {
  4283. mutations.forEach((mutation) => {
  4284. mutation.addedNodes.forEach((/** @type {HTMLElement} */ $el) => {
  4285. log('nested popup appeared', $el)
  4286. $nestedPopup = $el
  4287. ;({onPopupClosed} = handlePopup($el))
  4288. })
  4289. mutation.removedNodes.forEach((/** @type {HTMLElement} */ $el) => {
  4290. if ($el !== $nestedPopup) return
  4291. if (onPopupClosed) {
  4292. log('cleaning up after nested popup removed')
  4293. onPopupClosed()
  4294. }
  4295. })
  4296. })
  4297. }, 'nested popup observer')
  4298.  
  4299. let disconnect = nestedObserver.disconnect.bind(nestedObserver)
  4300. nestedObserver.disconnect = () => {
  4301. if (onPopupClosed) {
  4302. log('cleaning up after nested popup observer disconnected')
  4303. onPopupClosed()
  4304. }
  4305. disconnect()
  4306. }
  4307.  
  4308. return nestedObserver
  4309. }
  4310.  
  4311. /**
  4312. * @param {HTMLElement} $timeline
  4313. * @param {string} page
  4314. * @param {import("./types").TimelineOptions?} options
  4315. */
  4316. function onTimelineChange($timeline, page, options = {}) {
  4317. let startTime = Date.now()
  4318. let {classifyTweets = true, hideHeadings = true, isUserTimeline = false} = options
  4319.  
  4320. let isOnHomeTimeline = isOnHomeTimelinePage()
  4321. let isOnListTimeline = isOnListPage()
  4322. let isOnProfileTimeline = isOnProfilePage()
  4323. let timelineHasSpecificHandling = isOnHomeTimeline || isOnListTimeline || isOnProfileTimeline
  4324.  
  4325. if (config.twitterBlueChecks != 'ignore' && (isUserTimeline || !timelineHasSpecificHandling)) {
  4326. processBlueChecks($timeline)
  4327. }
  4328.  
  4329. if (isSafari && config.replaceLogo && isOnNotificationsPage()) {
  4330. processTwitterLogos($timeline)
  4331. }
  4332.  
  4333. if (isUserTimeline || !classifyTweets) return
  4334.  
  4335. let itemTypes = {}
  4336. let hiddenItemCount = 0
  4337. let hiddenItemTypes = {}
  4338.  
  4339. /** @type {?boolean} */
  4340. let hidPreviousItem = null
  4341. /** @type {{$item: Element, hideItem?: boolean}[]} */
  4342. let changes = []
  4343.  
  4344. for (let $item of $timeline.children) {
  4345. /** @type {?import("./types").TimelineItemType} */
  4346. let itemType = null
  4347. /** @type {?boolean} */
  4348. let hideItem = null
  4349. /** @type {?HTMLElement} */
  4350. let $tweet = $item.querySelector(Selectors.TWEET)
  4351. /** @type {boolean} */
  4352. let isReply = false
  4353. /** @type {boolean} */
  4354. let isBlueTweet = false
  4355.  
  4356. if ($tweet != null) {
  4357. itemType = getTweetType($tweet, isOnProfileTimeline)
  4358. if (timelineHasSpecificHandling) {
  4359. isReply = isReplyToPreviousTweet($tweet)
  4360. if (isReply && hidPreviousItem != null) {
  4361. hideItem = hidPreviousItem
  4362. } else {
  4363. if (isOnHomeTimeline) {
  4364. hideItem = shouldHideHomeTimelineItem(itemType, page)
  4365. if (config.mutableQuoteTweets && !hideItem && itemType == 'QUOTE_TWEET' && config.hideQuotesFrom.length > 0) {
  4366. let $quotedByLink = /** @type {HTMLAnchorElement} */ ($tweet.querySelector('[data-testid="User-Name"] a'))
  4367. let quotedBy = $quotedByLink?.pathname.substring(1)
  4368. if (quotedBy) {
  4369. hideItem = config.hideQuotesFrom.includes(quotedBy)
  4370. } else {
  4371. warn('hideQuotesFrom: unable to get quote tweet user')
  4372. }
  4373. }
  4374. }
  4375. else if (isOnListTimeline) {
  4376. hideItem = shouldHideListTimelineItem(itemType)
  4377. }
  4378. else if (isOnProfileTimeline) {
  4379. hideItem = shouldHideProfileTimelineItem(itemType)
  4380. }
  4381. }
  4382.  
  4383. if (!hideItem && config.mutableQuoteTweets && (itemType == 'QUOTE_TWEET' || itemType == 'RETWEETED_QUOTE_TWEET')) {
  4384. if (config.mutedQuotes.length > 0) {
  4385. let quotedTweet = getQuotedTweetDetails($tweet)
  4386. hideItem = config.mutedQuotes.some(muted => muted.user == quotedTweet.user && muted.time == quotedTweet.time)
  4387. }
  4388. if (!hideItem) {
  4389. addCaretMenuListenerForQuoteTweet($tweet)
  4390. }
  4391. }
  4392.  
  4393. if (config.twitterBlueChecks != 'ignore') {
  4394. for (let $svg of $tweet.querySelectorAll(Selectors.VERIFIED_TICK)) {
  4395. let isBlueCheck = isBlueVerified($svg)
  4396. if (!isBlueCheck) continue
  4397.  
  4398. blueCheck($svg)
  4399.  
  4400. // Don't count a tweet as blue if the check is in a quoted tweet
  4401. let userProfileLink = $svg.closest('a[role="link"]:not([href^="/i/status"])')
  4402. if (!userProfileLink) continue
  4403.  
  4404. isBlueTweet = true
  4405. }
  4406. }
  4407. }
  4408.  
  4409. if (!hideItem && config.restoreLinkHeadlines) {
  4410. restoreLinkHeadline($tweet)
  4411. }
  4412. }
  4413. else if (!timelineHasSpecificHandling) {
  4414. if ($item.querySelector(':scope > div > div > div > article')) {
  4415. itemType = 'UNAVAILABLE'
  4416. }
  4417. }
  4418.  
  4419. if (!timelineHasSpecificHandling) {
  4420. if (itemType != null) {
  4421. hideItem = shouldHideOtherTimelineItem(itemType)
  4422. }
  4423. }
  4424.  
  4425. // Special handling for non-Tweet timeline items
  4426. if (itemType == null) {
  4427. if ($item.querySelector('[data-testid="inlinePrompt"]')) {
  4428. itemType = 'INLINE_PROMPT'
  4429. hideItem = config.hideInlinePrompts || (
  4430. config.hideTwitterBlueUpsells && Boolean($item.querySelector('a[href^="/i/premium"]')) ||
  4431. config.hideMonetizationNav && Boolean($item.querySelector('a[href="/settings/monetization"]'))
  4432. )
  4433. } else if ($item.querySelector(Selectors.TIMELINE_HEADING)) {
  4434. itemType = 'HEADING'
  4435. hideItem = hideHeadings && config.hideWhoToFollowEtc
  4436. }
  4437. }
  4438.  
  4439. if (debug && itemType != null) {
  4440. $item.firstElementChild.dataset.itemType = `${itemType}${isReply ? ' / REPLY' : ''}${isBlueTweet ? ' / BLUE' : ''}`
  4441. }
  4442.  
  4443. // Assume a non-identified item following an identified item is related
  4444. if (itemType == null && hidPreviousItem != null) {
  4445. hideItem = hidPreviousItem
  4446. itemType = 'SUBSEQUENT_ITEM'
  4447. }
  4448.  
  4449. if (itemType != null) {
  4450. itemTypes[itemType] ||= 0
  4451. itemTypes[itemType]++
  4452. }
  4453.  
  4454. if (hideItem) {
  4455. hiddenItemCount++
  4456. hiddenItemTypes[itemType] ||= 0
  4457. hiddenItemTypes[itemType]++
  4458. }
  4459.  
  4460. if (hideItem != null && $item.firstElementChild) {
  4461. if (/** @type {HTMLElement} */ ($item.firstElementChild).style.display != (hideItem ? 'none' : '')) {
  4462. changes.push({$item, hideItem})
  4463. }
  4464. }
  4465.  
  4466. hidPreviousItem = hideItem
  4467. }
  4468.  
  4469. for (let change of changes) {
  4470. /** @type {HTMLElement} */ (change.$item.firstElementChild).style.display = change.hideItem ? 'none' : ''
  4471. }
  4472.  
  4473. log(
  4474. `processed ${$timeline.children.length} timeline item${s($timeline.children.length)} in ${Date.now() - startTime}ms`,
  4475. itemTypes, `hid ${hiddenItemCount}`, hiddenItemTypes
  4476. )
  4477. }
  4478.  
  4479. /**
  4480. * @param {HTMLElement} $timeline
  4481. * @param {import("./types").IndividualTweetTimelineOptions} options
  4482. */
  4483. function onIndividualTweetTimelineChange($timeline, options) {
  4484. let startTime = Date.now()
  4485.  
  4486. let itemTypes = {}
  4487. let hiddenItemCount = 0
  4488. let hiddenItemTypes = {}
  4489.  
  4490. /** @type {?boolean} */
  4491. let hidPreviousItem = null
  4492. /** @type {boolean} */
  4493. let hideAllSubsequentItems = false
  4494. /** @type {string} */
  4495. let opScreenName = /^\/([a-zA-Z\d_]{1,20})\//.exec(location.pathname)[1].toLowerCase()
  4496. /** @type {{$item: Element, hideItem?: boolean}[]} */
  4497. let changes = []
  4498. /** @type {import("./types").UserInfoObject} */
  4499. let userInfo = getUserInfo()
  4500. /** @type {?HTMLElement} */
  4501. let $focusedTweet
  4502.  
  4503. for (let $item of $timeline.children) {
  4504. /** @type {?import("./types").TimelineItemType} */
  4505. let itemType = null
  4506. /** @type {?boolean} */
  4507. let hideItem = null
  4508. /** @type {?HTMLElement} */
  4509. let $tweet = $item.querySelector(Selectors.TWEET)
  4510. /** @type {boolean} */
  4511. let isFocusedTweet = false
  4512. /** @type {boolean} */
  4513. let isReply = false
  4514. /** @type {import("./types").VerifiedType} */
  4515. let tweetVerifiedType = null
  4516. /** @type {?string} */
  4517. let screenName = null
  4518.  
  4519. if (hideAllSubsequentItems) {
  4520. hideItem = true
  4521. itemType = 'DISCOVER_MORE_TWEET'
  4522. }
  4523. else if ($tweet != null) {
  4524. isFocusedTweet = $tweet.tabIndex == -1
  4525. isReply = isReplyToPreviousTweet($tweet)
  4526. if (isFocusedTweet) {
  4527. itemType = 'FOCUSED_TWEET'
  4528. hideItem = false
  4529. $focusedTweet = $tweet
  4530. } else {
  4531. itemType = getTweetType($tweet)
  4532. if (isReply && hidPreviousItem != null) {
  4533. hideItem = hidPreviousItem
  4534. } else {
  4535. hideItem = shouldHideIndividualTweetTimelineItem(itemType)
  4536. }
  4537. }
  4538.  
  4539. if (!hideItem && config.restoreLinkHeadlines) {
  4540. restoreLinkHeadline($tweet)
  4541. }
  4542.  
  4543. if (!hideItem && (config.twitterBlueChecks != 'ignore' || config.hideTwitterBlueReplies)) {
  4544. for (let $svg of $tweet.querySelectorAll(Selectors.VERIFIED_TICK)) {
  4545. let verifiedType = getVerifiedType($svg)
  4546. if (!verifiedType) continue
  4547.  
  4548. if (config.twitterBlueChecks != 'ignore' && verifiedType == 'BLUE') {
  4549. blueCheck($svg)
  4550. }
  4551.  
  4552. // Don't count a tweet as verified if the check is in a quoted tweet
  4553. let $userProfileLink = /** @type {HTMLAnchorElement} */ ($svg.closest('a[role="link"]:not([href^="/i/status"])'))
  4554. if (!$userProfileLink) continue
  4555.  
  4556. tweetVerifiedType = verifiedType
  4557. screenName = $userProfileLink.href.split('/').pop()
  4558. }
  4559.  
  4560. // Replies to the focused tweet don't have the reply indicator
  4561. if (tweetVerifiedType && !isFocusedTweet && !isReply && screenName.toLowerCase() != opScreenName) {
  4562. itemType = `${tweetVerifiedType}_REPLY`
  4563. if (!hideItem) {
  4564. let user = userInfo[screenName]
  4565. let shouldHideBasedOnVerifiedType = config.hideTwitterBlueReplies && (
  4566. tweetVerifiedType == 'BLUE' ||
  4567. tweetVerifiedType == 'VERIFIED_ORG' && !config.showBlueReplyVerifiedAccounts
  4568. )
  4569. hideItem = shouldHideBasedOnVerifiedType && (user == null || !(
  4570. user.following && !config.hideBlueReplyFollowing ||
  4571. user.followedBy && !config.hideBlueReplyFollowedBy ||
  4572. config.showBlueReplyFollowersCount && user.followersCount >= Number(config.showBlueReplyFollowersCountAmount)
  4573. ))
  4574. }
  4575. }
  4576. }
  4577. }
  4578. else {
  4579. let $article = $item.querySelector('article')
  4580. if ($article) {
  4581. // Deleted or private, unless…
  4582. itemType = 'UNAVAILABLE'
  4583. let $button = $article.querySelector('[role="button"]')
  4584. if ($button) {
  4585. if ($button.textContent == getString('SHOW')) {
  4586. itemType = 'SHOW_MORE'
  4587. }
  4588. else if ($button.textContent == getString('VIEW')) {
  4589. // "This Tweet is from an account you (blocked|muted)." with a View button
  4590. hideItem = config.hideUnavailableQuoteTweets
  4591. }
  4592. }
  4593. else if ($article.textContent == getString('POST_UNAVAILABLE')) {
  4594. // Likely blocked or muted
  4595. hideItem = config.hideUnavailableQuoteTweets
  4596. }
  4597. } else {
  4598. // We need to identify "Show more replies" so it doesn't get hidden if the
  4599. // item immediately before it was hidden.
  4600. let $button = $item.querySelector('button[role="button"]')
  4601. if ($button) {
  4602. if ($button?.textContent == getString('SHOW_MORE_REPLIES')) {
  4603. itemType = 'SHOW_MORE'
  4604. }
  4605. } else {
  4606. let $heading = $item.querySelector(Selectors.TIMELINE_HEADING)
  4607. if ($heading) {
  4608. // Discover More headings have a description next to them
  4609. if ($heading.nextElementSibling &&
  4610. $heading.nextElementSibling.tagName == 'DIV' &&
  4611. $heading.nextElementSibling.getAttribute('dir') != null) {
  4612. itemType = 'DISCOVER_MORE_HEADING'
  4613. hideItem = config.hideMoreTweets
  4614. hideAllSubsequentItems = config.hideMoreTweets
  4615. } else {
  4616. itemType = 'HEADING'
  4617. }
  4618. }
  4619. }
  4620. }
  4621. }
  4622.  
  4623. if (debug && itemType != null) {
  4624. $item.firstElementChild.dataset.itemType = `${itemType}${isReply ? ' / REPLY' : ''}`
  4625. }
  4626.  
  4627. // Assume a non-identified item following an identified item is related
  4628. if (itemType == null && hidPreviousItem != null) {
  4629. hideItem = hidPreviousItem
  4630. itemType = 'SUBSEQUENT_ITEM'
  4631. }
  4632.  
  4633. if (itemType != null) {
  4634. itemTypes[itemType] ||= 0
  4635. itemTypes[itemType]++
  4636. }
  4637.  
  4638. if (hideItem) {
  4639. hiddenItemCount++
  4640. hiddenItemTypes[itemType] ||= 0
  4641. hiddenItemTypes[itemType]++
  4642. }
  4643.  
  4644. if (isFocusedTweet) {
  4645. // Tweets prior to the focused tweet should never be hidden
  4646. changes = []
  4647. hiddenItemCount = 0
  4648. hiddenItemTypes = {}
  4649. }
  4650. else if (hideItem != null && $item.firstElementChild) {
  4651. if (/** @type {HTMLElement} */ ($item.firstElementChild).style.display != (hideItem ? 'none' : '')) {
  4652. changes.push({$item, hideItem})
  4653. }
  4654. }
  4655.  
  4656. hidPreviousItem = hideItem
  4657. }
  4658.  
  4659. for (let change of changes) {
  4660. /** @type {HTMLElement} */ (change.$item.firstElementChild).style.display = change.hideItem ? 'none' : ''
  4661. }
  4662.  
  4663. tweakFocusedTweet($focusedTweet, options)
  4664.  
  4665. log(
  4666. `processed ${$timeline.children.length} thread item${s($timeline.children.length)} in ${Date.now() - startTime}ms`,
  4667. itemTypes, `hid ${hiddenItemCount}`, hiddenItemTypes
  4668. )
  4669. }
  4670.  
  4671. /**
  4672. * Title format (including notification count):
  4673. * - LTR: (3) ${title} / X
  4674. * - RTL: (3) X \ ${title}
  4675. * @param {string} title
  4676. */
  4677. function onTitleChange(title) {
  4678. log('title changed', {title, path: location.pathname})
  4679.  
  4680. if (checkforDisabledHomeTimeline()) return
  4681.  
  4682. // Ignore leading notification counts in titles
  4683. let notificationCount = ''
  4684. if (TITLE_NOTIFICATION_RE.test(title)) {
  4685. notificationCount = TITLE_NOTIFICATION_RE.exec(title)[0]
  4686. title = title.replace(TITLE_NOTIFICATION_RE, '')
  4687. }
  4688.  
  4689. if (config.replaceLogo && Boolean(notificationCount) != Boolean(currentNotificationCount)) {
  4690. observeFavicon.updatePip(Boolean(notificationCount))
  4691. }
  4692.  
  4693. let homeNavigationWasUsed = homeNavigationIsBeingUsed
  4694. homeNavigationIsBeingUsed = false
  4695.  
  4696. if (title == 'X' || title == getString('TWITTER')) {
  4697. // Mobile uses "Twitter" when viewing media - we need to let these process
  4698. // so the next page will be re-processed when the media is closed.
  4699. if (mobile && (URL_MEDIA_RE.test(location.pathname) || URL_MEDIAVIEWER_RE.test(location.pathname))) {
  4700. log('viewing media on mobile')
  4701. }
  4702. // Going to the root Settings page on desktop when the sidebar is hidden
  4703. // sets an empty title.
  4704. else if (desktop && location.pathname == '/settings' && currentPath != '/settings') {
  4705. log('viewing root Settings page')
  4706. }
  4707. else if (location.pathname.startsWith(PagePaths.BOOKMARKS) && !currentPath.startsWith(PagePaths.BOOKMARKS)) {
  4708. log('viewing Bookmarks page')
  4709. }
  4710. // Ignore Flash of Uninitialised Title when navigating to a page for the
  4711. // first time.
  4712. else {
  4713. log('ignoring Flash of Uninitialised Title')
  4714. return
  4715. }
  4716. }
  4717.  
  4718. // Remove " / Twitter" or "Twitter \ " from the title
  4719. let newPage = title
  4720. if (newPage != 'X' && newPage != getString('TWITTER')) {
  4721. newPage = title.slice(...ltr ? [0, title.lastIndexOf('/') - 1] : [title.indexOf('\\') + 2])
  4722. }
  4723.  
  4724. let hasDesktopModalBeenOpenedOrClosed = desktop && (
  4725. // Timeline settings dialog opened
  4726. location.pathname == PagePaths.TIMELINE_SETTINGS ||
  4727. // Timeline settings dialog closed
  4728. currentPath == PagePaths.TIMELINE_SETTINGS ||
  4729. // Media modal opened
  4730. URL_MEDIA_RE.test(location.pathname) ||
  4731. // Media modal closed
  4732. URL_MEDIA_RE.test(currentPath) ||
  4733. // "Send via Direct Message" dialog opened
  4734. location.pathname == PagePaths.COMPOSE_MESSAGE ||
  4735. // "Send via Direct Message" dialog closed
  4736. currentPath == PagePaths.COMPOSE_MESSAGE ||
  4737. // Compose Tweet dialog opened
  4738. location.pathname == PagePaths.COMPOSE_TWEET ||
  4739. // Compose Tweet dialog closed
  4740. currentPath == PagePaths.COMPOSE_TWEET
  4741. )
  4742.  
  4743. if (newPage == currentPage) {
  4744. // XXX After initial migration to x.com, Twitter has a bug where viewing a
  4745. // user profile makes the title sticky, so we also check the pathname.
  4746. // Remove this when we can, as unexpected modals on desktop will cause
  4747. // the underlying page to be reprocessed incorrectly.
  4748. if (location.pathname != currentPath && !hasDesktopModalBeenOpenedOrClosed) {
  4749. warn('Twitter bug: title is the same but path has changed', {from: currentPath, to: location.pathname})
  4750. }
  4751. else {
  4752. log(`ignoring duplicate title change`)
  4753. currentNotificationCount = notificationCount
  4754. return
  4755. }
  4756. }
  4757.  
  4758. // Search terms are shown in the title
  4759. if (currentPath == PagePaths.SEARCH && location.pathname == PagePaths.SEARCH) {
  4760. log('ignoring title change on Search page')
  4761. currentNotificationCount = notificationCount
  4762. return
  4763. }
  4764.  
  4765. // On desktop, stay on the separated tweets timeline when…
  4766. if (desktop && currentPage == separatedTweetsTimelineTitle &&
  4767. // …the title has changed back to the Home timeline…
  4768. (newPage == getString('HOME')) &&
  4769. // …the Home nav link or Following / Home header _wasn't_ clicked and…
  4770. !homeNavigationWasUsed &&
  4771. (
  4772. // …a modal which changes the pathname has been opened or closed.
  4773. hasDesktopModalBeenOpenedOrClosed ||
  4774. // …the notification count in the title changed.
  4775. notificationCount != currentNotificationCount
  4776. )) {
  4777. log('ignoring title change on separated tweets timeline')
  4778. currentNotificationCount = notificationCount
  4779. currentPath = location.pathname
  4780. setTitle(separatedTweetsTimelineTitle)
  4781. return
  4782. }
  4783.  
  4784. // Restore display of the separated tweets timelne if it's the last one we
  4785. // saw, and the user navigated back home without using the Home navigation
  4786. // item.
  4787. if (location.pathname == PagePaths.HOME &&
  4788. currentPath != PagePaths.HOME &&
  4789. !homeNavigationWasUsed &&
  4790. lastHomeTimelineTitle != null &&
  4791. separatedTweetsTimelineTitle != null &&
  4792. lastHomeTimelineTitle == separatedTweetsTimelineTitle) {
  4793. log('restoring display of the separated tweets timeline')
  4794. currentNotificationCount = notificationCount
  4795. currentPath = location.pathname
  4796. setTitle(separatedTweetsTimelineTitle)
  4797. return
  4798. }
  4799.  
  4800. // Assumption: all non-FOUT, non-duplicate title changes are navigation, which
  4801. // need the page to be re-processed.
  4802.  
  4803. currentPage = newPage
  4804. currentNotificationCount = notificationCount
  4805. currentPath = location.pathname
  4806.  
  4807. if (isOnHomeTimelinePage()) {
  4808. lastHomeTimelineTitle = currentPage
  4809. }
  4810.  
  4811. log('processing new page')
  4812.  
  4813. processCurrentPage()
  4814. }
  4815.  
  4816. /**
  4817. * Processes all Twitter Blue checks inside an element.
  4818. * @param {HTMLElement} $el
  4819. */
  4820. function processBlueChecks($el) {
  4821. for (let $svg of $el.querySelectorAll(`${Selectors.VERIFIED_TICK}:not(.tnt_blue_check)`)) {
  4822. if (isBlueVerified($svg)) {
  4823. blueCheck($svg)
  4824. }
  4825. }
  4826. }
  4827.  
  4828. /**
  4829. * Processes all Twitter logos inside an element.
  4830. */
  4831. function processTwitterLogos($el) {
  4832. for (let $svgPath of $el.querySelectorAll(Selectors.X_LOGO_PATH)) {
  4833. twitterLogo($svgPath)
  4834. }
  4835. }
  4836.  
  4837. function processCurrentPage() {
  4838. if (pageObservers.length > 0) {
  4839. log(
  4840. `disconnecting ${pageObservers.length} page observer${s(pageObservers.length)}`,
  4841. pageObservers.map(observer => observer['name'])
  4842. )
  4843. pageObservers.forEach(observer => observer.disconnect())
  4844. pageObservers = []
  4845. }
  4846.  
  4847. // Hooks for styling pages
  4848. $body.classList.toggle('Bookmarks', isOnBookmarksPage())
  4849. $body.classList.toggle('Community', isOnCommunityPage())
  4850. $body.classList.toggle('Explore', isOnExplorePage())
  4851. $body.classList.toggle('HideSidebar', shouldHideSidebar())
  4852. $body.classList.toggle('List', isOnListPage())
  4853. $body.classList.toggle('HomeTimeline', isOnHomeTimelinePage())
  4854. $body.classList.toggle('Notifications', isOnNotificationsPage())
  4855. $body.classList.toggle('Profile', isOnProfilePage())
  4856. if (!isOnProfilePage()) {
  4857. $body.classList.remove('OwnProfile', 'PremiumProfile')
  4858. }
  4859. $body.classList.toggle('ProfileFollows', isOnFollowListPage())
  4860. if (!isOnFollowListPage()) {
  4861. $body.classList.remove('Subscriptions')
  4862. }
  4863. $body.classList.toggle('QuoteTweets', isOnQuoteTweetsPage())
  4864. $body.classList.toggle('Tweet', isOnIndividualTweetPage())
  4865. $body.classList.toggle('Search', isOnSearchPage())
  4866. $body.classList.toggle('Settings', isOnSettingsPage())
  4867. $body.classList.toggle('MobileMedia', mobile && URL_MEDIA_RE.test(location.pathname))
  4868. $body.classList.toggle('MediaViewer', mobile && URL_MEDIAVIEWER_RE.test(location.pathname))
  4869. $body.classList.remove('SeparatedTweets')
  4870.  
  4871. if (desktop) {
  4872. let shouldObserveSidebarForConfig = (
  4873. config.twitterBlueChecks != 'ignore' ||
  4874. config.fullWidthContent ||
  4875. config.hideExploreNav && config.hideExploreNavWithSidebar
  4876. )
  4877. if (shouldObserveSidebarForConfig && !isOnMessagesPage() && !isOnSettingsPage()) {
  4878. observeSidebar()
  4879. } else {
  4880. $body.classList.remove('Sidebar')
  4881. }
  4882. if (isSafari && config.replaceLogo) {
  4883. tweakDesktopLogo()
  4884. }
  4885. }
  4886.  
  4887. if (isSafari && config.replaceLogo) {
  4888. tweakHomeIcon()
  4889. }
  4890.  
  4891. if (config.twitterBlueChecks != 'ignore' && (isOnSearchPage() || isOnExplorePage())) {
  4892. observeSearchForm()
  4893. }
  4894.  
  4895. if (isOnHomeTimelinePage()) {
  4896. tweakHomeTimelinePage()
  4897. }
  4898. else {
  4899. removeMobileTimelineHeaderElements()
  4900. }
  4901.  
  4902. if (isOnProfilePage()) {
  4903. tweakProfilePage()
  4904. }
  4905. else if (isOnFollowListPage()) {
  4906. tweakFollowListPage()
  4907. }
  4908. else if (isOnIndividualTweetPage()) {
  4909. tweakIndividualTweetPage()
  4910. }
  4911. else if (isOnNotificationsPage()) {
  4912. tweakNotificationsPage()
  4913. }
  4914. else if (isOnSearchPage()) {
  4915. tweakSearchPage()
  4916. }
  4917. else if (URL_TWEET_ENGAGEMENT_RE.test(currentPath)) {
  4918. tweakTweetEngagementPage()
  4919. }
  4920. else if (isOnListPage()) {
  4921. tweakListPage()
  4922. }
  4923. else if (isOnExplorePage()) {
  4924. tweakExplorePage()
  4925. }
  4926. else if (isOnBookmarksPage()) {
  4927. tweakBookmarksPage()
  4928. }
  4929. else if (isOnCommunitiesPage()) {
  4930. tweakCommunitiesPage()
  4931. }
  4932. else if (isOnCommunityPage()) {
  4933. tweakCommunityPage()
  4934. }
  4935. else if (isOnCommunityMembersPage()) {
  4936. tweakCommunityMembersPage()
  4937. }
  4938. else if (isOnDisplaySettingsPage()) {
  4939. tweakDisplaySettingsPage()
  4940. }
  4941.  
  4942. // On mobile, these are pages instead of modals
  4943. if (mobile) {
  4944. if (currentPath == PagePaths.COMPOSE_TWEET) {
  4945. tweakMobileComposeTweetPage()
  4946. }
  4947. else if (URL_MEDIAVIEWER_RE.test(currentPath)) {
  4948. tweakMobileMediaViewerPage()
  4949. }
  4950. }
  4951. }
  4952.  
  4953. /**
  4954. * The mobile version of Twitter reuses heading elements between screens, so we
  4955. * always remove any elements which could be there from the previous page and
  4956. * re-add them later when needed.
  4957. */
  4958. function removeMobileTimelineHeaderElements() {
  4959. if (mobile) {
  4960. document.querySelector('#tnt_separated_tweets_tab')?.remove()
  4961. }
  4962. }
  4963.  
  4964. /**
  4965. * @param {HTMLElement} $tweet
  4966. */
  4967. function restoreLinkHeadline($tweet) {
  4968. let $link = /** @type {HTMLElement} */ ($tweet.querySelector('div[data-testid="card.layoutLarge.media"] > a[rel][aria-label]'))
  4969. if ($link && !$link.dataset.headlineRestored) {
  4970. let [site, ...rest] = $link.getAttribute('aria-label').split(' ')
  4971. let headline = rest.join(' ')
  4972. $link.lastElementChild?.classList.add('tnt_overlay_headline')
  4973. $link.insertAdjacentHTML('beforeend', `<div class="tnt_link_headline ${fontFamilyRule?.selectorText?.replace('.', '') || 'tnt_font_family'}" style="border-top: 1px solid var(--border-color); padding: 14px;">
  4974. <div style="color: var(--color); margin-bottom: 2px;">${site}</div>
  4975. <div style="color: var(--color-emphasis)">${headline}</div>
  4976. </div>`)
  4977. $link.dataset.headlineRestored = 'true'
  4978. }
  4979. }
  4980.  
  4981. /**
  4982. * @param {HTMLElement} $focusedTweet
  4983. */
  4984. function restoreTweetInteractionsLinks($focusedTweet) {
  4985. if (!config.restoreQuoteTweetsLink && !config.restoreOtherInteractionLinks) return
  4986.  
  4987. let [tweetLink, tweetId] = location.pathname.match(/^\/[a-zA-Z\d_]{1,20}\/status\/(\d+)/) ?? []
  4988. let tweetInfo = getTweetInfo(tweetId)
  4989. log('focused tweet', {tweetLink, tweetId, tweetInfo})
  4990. if (!tweetInfo) return
  4991.  
  4992. let shouldDisplayLinks = (
  4993. (config.restoreQuoteTweetsLink && tweetInfo.quote_count > 0) ||
  4994. (config.restoreOtherInteractionLinks && (tweetInfo.retweet_count > 0 || tweetInfo.favorite_count > 0))
  4995. )
  4996. let $existingLinks = $focusedTweet.querySelector('#tntInteractionLinks')
  4997. if (!shouldDisplayLinks || $existingLinks) {
  4998. if (!shouldDisplayLinks) $existingLinks?.remove()
  4999. return
  5000. }
  5001.  
  5002. let $group = $focusedTweet.querySelector('[role="group"][id^="id__"]')
  5003. if (!$group) return warn('focused tweet action bar not found')
  5004.  
  5005. $group.parentElement.insertAdjacentHTML('beforebegin', `
  5006. <div id="tntInteractionLinks">
  5007. <div class="${fontFamilyRule?.selectorText?.replace('.', '') || 'tnt_font_family'}" style="padding: 16px 4px; border-top: 1px solid var(--border-color); display: flex; gap: 20px;">
  5008. ${tweetInfo.quote_count > 0 ? `<a id="tntQuoteTweetsLink" class="quoteTweets" href="${tweetLink}/quotes" dir="auto" role="link">
  5009. <span id="tntQuoteTweetCount">
  5010. ${Intl.NumberFormat(lang, {notation: tweetInfo.quote_count < 10000 ? 'standard' : 'compact', compactDisplay: 'short'}).format(tweetInfo.quote_count)}
  5011. </span>
  5012. <span>${getString(tweetInfo.quote_count == 1 ? (config.replaceLogo ? 'QUOTE_TWEET' : 'QUOTE') : (config.replaceLogo ? 'QUOTE_TWEETS' : 'QUOTES'))}</span>
  5013. </a>` : ''}
  5014. ${tweetInfo.retweet_count > 0 ? `<a id="tntRetweetsLink" data-tab="2" href="${tweetLink}/retweets" dir="auto" role="link">
  5015. <span>${getString(config.replaceLogo ? 'RETWEETS' : 'REPOSTS')}</span>
  5016. </a>` : ''}
  5017. ${tweetInfo.favorite_count > 0 ? `<a id="tntLikesLink" data-tab="3" href="${tweetLink}/likes" dir="auto" role="link">
  5018. <span>${getString('LIKES')}</span>
  5019. </a>` : ''}
  5020. </div>
  5021. </div>
  5022. `)
  5023.  
  5024. let links = /** @type {NodeListOf<HTMLAnchorElement>} */ ($focusedTweet.querySelectorAll('#tntInteractionLinks a'))
  5025. links.forEach(($link) => {
  5026. $link.addEventListener('click', async (e) => {
  5027. let $caret = /** @type {HTMLElement} */ ($focusedTweet.querySelector('[data-testid="caret"]'))
  5028. if (!$caret) return warn('focused tweet menu caret not found')
  5029.  
  5030. log('clicking "View post engagements" menu item')
  5031. e.preventDefault()
  5032. $caret.click()
  5033. let $tweetEngagements = await getElement('#layers a[data-testid="tweetEngagements"]', {
  5034. name: 'View post engagements menu item',
  5035. stopIf: pageIsNot(currentPage),
  5036. timeout: 500,
  5037. })
  5038. if ($tweetEngagements) {
  5039. tweetInteractionsTab = $link.dataset.tab || null
  5040. $tweetEngagements.click()
  5041. } else {
  5042. warn('falling back to full page refresh')
  5043. location.href = $link.href
  5044. }
  5045. })
  5046. })
  5047. }
  5048.  
  5049. /**
  5050. * Sets the page name in <title>, retaining any current notification count.
  5051. * @param {string} page
  5052. */
  5053. function setTitle(page) {
  5054. let name = config.replaceLogo ? getString('TWITTER') : 'X'
  5055. document.title = ltr ? (
  5056. `${currentNotificationCount}${page} / ${name}`
  5057. ) : (
  5058. `${currentNotificationCount}${name} \\ ${page}`
  5059. )
  5060. }
  5061.  
  5062. /**
  5063. * @param {import("./types").TimelineItemType} type
  5064. * @returns {boolean}
  5065. */
  5066. function shouldHideIndividualTweetTimelineItem(type) {
  5067. switch (type) {
  5068. case 'QUOTE_TWEET':
  5069. case 'RETWEET':
  5070. case 'RETWEETED_QUOTE_TWEET':
  5071. case 'TWEET':
  5072. return false
  5073. case 'UNAVAILABLE_QUOTE_TWEET':
  5074. case 'UNAVAILABLE_RETWEET':
  5075. return config.hideUnavailableQuoteTweets
  5076. default:
  5077. return true
  5078. }
  5079. }
  5080.  
  5081. /**
  5082. * @param {import("./types").TimelineItemType} type
  5083. * @returns {boolean}
  5084. */
  5085. function shouldHideListTimelineItem(type) {
  5086. switch (type) {
  5087. case 'RETWEET':
  5088. case 'RETWEETED_QUOTE_TWEET':
  5089. return config.listRetweets == 'hide'
  5090. case 'UNAVAILABLE_QUOTE_TWEET':
  5091. return config.hideUnavailableQuoteTweets
  5092. case 'UNAVAILABLE_RETWEET':
  5093. return config.hideUnavailableQuoteTweets || config.listRetweets == 'hide'
  5094. default:
  5095. return false
  5096. }
  5097. }
  5098.  
  5099. /**
  5100. * @param {import("./types").TimelineItemType} type
  5101. * @param {string} page
  5102. * @returns {boolean}
  5103. */
  5104. function shouldHideHomeTimelineItem(type, page) {
  5105. switch (type) {
  5106. case 'QUOTE_TWEET':
  5107. return shouldHideSharedTweet(config.quoteTweets, page)
  5108. case 'RETWEET':
  5109. return selectedHomeTabIndex >= 2 ? config.listRetweets == 'hide' : shouldHideSharedTweet(config.retweets, page)
  5110. case 'RETWEETED_QUOTE_TWEET':
  5111. return selectedHomeTabIndex >= 2 ? (
  5112. config.listRetweets == 'hide'
  5113. ) : (
  5114. shouldHideSharedTweet(config.retweets, page) || shouldHideSharedTweet(config.quoteTweets, page)
  5115. )
  5116. case 'TWEET':
  5117. return page == separatedTweetsTimelineTitle
  5118. case 'UNAVAILABLE_QUOTE_TWEET':
  5119. return config.hideUnavailableQuoteTweets || shouldHideSharedTweet(config.quoteTweets, page)
  5120. case 'UNAVAILABLE_RETWEET':
  5121. return config.hideUnavailableQuoteTweets || selectedHomeTabIndex >= 2 ? config.listRetweets == 'hide' : shouldHideSharedTweet(config.retweets, page)
  5122. default:
  5123. return true
  5124. }
  5125. }
  5126.  
  5127. /**
  5128. * @param {import("./types").TimelineItemType} type
  5129. * @returns {boolean}
  5130. */
  5131. function shouldHideProfileTimelineItem(type) {
  5132. switch (type) {
  5133. case 'PINNED_TWEET':
  5134. case 'QUOTE_TWEET':
  5135. case 'TWEET':
  5136. return false
  5137. case 'RETWEET':
  5138. case 'RETWEETED_QUOTE_TWEET':
  5139. return config.hideProfileRetweets
  5140. case 'UNAVAILABLE_QUOTE_TWEET':
  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 shouldHideOtherTimelineItem(type) {
  5152. switch (type) {
  5153. case 'QUOTE_TWEET':
  5154. case 'RETWEET':
  5155. case 'RETWEETED_QUOTE_TWEET':
  5156. case 'TWEET':
  5157. case 'UNAVAILABLE':
  5158. case 'UNAVAILABLE_QUOTE_TWEET':
  5159. case 'UNAVAILABLE_RETWEET':
  5160. return false
  5161. default:
  5162. return true
  5163. }
  5164. }
  5165.  
  5166. /**
  5167. * @param {import("./types").SharedTweetsConfig} config
  5168. * @param {string} page
  5169. * @returns {boolean}
  5170. */
  5171. function shouldHideSharedTweet(config, page) {
  5172. switch (config) {
  5173. case 'hide': return true
  5174. case 'ignore': return page == separatedTweetsTimelineTitle
  5175. case 'separate': return page != separatedTweetsTimelineTitle
  5176. }
  5177. }
  5178.  
  5179. async function tweakBookmarksPage() {
  5180. if (config.twitterBlueChecks != 'ignore' || config.restoreLinkHeadlines) {
  5181. observeTimeline(currentPage)
  5182. }
  5183. }
  5184.  
  5185. async function tweakExplorePage() {
  5186. if (!config.hideExplorePageContents) return
  5187.  
  5188. let $searchInput = await getElement('input[data-testid="SearchBox_Search_Input"]', {
  5189. name: 'explore page search input',
  5190. stopIf: () => !isOnExplorePage(),
  5191. })
  5192. if (!$searchInput) return
  5193.  
  5194. log('focusing search input')
  5195. $searchInput.focus()
  5196.  
  5197. if (mobile) {
  5198. // The back button appears after the search input is focused on mobile. When
  5199. // you tap it or otherwise navigate back, it's replaced with the slide-out
  5200. // menu button and Explore page contents are shown - we want to skip that.
  5201. let $backButton = await getElement('div[data-testid="app-bar-back"]', {
  5202. name: 'back button',
  5203. stopIf: () => !isOnExplorePage(),
  5204. })
  5205. if (!$backButton) return
  5206.  
  5207. pageObservers.push(
  5208. observeElement($backButton.parentElement, (mutations) => {
  5209. mutations.forEach((mutation) => {
  5210. mutation.addedNodes.forEach((/** @type {HTMLElement} */ $el) => {
  5211. if ($el.querySelector('[data-testid="DashButton_ProfileIcon_Link"]')) {
  5212. log('slide-out menu button appeared, going back to skip Explore page')
  5213. history.go(-2)
  5214. }
  5215. })
  5216. })
  5217. }, 'back button parent')
  5218. )
  5219. }
  5220. }
  5221.  
  5222. function tweakCommunitiesPage() {
  5223. observeTimeline(currentPage)
  5224. }
  5225.  
  5226. function tweakCommunityPage() {
  5227. if (config.twitterBlueChecks != 'ignore') {
  5228. observeTimeline(currentPage, {
  5229. classifyTweets: false,
  5230. isTabbed: true,
  5231. tabbedTimelineContainerSelector: `${Selectors.PRIMARY_COLUMN} > div > div:last-child`,
  5232. onTimelineAppeared() {
  5233. // The About tab has static content at the top which can include a check
  5234. if (/\/about\/?$/.test(location.pathname)) {
  5235. processBlueChecks(document.querySelector(Selectors.PRIMARY_COLUMN))
  5236. }
  5237. }
  5238. })
  5239. }
  5240. }
  5241.  
  5242. function tweakCommunityMembersPage() {
  5243. if (config.twitterBlueChecks != 'ignore') {
  5244. observeTimeline(currentPage, {
  5245. classifyTweets: false,
  5246. isTabbed: true,
  5247. timelineSelector: 'div[data-testid="primaryColumn"] > div > div:last-child',
  5248. })
  5249. }
  5250. }
  5251.  
  5252. function tweakDisplaySettingsPage() {
  5253. (async () => {
  5254. let $colorRerenderBoundary = await getElement('#react-root > div > div')
  5255.  
  5256. pageObservers.push(
  5257. observeElement($colorRerenderBoundary, () => {
  5258. let newThemeColor = getThemeColorFromState()
  5259. if (newThemeColor == themeColor) return
  5260.  
  5261. log('Color setting changed')
  5262. themeColor = newThemeColor
  5263. configureThemeCss()
  5264. observePopups()
  5265. observeSideNavTweetButton()
  5266. }, 'Color change re-render boundary')
  5267. )
  5268. })()
  5269.  
  5270. if (desktop) {
  5271. pageObservers.push(
  5272. observeElement($html, () => {
  5273. if (!$html.style.fontSize) return
  5274.  
  5275. if ($html.style.fontSize != fontSize) {
  5276. fontSize = $html.style.fontSize
  5277. log(`<html> fontSize has changed to ${fontSize}`)
  5278. configureDynamicCss()
  5279. observePopups()
  5280. observeSideNavTweetButton()
  5281. }
  5282. }, '<html> style attribute for font size changes', {
  5283. attributes: true,
  5284. attributeFilter: ['style']
  5285. })
  5286. )
  5287. }
  5288. }
  5289.  
  5290. /**
  5291. * @param {HTMLElement} $focusedTweet
  5292. * @param {import("./types").IndividualTweetTimelineOptions} options
  5293. */
  5294. async function tweakFocusedTweet($focusedTweet, options) {
  5295. let {observers} = options
  5296. if ($focusedTweet) {
  5297. restoreTweetInteractionsLinks($focusedTweet)
  5298.  
  5299. if (desktop && config.replaceLogo && !isObserving(observers, 'tweet editor')) {
  5300. let $editorRoot = await getElement('.DraftEditor-root', {
  5301. context: $focusedTweet.parentElement,
  5302. name: 'tweet editor in focused tweet',
  5303. timeout: 500,
  5304. })
  5305. if ($editorRoot && !isObserving(observers, 'tweet editor')) {
  5306. observers.unshift(
  5307. observeElement($editorRoot, () => {
  5308. if ($editorRoot.firstElementChild.classList.contains('public-DraftEditorPlaceholder-root')) {
  5309. let $placeholder = $editorRoot.querySelector('.public-DraftEditorPlaceholder-inner')
  5310. if ($placeholder) {
  5311. $placeholder.textContent = getString('TWEET_YOUR_REPLY')
  5312. }
  5313. }
  5314. }, 'tweet editor')
  5315. )
  5316. }
  5317. }
  5318. }
  5319. else {
  5320. disconnectObserver('tweet editor', observers)
  5321. }
  5322. }
  5323.  
  5324. async function tweakFollowListPage() {
  5325. // These tabs are dynamic as "Followers you know" only appears when applicable
  5326. let $tabs = await getElement(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav`, {
  5327. name: 'Following tabs',
  5328. stopIf: pageIsNot(currentPage),
  5329. })
  5330. if (!$tabs) return
  5331.  
  5332. let $subscriptionsTabLink = $tabs.querySelector('div[role="tablist"] a[href$="/subscriptions"]')
  5333. if ($subscriptionsTabLink) {
  5334. $body.classList.add('Subscriptions')
  5335. }
  5336.  
  5337. if (config.hideVerifiedNotificationsTab) {
  5338. let isVerifiedTabSelected = Boolean($tabs.querySelector('div[role="tablist"] > div:nth-child(1) > a[aria-selected="true"]'))
  5339. if (isVerifiedTabSelected) {
  5340. log('switching to Following tab')
  5341. $tabs.querySelector(`div[role="tablist"] > div:nth-last-child(${$subscriptionsTabLink ? 3 : 2}) > a`)?.click()
  5342. }
  5343. }
  5344.  
  5345. if (config.twitterBlueChecks != 'ignore') {
  5346. observeTimeline(currentPage, {
  5347. classifyTweets: false,
  5348. })
  5349. }
  5350. }
  5351.  
  5352. async function tweakIndividualTweetPage() {
  5353. observeIndividualTweetTimeline(currentPage)
  5354.  
  5355. if (config.replaceLogo) {
  5356. (async () => {
  5357. let $headingText = await getElement(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} h2 span`, {
  5358. name: 'tweet thread heading',
  5359. stopIf: pageIsNot(currentPage)
  5360. })
  5361. if ($headingText && $headingText.textContent != getString('TWEET')) {
  5362. $headingText.textContent = getString('TWEET')
  5363. }
  5364. })()
  5365. }
  5366.  
  5367. setDefaultSortReplies()
  5368. }
  5369.  
  5370. function tweakListPage() {
  5371. observeTimeline(currentPage, {
  5372. hideHeadings: false,
  5373. })
  5374. }
  5375.  
  5376. async function tweakDesktopLogo() {
  5377. let $logoPath = await getElement(`h1 ${Selectors.X_LOGO_PATH}`, {name: 'desktop nav logo', timeout: 5000})
  5378. if ($logoPath) {
  5379. twitterLogo($logoPath)
  5380. }
  5381. }
  5382.  
  5383. async function tweakHomeIcon() {
  5384. let $homeIconPath = await getElement(`${Selectors.NAV_HOME_LINK} svg path`, {name: 'Home icon', stopIf: pageIsNot(currentPage)})
  5385. if ($homeIconPath) {
  5386. homeIcon($homeIconPath)
  5387. }
  5388. }
  5389.  
  5390. async function tweakTweetBox() {
  5391. // Observe username typeahead dropdowns to replace Blue checks
  5392. if (config.twitterBlueChecks != 'ignore') {
  5393. let $tweetTextarea = await getElement(`${desktop ? 'div[data-testid="primaryColumn"]': 'main'} [data-testid^="tweetTextarea"]`, {
  5394. name: 'tweet textarea',
  5395. stopIf: pageIsNot(currentPage),
  5396. })
  5397. if (!$tweetTextarea) return
  5398.  
  5399. /** @type {HTMLElement} */
  5400. let $typeaheadDropdown
  5401.  
  5402. pageObservers.push(
  5403. observeElement($tweetTextarea.parentElement.parentElement.parentElement.parentElement, (mutations) => {
  5404. for (let mutation of mutations) {
  5405. if ($typeaheadDropdown && mutations.some(mutation => Array.from(mutation.removedNodes).includes($typeaheadDropdown))) {
  5406. disconnectPageObserver('tweet textarea typeahead dropdown')
  5407. $typeaheadDropdown = null
  5408. }
  5409. for (let $addedNode of mutation.addedNodes) {
  5410. if ($addedNode instanceof HTMLElement && $addedNode.getAttribute('id')?.startsWith('typeaheadDropdown')) {
  5411. $typeaheadDropdown = $addedNode
  5412. pageObservers.push(
  5413. observeElement($typeaheadDropdown, () => {
  5414. processBlueChecks($typeaheadDropdown)
  5415. }, 'tweet textarea typeahead dropdown')
  5416. )
  5417. }
  5418. }
  5419. }
  5420. }, 'tweet textarea typeahead dropdown container')
  5421. )
  5422. }
  5423.  
  5424. if (config.replaceLogo) {
  5425. tweakTweetButton()
  5426. }
  5427. }
  5428.  
  5429. async function tweakTweetButton() {
  5430. let $tweetButton = await getElement(`${desktop ? 'div[data-testid="primaryColumn"]': 'main'} button[data-testid^="tweetButton"]`, {
  5431. name: 'tweet button',
  5432. stopIf: pageIsNot(currentPage),
  5433. })
  5434. if ($tweetButton) {
  5435. let $text = $tweetButton.querySelector('span > span')
  5436. if ($text) {
  5437. setTweetButtonText($text)
  5438. } else {
  5439. warn('could not find tweet button text')
  5440. }
  5441. }
  5442. }
  5443.  
  5444. function tweakHomeTimelinePage() {
  5445. if (desktop) {
  5446. tweakTweetBox()
  5447. }
  5448.  
  5449. let $timelineTabs = document.querySelector(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav`)
  5450.  
  5451. // Hook for styling when on the separated tweets tab
  5452. $body.classList.toggle('SeparatedTweets', isOnSeparatedTweetsTimeline())
  5453.  
  5454. if ($timelineTabs == null) {
  5455. warn('could not find timeline tabs')
  5456. return
  5457. }
  5458.  
  5459. tweakTimelineTabs($timelineTabs)
  5460. if (mobile && isSafari && config.replaceLogo) {
  5461. processTwitterLogos(document.querySelector(Selectors.MOBILE_TIMELINE_HEADER))
  5462. }
  5463.  
  5464. function updateSelectedHomeTabIndex() {
  5465. let $selectedHomeTabLink = $timelineTabs.querySelector('div[role="tablist"] a[aria-selected="true"]')
  5466. if ($selectedHomeTabLink) {
  5467. selectedHomeTabIndex = Array.from($selectedHomeTabLink.parentElement.parentElement.children).indexOf($selectedHomeTabLink.parentElement)
  5468. log({selectedHomeTabIndex})
  5469. } else {
  5470. warn('could not find selected Home tab link')
  5471. selectedHomeTabIndex = -1
  5472. }
  5473. }
  5474.  
  5475. updateSelectedHomeTabIndex()
  5476.  
  5477. // If there are pinned lists, the timeline tabs <nav> will be replaced when they load
  5478. pageObservers.push(
  5479. observeElement($timelineTabs.parentElement, (mutations) => {
  5480. let timelineTabsReplaced = mutations.some(mutation => Array.from(mutation.removedNodes).includes($timelineTabs))
  5481. if (timelineTabsReplaced) {
  5482. log('timeline tabs replaced')
  5483. $timelineTabs = document.querySelector(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav`)
  5484. tweakTimelineTabs($timelineTabs)
  5485. }
  5486. }, 'timeline tabs nav container')
  5487. )
  5488.  
  5489. observeTimeline(currentPage, {
  5490. isTabbed: true,
  5491. onTabChanged: () => {
  5492. updateSelectedHomeTabIndex()
  5493. wasForYouTabSelected = selectedHomeTabIndex == 0
  5494. },
  5495. tabbedTimelineContainerSelector: 'div[data-testid="primaryColumn"] > div > div:last-child',
  5496. })
  5497. }
  5498.  
  5499. function tweakMobileComposeTweetPage() {
  5500. tweakTweetBox()
  5501. }
  5502.  
  5503. function tweakMobileMediaViewerPage() {
  5504. if (config.twitterBlueChecks == 'ignore') return
  5505.  
  5506. let $timeline = /** @type {HTMLElement} */ (document.querySelector('[data-testid="vss-scroll-view"] > div'))
  5507. if (!$timeline) {
  5508. warn('media viewer timeline not found')
  5509. return
  5510. }
  5511.  
  5512. observeElement($timeline, (mutations) => {
  5513. for (let mutation of mutations) {
  5514. if (!mutation.addedNodes) continue
  5515. for (let $addedNode of mutation.addedNodes) {
  5516. if ($addedNode.querySelector?.('div[data-testid^="immersive-tweet-ui-content-container"]')) {
  5517. processBlueChecks($addedNode)
  5518. }
  5519. }
  5520. }
  5521. }, 'media viewer timeline', {childList: true, subtree: true})
  5522. }
  5523.  
  5524. async function tweakTimelineTabs($timelineTabs) {
  5525. let $followingTabLink = /** @type {HTMLElement} */ ($timelineTabs.querySelector('div[role="tablist"] > div:nth-child(2) > a'))
  5526.  
  5527. if (config.alwaysUseLatestTweets && !document.title.startsWith(separatedTweetsTimelineTitle)) {
  5528. let isForYouTabSelected = Boolean($timelineTabs.querySelector('div[role="tablist"] > div:first-child > a[aria-selected="true"]'))
  5529. if (isForYouTabSelected && (!wasForYouTabSelected || config.hideForYouTimeline)) {
  5530. log('switching to Following timeline')
  5531. $followingTabLink.click()
  5532. wasForYouTabSelected = false
  5533. } else {
  5534. wasForYouTabSelected = isForYouTabSelected
  5535. }
  5536. }
  5537.  
  5538. if (shouldShowSeparatedTweetsTab()) {
  5539. let $newTab = /** @type {HTMLElement} */ ($timelineTabs.querySelector('#tnt_separated_tweets_tab'))
  5540. if ($newTab) {
  5541. log('separated tweets timeline tab already present')
  5542. $newTab.querySelector('span').textContent = separatedTweetsTimelineTitle
  5543. }
  5544. else {
  5545. log('inserting separated tweets tab')
  5546. $newTab = /** @type {HTMLElement} */ ($followingTabLink.parentElement.cloneNode(true))
  5547. $newTab.id = 'tnt_separated_tweets_tab'
  5548. $newTab.querySelector('span').textContent = separatedTweetsTimelineTitle
  5549. let $link = $newTab.querySelector('a')
  5550. $link.removeAttribute('aria-selected')
  5551.  
  5552. // This script assumes navigation has occurred when the document title
  5553. // changes, so by changing the title we fake navigation to a non-existent
  5554. // page representing the separated tweets timeline.
  5555. $link.addEventListener('click', (e) => {
  5556. e.preventDefault()
  5557. e.stopPropagation()
  5558. if (!document.title.startsWith(separatedTweetsTimelineTitle)) {
  5559. // The separated tweets tab belongs to the Following tab
  5560. let isFollowingTabSelected = Boolean($timelineTabs.querySelector('div[role="tablist"] > div:nth-child(2) > a[aria-selected="true"]'))
  5561. if (!isFollowingTabSelected) {
  5562. log('switching to the Following tab for separated tweets')
  5563. $followingTabLink.click()
  5564. }
  5565. setTitle(separatedTweetsTimelineTitle)
  5566. }
  5567. window.scrollTo({top: 0})
  5568. })
  5569. $followingTabLink.parentElement.insertAdjacentElement('afterend', $newTab)
  5570.  
  5571. // Return to the Home timeline when any other tab is clicked
  5572. $followingTabLink.parentElement.parentElement.addEventListener('click', () => {
  5573. if (location.pathname == '/home' && !document.title.startsWith(getString('HOME'))) {
  5574. log('setting title to Home')
  5575. homeNavigationIsBeingUsed = true
  5576. setTitle(getString('HOME'))
  5577. }
  5578. })
  5579.  
  5580. // Return to the Home timeline when the Home nav link is clicked
  5581. let $homeNavLink = await getElement(Selectors.NAV_HOME_LINK, {
  5582. name: 'home nav link',
  5583. stopIf: pathIsNot(currentPath),
  5584. })
  5585. if ($homeNavLink && !$homeNavLink.dataset.tweakNewTwitterListener) {
  5586. $homeNavLink.addEventListener('click', () => {
  5587. homeNavigationIsBeingUsed = true
  5588. if (location.pathname == '/home' && !document.title.startsWith(getString('HOME'))) {
  5589. setTitle(getString('HOME'))
  5590. }
  5591. })
  5592. $homeNavLink.dataset.tweakNewTwitterListener = 'true'
  5593. }
  5594. }
  5595. } else {
  5596. removeMobileTimelineHeaderElements()
  5597. }
  5598. }
  5599.  
  5600. function tweakNotificationsPage() {
  5601. let $navigationTabs = document.querySelector(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav`)
  5602. if ($navigationTabs == null) {
  5603. warn('could not find Notifications tabs')
  5604. return
  5605. }
  5606.  
  5607. if (config.hideVerifiedNotificationsTab) {
  5608. let isVerifiedTabSelected = Boolean($navigationTabs.querySelector('div[role="tablist"] > div:nth-child(2) > a[aria-selected="true"]'))
  5609. if (isVerifiedTabSelected) {
  5610. log('switching to All tab')
  5611. $navigationTabs.querySelector('div[role="tablist"] > div:nth-child(1) > a')?.click()
  5612. }
  5613. }
  5614.  
  5615. if (config.twitterBlueChecks != 'ignore' || config.restoreLinkHeadlines) {
  5616. observeTimeline(currentPage, {
  5617. isTabbed: true,
  5618. tabbedTimelineContainerSelector: 'div[data-testid="primaryColumn"] > div > div:last-child',
  5619. })
  5620. }
  5621. }
  5622.  
  5623. async function tweakProfilePage() {
  5624. let $initialContent = await getElement(desktop ? Selectors.PRIMARY_COLUMN : Selectors.MOBILE_TIMELINE_HEADER, {
  5625. name: 'initial profile content',
  5626. stopIf: pageIsNot(currentPage),
  5627. })
  5628. if (!$initialContent) return
  5629.  
  5630. if (config.twitterBlueChecks != 'ignore') {
  5631. processBlueChecks($initialContent)
  5632. }
  5633.  
  5634. let tab = currentPath.match(URL_PROFILE_RE)?.[2] || 'tweets'
  5635. log(`on ${tab} tab`)
  5636. observeTimeline(currentPage, {
  5637. isUserTimeline: tab == 'affiliates'
  5638. })
  5639.  
  5640. let $editProfileButton = document.querySelector('a[href="/settings/profile"]')
  5641. let $headerVerifiedIcon = document.querySelector(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.TIMELINE_HEADING} [data-testid="icon-verified"]`)
  5642. $body.classList.toggle('OwnProfile', Boolean($editProfileButton))
  5643. $body.classList.toggle('PremiumProfile', Boolean($headerVerifiedIcon))
  5644.  
  5645. if (config.replaceLogo || config.hideSubscriptions) {
  5646. let $profileTabs = await getElement(`${Selectors.PRIMARY_COLUMN} nav`, {
  5647. name: 'profile tabs',
  5648. stopIf: pageIsNot(currentPage),
  5649. })
  5650. if (!$profileTabs) return
  5651. // The Profile tabs <nav> can be replaced
  5652. pageObservers.push(
  5653. observeElement($profileTabs.parentElement, async (mutations) => {
  5654. if (mutations.length > 0) {
  5655. let $newProfileTabs = findAddedNode(mutations, ($el) => $el instanceof HTMLElement && $el.tagName == 'NAV')
  5656. if ($newProfileTabs == null) return
  5657. $profileTabs = /** @type {HTMLElement} */ ($newProfileTabs)
  5658. }
  5659. if (config.replaceLogo) {
  5660. let $tweetsTabText = await getElement('[data-testid="ScrollSnap-List"] > [role="presentation"]:first-child div[dir] > span:first-child', {
  5661. context: $profileTabs,
  5662. name: 'Tweets tab text',
  5663. stopIf: pageIsNot(currentPage),
  5664. })
  5665. if ($tweetsTabText && $tweetsTabText.textContent != getString('TWEETS')) {
  5666. $tweetsTabText.textContent = getString('TWEETS')
  5667. }
  5668. }
  5669. if (config.hideSubscriptions) {
  5670. let $subscriptionsTabLink = await getElement('a[href$="/superfollows"]', {
  5671. context: $profileTabs,
  5672. name: 'Subscriptions tab link',
  5673. stopIf: pageIsNot(currentPage),
  5674. timeout: 1000,
  5675. })
  5676. if ($subscriptionsTabLink) {
  5677. $subscriptionsTabLink.parentElement.classList.add('SubsTab')
  5678. }
  5679. }
  5680. }, 'profile tabs', {childList: true})
  5681. )
  5682. }
  5683. }
  5684.  
  5685. /**
  5686. * @param {Element} $dropdownItem
  5687. * @param {string} dropdownItemSelector
  5688. * @param {import("./types").LocaleKey} localeKey
  5689. */
  5690. async function tweakRetweetDropdown($dropdownItem, dropdownItemSelector, localeKey) {
  5691. log('tweaking Retweet/Quote Tweet dropdown')
  5692.  
  5693. if (desktop) {
  5694. $dropdownItem = await getElement(`
  5695. #layers div[data-testid="Dropdown"] ${dropdownItemSelector}
  5696. `, {
  5697. name: 'rendered menu item',
  5698. timeout: 100,
  5699. })
  5700. if (!$dropdownItem) return
  5701. }
  5702.  
  5703. let $text = $dropdownItem.querySelector('div[dir] > span')
  5704. if ($text) $text.textContent = getString(localeKey)
  5705.  
  5706. let $quoteTweetText = $dropdownItem.nextElementSibling?.querySelector('div[dir] > span')
  5707. if ($quoteTweetText) $quoteTweetText.textContent = getString('QUOTE_TWEET')
  5708. }
  5709.  
  5710. function tweakSearchPage() {
  5711. let $searchTabs = document.querySelector(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav`)
  5712. if ($searchTabs != null) {
  5713. if (config.defaultToLatestSearch) {
  5714. let isTopTabSelected = Boolean($searchTabs.querySelector('div[role="tablist"] > div:nth-child(1) > a[aria-selected="true"]'))
  5715. if (isTopTabSelected) {
  5716. log('switching to Latest tab')
  5717. $searchTabs.querySelector('div[role="tablist"] > div:nth-child(2) > a')?.click()
  5718. }
  5719. }
  5720. } else {
  5721. warn('could not find Search tabs')
  5722. }
  5723.  
  5724. observeTimeline(currentPage, {
  5725. hideHeadings: false,
  5726. isTabbed: true,
  5727. tabbedTimelineContainerSelector: 'div[data-testid="primaryColumn"] > div > div:last-child',
  5728. })
  5729. }
  5730.  
  5731. function tweakTweetEngagementPage() {
  5732. if (config.replaceLogo) {
  5733. let $headingText = document.querySelector(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} h2 span`)
  5734. if ($headingText) {
  5735. if ($headingText.textContent != getString('TWEET_INTERACTIONS')) {
  5736. $headingText.textContent = getString('TWEET_INTERACTIONS')
  5737. }
  5738. } else {
  5739. warn('could not find Post engagement heading')
  5740. }
  5741. }
  5742.  
  5743. let $tabs = document.querySelector(`${mobile ? Selectors.MOBILE_TIMELINE_HEADER : Selectors.PRIMARY_COLUMN} nav`)
  5744. if ($tabs == null) {
  5745. warn('could not find Post engagement tabs')
  5746. return
  5747. }
  5748.  
  5749. if (tweetInteractionsTab) {
  5750. log('switching to tab', tweetInteractionsTab)
  5751. $tabs.querySelector(`div[role="tablist"] > div:nth-child(${tweetInteractionsTab}) > a`)?.click()
  5752. tweetInteractionsTab = null
  5753. }
  5754.  
  5755. if (config.replaceLogo) {
  5756. let $quoteTweetsTabText = $tabs.querySelector('div[role="tablist"] > div:nth-child(1) div[dir] > span')
  5757. if ($quoteTweetsTabText) $quoteTweetsTabText.textContent = getString('QUOTE_TWEETS')
  5758. let $retweetsTabText = $tabs.querySelector('div[role="tablist"] > div:nth-child(2) div[dir] > span')
  5759. if ($retweetsTabText) $retweetsTabText.textContent = getString('RETWEETS')
  5760. }
  5761.  
  5762. if (config.twitterBlueChecks != 'ignore') {
  5763. observeTimeline(currentPage, {classifyTweets: false})
  5764. }
  5765. }
  5766. //#endregion
  5767.  
  5768. //#region Main
  5769. async function main() {
  5770. let $settings = /** @type {HTMLScriptElement} */ (document.querySelector('script#tnt_settings'))
  5771. if ($settings) {
  5772. try {
  5773. Object.assign(config, JSON.parse($settings.innerText))
  5774. } catch(e) {
  5775. error('error parsing initial settings', e)
  5776. }
  5777.  
  5778. let settingsChangeObserver = new MutationObserver(() => {
  5779. /** @type {Partial<import("./types").Config>} */
  5780. let configChanges
  5781. try {
  5782. configChanges = JSON.parse($settings.innerText)
  5783. } catch(e) {
  5784. error('error parsing incoming settings change', e)
  5785. return
  5786. }
  5787.  
  5788. if ('debug' in configChanges) {
  5789. log('disabling debug mode')
  5790. debug = configChanges.debug
  5791. log('enabled debug mode')
  5792. configureThemeCss()
  5793. return
  5794. }
  5795.  
  5796. Object.assign(config, configChanges)
  5797. configChanged(configChanges)
  5798. })
  5799. settingsChangeObserver.observe($settings, {childList: true})
  5800. }
  5801.  
  5802. if (config.debug) {
  5803. debug = true
  5804. }
  5805.  
  5806. observeTitle()
  5807.  
  5808. let $loadingStyle
  5809. if (config.replaceLogo) {
  5810. getElement('html', {name: 'html element'}).then(($html) => {
  5811. $loadingStyle = document.createElement('style')
  5812. $loadingStyle.dataset.insertedBy = 'control-panel-for-twitter'
  5813. $loadingStyle.dataset.role = 'loading-logo'
  5814. $loadingStyle.textContent = dedent(`
  5815. ${Selectors.X_LOGO_PATH} {
  5816. fill: ${isSafari ? 'transparent' : THEME_BLUE};
  5817. d: path("${Svgs.TWITTER_LOGO_PATH}");
  5818. }
  5819. .tnt_logo {
  5820. fill: ${THEME_BLUE};
  5821. }
  5822. `)
  5823. $html.appendChild($loadingStyle)
  5824. })
  5825.  
  5826. if (isSafari) {
  5827. getElement(Selectors.X_LOGO_PATH, {name: 'pre-loading indicator logo', timeout: 1000}).then(($logoPath) => {
  5828. if ($logoPath) {
  5829. twitterLogo($logoPath)
  5830. }
  5831. })
  5832. }
  5833.  
  5834. observeFavicon()
  5835. }
  5836.  
  5837. let $appWrapper = await getElement('#layers + div', {name: 'app wrapper'})
  5838.  
  5839. $html = document.querySelector('html')
  5840. $body = document.body
  5841. $reactRoot = document.querySelector('#react-root')
  5842. lang = $html.lang
  5843. dir = $html.dir
  5844. ltr = dir == 'ltr'
  5845. let lastFlexDirection
  5846.  
  5847. observeElement($appWrapper, () => {
  5848. let flexDirection = getComputedStyle($appWrapper).flexDirection
  5849.  
  5850. mobile = flexDirection == 'column'
  5851. desktop = !mobile
  5852.  
  5853. /** @type {'mobile' | 'desktop'} */
  5854. let version = mobile ? 'mobile' : 'desktop'
  5855.  
  5856. if (version != config.version) {
  5857. log('setting version to', version)
  5858. config.version = version
  5859. // Let the options page know which version is being used
  5860. storeConfigChanges({version})
  5861. }
  5862.  
  5863. if (lastFlexDirection == null) {
  5864. log('initial config', {config, lang, version})
  5865.  
  5866. // One-time setup
  5867. checkReactNativeStylesheet()
  5868. observeBodyBackgroundColor()
  5869. let initialThemeColor = getThemeColorFromState()
  5870. if (initialThemeColor) {
  5871. themeColor = initialThemeColor
  5872. }
  5873. if (desktop) {
  5874. fontSize = $html.style.fontSize
  5875. if (!fontSize) {
  5876. warn('initial fontSize not set on <html>')
  5877. }
  5878. }
  5879.  
  5880. // Repeatable configuration setup
  5881. configureSeparatedTweetsTimelineTitle()
  5882. configureCss()
  5883. configureDynamicCss()
  5884. configureThemeCss()
  5885. observePopups()
  5886. observeSideNavTweetButton()
  5887.  
  5888. // Start taking action on page changes
  5889. observingPageChanges = true
  5890.  
  5891. // Delay removing loading icon styles to avoid Flash of X
  5892. if ($loadingStyle) {
  5893. setTimeout(() => $loadingStyle.remove(), 1000)
  5894. }
  5895. }
  5896. else if (flexDirection != lastFlexDirection) {
  5897. configChanged({version})
  5898. }
  5899.  
  5900. $body.classList.toggle('Mobile', mobile)
  5901. $body.classList.toggle('Desktop', desktop)
  5902.  
  5903. lastFlexDirection = flexDirection
  5904. }, 'app wrapper class attribute for version changes (mobile ↔ desktop)', {
  5905. attributes: true,
  5906. attributeFilter: ['class']
  5907. })
  5908. }
  5909.  
  5910. /**
  5911. * @param {Partial<import("./types").Config>} changes
  5912. */
  5913. function configChanged(changes) {
  5914. log('config changed', changes)
  5915.  
  5916. if ('version' in changes) {
  5917. fontSize = desktop ? $html.style.fontSize : null
  5918. }
  5919.  
  5920. configureCss()
  5921. configureFont()
  5922. configureDynamicCss()
  5923. configureThemeCss()
  5924. observeFavicon()
  5925. observePopups()
  5926. observeSideNavTweetButton()
  5927.  
  5928. // Only re-process the current page if navigation wasn't already triggered
  5929. // while applying the following config changes (if there were any).
  5930. let navigationTriggered = (
  5931. configureSeparatedTweetsTimelineTitle() ||
  5932. checkforDisabledHomeTimeline()
  5933. )
  5934. if (!navigationTriggered) {
  5935. processCurrentPage()
  5936. }
  5937. }
  5938.  
  5939. main()
  5940. //#endregion
  5941.  
  5942. }()