Control Panel for Twitter

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

当前为 2024-05-14 提交的版本,查看 最新版本

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