Control Panel for Twitter

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

От 17.06.2024. Виж последната версия.

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