Control Panel for Twitter

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

当前为 2024-10-11 提交的版本,查看 最新版本

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