Control Panel for Twitter

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

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

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