Control Panel for Twitter

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

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

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