Control Panel for Twitter

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

当前为 2023-09-17 提交的版本,查看 最新版本

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