forked from insin/control-panel-for-twitter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tweak-new-twitter.user.js
3373 lines (3103 loc) · 117 KB
/
tweak-new-twitter.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name Tweak New Twitter
// @description Remove algorithmic content from Twitter, hide news & trends, control which shared tweets appear on your timeline, and improve the UI
// @icon https://raw.githubusercontent.com/insin/tweak-new-twitter/master/icons/icon32.png
// @namespace https://github.com/insin/tweak-new-twitter/
// @match https://twitter.com/*
// @match https://mobile.twitter.com/*
// @version 88
// ==/UserScript==
void function() {
let debug = false
/** @type {boolean} */
let desktop
/** @type {boolean} */
let mobile
const $html = document.querySelector('html')
const $body = document.body
const lang = $html.lang
const dir = $html.dir
const ltr = dir == 'ltr'
//#region Default config
/**
* @type {import("./types").Config}
*/
const config = {
debug: false,
// Shared
addAddMutedWordMenuItem: true,
alwaysUseLatestTweets: true,
communityTweets: 'ignore',
dontUseChirpFont: false,
dropdownMenuFontWeight: true,
fastBlock: true,
followButtonStyle: 'monochrome',
followeesFollows: 'ignore',
hideAnalyticsNav: true,
hideBookmarksNav: true,
hideCommunitiesNav: true,
hideExplorePageContents: true,
hideFollowingMetrics: true,
hideForYouTimeline: true,
hideHelpCenterNav: true,
hideKeyboardShortcutsNav: false,
hideLikeMetrics: true,
hideListsNav: true,
hideMetrics: false,
hideMomentsNav: true,
hideMonetizationNav: true,
hideMoreTweets: true,
hideNewslettersNav: true,
hideQuoteTweetMetrics: true,
hideReplyMetrics: true,
hideRetweetMetrics: true,
hideShareTweetButton: false,
hideTopicsNav: true,
hideTotalTweetsMetrics: true,
hideTweetAnalyticsLinks: false,
hideTwitterAdsNav: true,
hideTwitterBlueNav: true,
hideTwitterCircleNav: true,
hideTwitterForProfessionalsNav: true,
hideUnavailableQuoteTweets: true,
hideVerifiedNotificationsTab: true,
hideViews: true,
hideWhoToFollowEtc: true,
likedTweets: 'ignore',
mutableQuoteTweets: true,
mutedQuotes: [],
quoteTweets: 'ignore',
repliedToTweets: 'ignore',
retweets: 'separate',
suggestedTopicTweets: 'ignore',
tweakQuoteTweetsPage: true,
twitterBlueChecks: 'replace',
uninvertFollowButtons: true,
// Experiments
disableHomeTimeline: false,
disabledHomeTimelineRedirect: 'notifications',
fullWidthContent: false,
fullWidthMedia: false,
reducedInteractionMode: false,
verifiedAccounts: 'ignore',
// Desktop only
hideAccountSwitcher: true,
hideExploreNav: true,
hideMessagesDrawer: true,
hideSidebarContent: true,
navBaseFontSize: true,
showRelevantPeople: false,
// Mobile only
hideAppNags: true,
hideMessagesBottomNavItem: false,
}
//#endregion
//#region Locales
/**
* @type {{[key: string]: import("./types").Locale}}
*/
const locales = {
'ar-x-fm': {
ADD_MUTED_WORD: 'اضافة كلمة مكتومة',
DISCOVER_MORE: 'اكتشاف المزيد',
FOLLOWING: 'متابَع',
HOME: 'الرئيسيّة',
MUTE_THIS_CONVERSATION: 'كتم هذه المحادثه',
QUOTE_TWEET: 'اقتباس التغريدة',
QUOTE_TWEETS: 'تغريدات اقتباس',
RETWEETS: 'إعادات التغريد',
SHARED_TWEETS: 'التغريدات المشتركة',
TWITTER: 'تويتر',
},
ar: {
ADD_MUTED_WORD: 'اضافة كلمة مكتومة',
DISCOVER_MORE: 'اكتشاف المزيد',
FOLLOWING: 'متابَع',
HOME: 'الرئيسيّة',
MUTE_THIS_CONVERSATION: 'كتم هذه المحادثه',
QUOTE_TWEET: 'اقتباس التغريدة',
QUOTE_TWEETS: 'تغريدات اقتباس',
RETWEETS: 'إعادات التغريد',
SHARED_TWEETS: 'التغريدات المشتركة',
},
bg: {
ADD_MUTED_WORD: 'Добавяне на заглушена дума',
DISCOVER_MORE: 'Откриване на още',
FOLLOWING: 'Следвано',
HOME: 'Начало',
MUTE_THIS_CONVERSATION: 'Заглушаване на разговора',
QUOTE_TWEET: 'Цитиране на туита',
QUOTE_TWEETS: 'Туитове с цитат',
RETWEETS: 'Ретуитове',
SHARED_TWEETS: 'Споделени туитове',
},
bn: {
ADD_MUTED_WORD: 'নীরব করা শব্দ যোগ করুন',
DISCOVER_MORE: 'আরও খুঁজুন',
FOLLOWING: 'অনুসরণ করছেন',
HOME: 'হোম',
MUTE_THIS_CONVERSATION: 'এই কথা-বার্তা নীরব করুন',
QUOTE_TWEET: 'টুইট উদ্ধৃত করুন',
QUOTE_TWEETS: 'টুইট উদ্ধৃতিগুলো',
RETWEETS: 'পুনঃটুইটগুলো',
SHARED_TWEETS: 'ভাগ করা টুইটগুলি',
TWITTER: 'টুইটার',
},
ca: {
ADD_MUTED_WORD: 'Afegeix una paraula silenciada',
DISCOVER_MORE: 'Descobreix-ne més',
FOLLOWING: 'Seguint',
HOME: 'Inici',
MUTE_THIS_CONVERSATION: 'Silencia la conversa',
QUOTE_TWEET: 'Cita el tuit',
QUOTE_TWEETS: 'Tuits amb cita',
RETWEETS: 'Retuits',
SHARED_TWEETS: 'Tuits compartits',
},
cs: {
ADD_MUTED_WORD: 'Přidat slovo na seznam skrytých slov',
DISCOVER_MORE: 'Objevte víc',
FOLLOWING: 'Sleduji',
HOME: 'Hlavní stránka',
MUTE_THIS_CONVERSATION: 'Skrýt tuto konverzaci',
QUOTE_TWEET: 'Citovat Tweet',
QUOTE_TWEETS: 'Tweety s citací',
RETWEETS: 'Retweety',
SHARED_TWEETS: 'Sdílené tweety',
},
da: {
ADD_MUTED_WORD: 'Tilføj skjult ord',
DISCOVER_MORE: 'Opdag mere',
FOLLOWING: 'Følger',
HOME: 'Forside',
MUTE_THIS_CONVERSATION: 'Skjul denne samtale',
QUOTE_TWEET: 'Citér Tweet',
QUOTE_TWEETS: 'Citat-Tweets',
SHARED_TWEETS: 'Delte tweets',
},
de: {
ADD_MUTED_WORD: 'Stummgeschaltetes Wort hinzufügen',
DISCOVER_MORE: 'Mehr entdecken',
FOLLOWING: 'Folge ich',
HOME: 'Startseite',
MUTE_THIS_CONVERSATION: 'Diese Konversation stummschalten',
QUOTE_TWEET: 'Tweet zitieren',
QUOTE_TWEETS: 'Zitierte Tweets',
SHARED_TWEETS: 'Geteilte Tweets',
},
el: {
ADD_MUTED_WORD: 'Προσθήκη λέξης σε σίγαση',
DISCOVER_MORE: 'Ανακαλύψτε περισσότερα',
FOLLOWING: 'Ακολουθείτε',
HOME: 'Αρχική σελίδα',
MUTE_THIS_CONVERSATION: 'Σίγαση αυτής της συζήτησης',
QUOTE_TWEET: 'Παράθεση Tweet',
QUOTE_TWEETS: 'Tweet με παράθεση',
RETWEETS: 'Retweet',
SHARED_TWEETS: 'Κοινόχρηστα Tweets',
},
en: {
ADD_MUTED_WORD: 'Add muted word',
DISCOVER_MORE: 'Discover more',
FOLLOWING: 'Following',
HOME: 'Home',
MUTE_THIS_CONVERSATION: 'Mute this conversation',
QUOTE_TWEET: 'Quote Tweet',
QUOTE_TWEETS: 'Quote Tweets',
RETWEETS: 'Retweets',
SHARED_TWEETS: 'Shared Tweets',
TWITTER: 'Twitter',
},
es: {
ADD_MUTED_WORD: 'Añadir palabra silenciada',
DISCOVER_MORE: 'Descubrir más',
FOLLOWING: 'Siguiendo',
HOME: 'Inicio',
MUTE_THIS_CONVERSATION: 'Silenciar esta conversación',
QUOTE_TWEET: 'Citar Tweet',
QUOTE_TWEETS: 'Tweets citados',
SHARED_TWEETS: 'Tweets compartidos',
},
eu: {
ADD_MUTED_WORD: 'Gehitu isilarazitako hitza',
FOLLOWING: 'Jarraitzen',
HOME: 'Hasiera',
MUTE_THIS_CONVERSATION: 'Isilarazi elkarrizketa hau',
QUOTE_TWEET: 'Txioa apaitu',
QUOTE_TWEETS: 'Aipatu txioak',
RETWEETS: 'Bertxioak',
SHARED_TWEETS: 'Partekatutako',
},
fa: {
ADD_MUTED_WORD: 'افزودن واژه خموشسازی شده',
DISCOVER_MORE: 'کاوش بیشتر',
FOLLOWING: 'دنبالشده',
HOME: 'خانه',
MUTE_THIS_CONVERSATION: 'خموشسازی این گفتگو',
QUOTE_TWEET: 'نقلتوییت',
QUOTE_TWEETS: 'نقلتوییتها',
RETWEETS: 'بازتوییتها',
SHARED_TWEETS: 'توییتهای مشترک',
TWITTER: 'توییتر',
},
fi: {
ADD_MUTED_WORD: 'Lisää hiljennetty sana',
DISCOVER_MORE: 'Löydä uutta',
FOLLOWING: 'Seurataan',
HOME: 'Etusivu',
MUTE_THIS_CONVERSATION: 'Hiljennä tämä keskustelu',
QUOTE_TWEET: 'Twiitin lainaus',
QUOTE_TWEETS: 'Twiitin lainaukset',
RETWEETS: 'Uudelleentwiittaukset',
SHARED_TWEETS: 'Jaetut twiitit',
},
fil: {
ADD_MUTED_WORD: 'Idagdag ang naka-mute na salita',
DISCOVER_MORE: 'Tuklasin ang higit pa',
FOLLOWING: 'Sinusundan',
HOME: 'Home',
MUTE_THIS_CONVERSATION: 'I-mute ang usapang ito',
QUOTE_TWEET: 'Quote na Tweet',
QUOTE_TWEETS: 'Mga Quote na Tweet',
RETWEETS: 'Mga Retweet',
SHARED_TWEETS: 'Mga Ibinahaging Tweet',
},
fr: {
ADD_MUTED_WORD: 'Ajouter un mot masqué',
DISCOVER_MORE: 'Découvrez plus',
FOLLOWING: 'Abonné',
HOME: 'Accueil',
MUTE_THIS_CONVERSATION: 'Masquer cette conversation',
QUOTE_TWEET: 'Citer le Tweet',
QUOTE_TWEETS: 'Tweets cités',
SHARED_TWEETS: 'Tweets partagés',
},
ga: {
ADD_MUTED_WORD: 'Cuir focal balbhaithe leis',
FOLLOWING: 'Á Leanúint',
HOME: 'Baile',
MUTE_THIS_CONVERSATION: 'Balbhaigh an comhrá seo',
QUOTE_TWEET: 'Cuir Ráiteas Leis',
QUOTE_TWEETS: 'Luaigh Tvuíteanna',
RETWEETS: 'Atweetanna',
SHARED_TWEETS: 'Tweetanna Roinnte',
},
gl: {
ADD_MUTED_WORD: 'Engadir palabra silenciada',
FOLLOWING: 'Seguindo',
HOME: 'Inicio',
MUTE_THIS_CONVERSATION: 'Silenciar esta conversa',
QUOTE_TWEET: 'Citar chío',
QUOTE_TWEETS: 'Chíos citados',
RETWEETS: 'Rechouchíos',
SHARED_TWEETS: 'Chíos compartidos',
},
gu: {
ADD_MUTED_WORD: 'જોડાણ અટકાવેલો શબ્દ ઉમેરો',
DISCOVER_MORE: 'વધુ શોધો',
FOLLOWING: 'અનુસરે છે',
HOME: 'હોમ',
MUTE_THIS_CONVERSATION: 'આ વાર્તાલાપનું જોડાણ અટકાવો',
QUOTE_TWEET: 'અવતરણની સાથે ટ્વીટ કરો',
QUOTE_TWEETS: 'અવતરણની સાથે ટ્વીટ્સ',
RETWEETS: 'પુનટ્વીટ્સ',
SHARED_TWEETS: 'શેર કરેલી ટ્વીટ્સ',
},
he: {
ADD_MUTED_WORD: 'הוסף מילה מושתקת',
DISCOVER_MORE: 'גלה עוד',
FOLLOWING: 'עוקב',
HOME: 'דף הבית',
MUTE_THIS_CONVERSATION: 'להשתיק את השיחה הזאת',
QUOTE_TWEET: 'ציטוט ציוץ',
QUOTE_TWEETS: 'ציוצי ציטוט',
RETWEETS: 'ציוצים מחדש',
SHARED_TWEETS: 'ציוצים משותפים',
TWITTER: 'טוויטר',
},
hi: {
ADD_MUTED_WORD: 'म्यूट किया गया शब्द जोड़ें',
DISCOVER_MORE: 'और अधिक जानें',
FOLLOWING: 'फ़ॉलो कर रहे हैं',
HOME: 'होम',
MUTE_THIS_CONVERSATION: 'इस बातचीत को म्यूट करें',
QUOTE_TWEET: 'ट्वीट क्वोट करें',
QUOTE_TWEETS: 'कोट ट्वीट्स',
RETWEETS: 'रीट्वीट्स',
SHARED_TWEETS: 'साझा किए गए ट्वीट',
},
hr: {
ADD_MUTED_WORD: 'Dodaj onemogućenu riječ',
DISCOVER_MORE: 'Otkrijte više',
FOLLOWING: 'Pratim',
HOME: 'Naslovnica',
MUTE_THIS_CONVERSATION: 'Isključi zvuk ovog razgovora',
QUOTE_TWEET: 'Citiraj Tweet',
QUOTE_TWEETS: 'Citirani tweetovi',
RETWEETS: 'Proslijeđeni tweetovi',
SHARED_TWEETS: 'Dijeljeni tweetovi',
},
hu: {
ADD_MUTED_WORD: 'Elnémított szó hozzáadása',
DISCOVER_MORE: 'Továbbiak felfedezése',
FOLLOWING: 'követés',
HOME: 'Kezdőlap',
MUTE_THIS_CONVERSATION: 'Beszélgetés némítása',
QUOTE_TWEET: 'Tweet idézése',
QUOTE_TWEETS: 'Tweet-idézések',
RETWEETS: 'Retweetek',
SHARED_TWEETS: 'Megosztott tweetek',
},
id: {
ADD_MUTED_WORD: 'Tambahkan kata kunci yang dibisukan',
DISCOVER_MORE: 'Temukan lebih banyak',
FOLLOWING: 'Mengikuti',
HOME: 'Beranda',
MUTE_THIS_CONVERSATION: 'Bisukan percakapan ini',
QUOTE_TWEET: 'Kutip Tweet',
QUOTE_TWEETS: 'Tweet Kutipan',
RETWEETS: 'Retweet',
SHARED_TWEETS: 'Tweet yang Dibagikan',
},
it: {
ADD_MUTED_WORD: 'Aggiungi parola o frase silenziata',
DISCOVER_MORE: 'Continua con la scoperta',
FOLLOWING: 'Following',
HOME: 'Home',
MUTE_THIS_CONVERSATION: 'Silenzia questa conversazione',
QUOTE_TWEET: 'Cita Tweet',
QUOTE_TWEETS: 'Tweet di citazione',
RETWEETS: 'Retweet',
SHARED_TWEETS: 'Tweet condivisi',
},
ja: {
ADD_MUTED_WORD: 'ミュートするキーワードを追加',
DISCOVER_MORE: 'もっと見つける',
FOLLOWING: 'フォロー中',
HOME: 'ホーム',
MUTE_THIS_CONVERSATION: 'この会話をミュート',
QUOTE_TWEET: '引用ツイート',
QUOTE_TWEETS: '引用ツイート',
RETWEETS: 'リツイート',
SHARED_TWEETS: '共有ツイート',
},
kn: {
ADD_MUTED_WORD: 'ಸದ್ದಡಗಿಸಿದ ಪದವನ್ನು ಸೇರಿಸಿ',
DISCOVER_MORE: 'ಇನ್ನಷ್ಟನ್ನು ಕಂಡುಕೊಳ್ಳಿ',
FOLLOWING: 'ಹಿಂಬಾಲಿಸಲಾಗುತ್ತಿದೆ',
HOME: 'ಹೋಮ್',
MUTE_THIS_CONVERSATION: 'ಈ ಸಂವಾದವನ್ನು ಸದ್ದಡಗಿಸಿ',
QUOTE_TWEET: 'ಟ್ವೀಟ್ ಕೋಟ್ ಮಾಡಿ',
QUOTE_TWEETS: 'ಕೋಟ್ ಟ್ವೀಟ್ಗಳು',
RETWEETS: 'ಮರುಟ್ವೀಟ್ಗಳು',
SHARED_TWEETS: 'ಹಂಚಿದ ಟ್ವೀಟ್ಗಳು',
},
ko: {
ADD_MUTED_WORD: '뮤트할 단어 추가하기',
DISCOVER_MORE: '더 찾아보기',
FOLLOWING: '팔로잉',
HOME: '홈',
MUTE_THIS_CONVERSATION: '이 대화 뮤트하기',
QUOTE_TWEET: '트윗 인용하기',
QUOTE_TWEETS: '트윗 인용하기',
RETWEETS: '리트윗',
SHARED_TWEETS: '공유 트윗',
TWITTER: '트위터',
},
mr: {
ADD_MUTED_WORD: 'म्यूट केलेले शब्द सामील करा',
DISCOVER_MORE: 'अधिक प्रमाणामध्ये शोधा',
FOLLOWING: 'फॉलोइंग',
HOME: 'होम',
MUTE_THIS_CONVERSATION: 'ही चर्चा म्यूट करा',
QUOTE_TWEET: 'ट्विट वर भाष्य करा',
QUOTE_TWEETS: 'भाष्य ट्विट्स',
RETWEETS: 'पुनर्ट्विट्स',
SHARED_TWEETS: 'सामायिक ट्विट',
},
ms: {
ADD_MUTED_WORD: 'Tambahkan perkataan yang disenyapkan',
DISCOVER_MORE: 'Temui lagi',
FOLLOWING: 'Mengikuti',
HOME: 'Laman Utama',
MUTE_THIS_CONVERSATION: 'Senyapkan perbualan ini',
QUOTE_TWEET: 'Petik Tweet',
QUOTE_TWEETS: 'Tweet Petikan',
RETWEETS: 'Tweet semula',
SHARED_TWEETS: 'Tweet Berkongsi',
},
nb: {
ADD_MUTED_WORD: 'Skjul nytt ord',
DISCOVER_MORE: 'Oppdag mer',
FOLLOWING: 'Følger',
HOME: 'Hjem',
MUTE_THIS_CONVERSATION: 'Skjul denne samtalen',
QUOTE_TWEET: 'Sitat-Tweet',
QUOTE_TWEETS: 'Sitat-Tweets',
SHARED_TWEETS: 'Delte tweets',
},
nl: {
ADD_MUTED_WORD: 'Genegeerd woord toevoegen',
DISCOVER_MORE: 'Meer ontdekken',
FOLLOWING: 'Volgend',
HOME: 'Startpagina',
MUTE_THIS_CONVERSATION: 'Dit gesprek negeren',
QUOTE_TWEET: 'Citeer Tweet',
QUOTE_TWEETS: 'Geciteerde Tweets',
SHARED_TWEETS: 'Gedeelde Tweets',
},
pl: {
ADD_MUTED_WORD: 'Dodaj wyciszone słowo',
DISCOVER_MORE: 'Odkryj więcej',
FOLLOWING: 'Obserwujesz',
HOME: 'Główna',
MUTE_THIS_CONVERSATION: 'Wycisz tę rozmowę',
QUOTE_TWEET: 'Cytuj Tweeta',
QUOTE_TWEETS: 'Cytaty z Tweeta',
RETWEETS: 'Tweety podane dalej',
SHARED_TWEETS: 'Udostępnione Tweety',
},
pt: {
ADD_MUTED_WORD: 'Adicionar palavra silenciada',
DISCOVER_MORE: 'Descubra mais',
FOLLOWING: 'Seguindo',
HOME: 'Página Inicial',
MUTE_THIS_CONVERSATION: 'Silenciar esta conversa',
QUOTE_TWEET: 'Comentar o Tweet',
QUOTE_TWEETS: 'Tweets com comentário',
SHARED_TWEETS: 'Tweets Compartilhados',
},
ro: {
ADD_MUTED_WORD: 'Adaugă cuvântul ignorat',
DISCOVER_MORE: 'Descoperă mai mult',
FOLLOWING: 'Urmărești',
HOME: 'Pagina principală',
MUTE_THIS_CONVERSATION: 'Ignoră această conversație',
QUOTE_TWEET: 'Citează Tweetul',
QUOTE_TWEETS: 'Tweeturi cu citat',
RETWEETS: 'Retweeturi',
SHARED_TWEETS: 'Tweeturi partajate',
},
ru: {
ADD_MUTED_WORD: 'Добавить игнорируемое слово',
DISCOVER_MORE: 'Узнать больше',
FOLLOWING: 'Читаю',
HOME: 'Главная',
MUTE_THIS_CONVERSATION: 'Игнорировать эту переписку',
QUOTE_TWEET: 'Цитировать',
QUOTE_TWEETS: 'Твиты с цитатами',
RETWEETS: 'Ретвиты',
SHARED_TWEETS: 'Общие твиты',
TWITTER: 'Твиттер',
},
sk: {
ADD_MUTED_WORD: 'Pridať stíšené slovo',
DISCOVER_MORE: 'Objaviť viac',
FOLLOWING: 'Sledujem',
HOME: 'Domov',
MUTE_THIS_CONVERSATION: 'Stíšiť túto konverzáciu',
QUOTE_TWEET: 'Tweet s citátom',
QUOTE_TWEETS: 'Tweety s citátom',
RETWEETS: 'Retweety',
SHARED_TWEETS: 'Zdieľané Tweety',
},
sr: {
ADD_MUTED_WORD: 'Додај игнорисану реч',
DISCOVER_MORE: 'Откриј више',
FOLLOWING: 'Пратиш',
HOME: 'Почетна',
MUTE_THIS_CONVERSATION: 'Игнориши овај разговор',
QUOTE_TWEET: 'твит са цитатом',
QUOTE_TWEETS: 'твит(ов)а са цитатом',
RETWEETS: 'Ретвитови',
SHARED_TWEETS: 'Дељени твитови',
TWITTER: 'Твитер',
},
sv: {
ADD_MUTED_WORD: 'Lägg till ignorerat ord',
DISCOVER_MORE: 'Upptäck mer',
FOLLOWING: 'Följer',
HOME: 'Hem',
MUTE_THIS_CONVERSATION: 'Ignorera den här konversationen',
QUOTE_TWEET: 'Citera Tweet',
QUOTE_TWEETS: 'Citat-tweets',
SHARED_TWEETS: 'Delade tweetsen',
},
ta: {
ADD_MUTED_WORD: 'செயல்மறைத்த வார்த்தையைச் சேர்',
DISCOVER_MORE: 'மேலும் கண்டறியவும்',
FOLLOWING: 'பின்தொடர்கிறீர்கள்',
HOME: 'முகப்பு',
MUTE_THIS_CONVERSATION: 'இந்த உரையாடலை செயல்மறை',
QUOTE_TWEET: 'ட்விட்டை மேற்கோள் காட்டு',
QUOTE_TWEETS: 'மேற்கோள் கீச்சுகள்',
RETWEETS: 'மறுகீச்சுகள்',
SHARED_TWEETS: 'பகிரப்பட்ட ட்வீட்டுகள்',
},
th: {
ADD_MUTED_WORD: 'เพิ่มคำที่ซ่อน',
DISCOVER_MORE: 'ค้นหาเพิ่มเติม',
FOLLOWING: 'กําลังติดตาม',
HOME: 'หน้าแรก',
MUTE_THIS_CONVERSATION: 'ซ่อนบทสนทนานี้',
QUOTE_TWEET: 'อ้างอิงทวีต',
QUOTE_TWEETS: 'ทวีตและคำพูด',
RETWEETS: 'รีทวีต',
SHARED_TWEETS: 'ทวีตที่แชร์',
TWITTER: 'ทวิตเตอร์',
},
tr: {
ADD_MUTED_WORD: 'Sessize alınacak kelime ekle',
DISCOVER_MORE: 'Daha fazlasını keşfet',
FOLLOWING: 'Takip ediliyor',
HOME: 'Anasayfa',
MUTE_THIS_CONVERSATION: 'Bu sohbeti sessize al',
QUOTE_TWEET: 'Tweeti Alıntıla',
QUOTE_TWEETS: 'Alıntı Tweetler',
RETWEETS: 'Retweetler',
SHARED_TWEETS: 'Paylaşılan Tweetler',
},
uk: {
ADD_MUTED_WORD: 'Додати слово до списку ігнорування',
DISCOVER_MORE: 'Дізнавайтеся більше',
FOLLOWING: 'Читає(те)',
HOME: 'Головна',
MUTE_THIS_CONVERSATION: 'Ігнорувати цю розмову',
QUOTE_TWEET: 'Цитувати твіт',
QUOTE_TWEETS: 'Цитовані твіти',
RETWEETS: 'Ретвіти',
SHARED_TWEETS: 'Спільні твіти',
TWITTER: 'Твіттер',
},
ur: {
ADD_MUTED_WORD: 'میوٹ شدہ لفظ شامل کریں',
DISCOVER_MORE: 'مزید دریافت کریں',
FOLLOWING: 'فالو کر رہے ہیں',
HOME: 'ہوم',
MUTE_THIS_CONVERSATION: 'اس گفتگو کو میوٹ کریں',
QUOTE_TWEET: 'ٹویٹ کا حوالہ دیں',
QUOTE_TWEETS: 'ٹویٹ کو نقل کرو',
RETWEETS: 'ریٹویٹس',
SHARED_TWEETS: 'مشترکہ ٹویٹس',
TWITTER: 'ٹوئٹر',
},
vi: {
ADD_MUTED_WORD: 'Thêm từ tắt tiếng',
DISCOVER_MORE: 'Khám phá thêm',
FOLLOWING: 'Đang theo dõi',
HOME: 'Trang chủ',
MUTE_THIS_CONVERSATION: 'Tắt tiếng cuộc trò chuyện này',
QUOTE_TWEET: 'Trích dẫn Tweet',
QUOTE_TWEETS: 'Tweet trích dẫn',
RETWEETS: 'Các Tweet lại',
SHARED_TWEETS: 'Tweet được chia sẻ',
},
'zh-Hant': {
ADD_MUTED_WORD: '加入靜音文字',
DISCOVER_MORE: '探索更多',
FOLLOWING: '正在跟隨',
HOME: '首頁',
MUTE_THIS_CONVERSATION: '將此對話靜音',
QUOTE_TWEET: '引用推文',
QUOTE_TWEETS: '引用的推文',
RETWEETS: '轉推',
SHARED_TWEETS: '分享的推文',
},
zh: {
ADD_MUTED_WORD: '添加要隐藏的字词',
DISCOVER_MORE: '发现更多',
FOLLOWING: '正在关注',
HOME: '主页',
MUTE_THIS_CONVERSATION: '隐藏此对话',
QUOTE_TWEET: '引用推文',
QUOTE_TWEETS: '引用推文',
RETWEETS: '转推',
SHARED_TWEETS: '分享的推文',
},
}
/**
* @param {import("./types").LocaleKey} code
* @returns {string}
*/
function getString(code) {
return (locales[lang] || locales['en'])[code] || locales['en'][code];
}
//#endregion
//#region Config & variables
/** @enum {string} */
const PagePaths = {
ADD_MUTED_WORD: '/settings/add_muted_keyword',
BOOKMARKS: '/i/bookmarks',
COMPOSE_MESSAGE: '/messages/compose',
COMPOSE_TWEET: '/compose/tweet',
CONNECT: '/i/connect',
CUSTOMIZE_YOUR_VIEW: '/i/display',
HOME: '/home',
NOTIFICATION_TIMELINE: '/i/timeline',
PROFILE_SETTINGS: '/settings/profile',
SEARCH: '/search',
}
/** @enum {string} */
const Selectors = {
BLOCK_MENU_ITEM: '[data-testid="block"]',
DESKTOP_TIMELINE_HEADER: 'div[data-testid="primaryColumn"] > div > div:first-of-type',
DISPLAY_DONE_BUTTON_DESKTOP: '#layers div[role="button"]:not([aria-label])',
DISPLAY_DONE_BUTTON_MOBILE: 'main div[role="button"]:not([aria-label])',
MESSAGES_DRAWER: 'div[data-testid="DMDrawer"]',
MOBILE_TIMELINE_HEADER_OLD: 'header > div:nth-of-type(2) > div:first-of-type',
MOBILE_TIMELINE_HEADER_NEW: 'div[data-testid="TopNavBar"]',
NAV_HOME_LINK: 'a[data-testid="AppTabBar_Home_Link"]',
PRIMARY_COLUMN: 'div[data-testid="primaryColumn"]',
PRIMARY_NAV_DESKTOP: 'header nav',
PRIMARY_NAV_MOBILE: '#layers nav',
PROMOTED_TWEET_CONTAINER: '[data-testid="placementTracking"]',
SIDEBAR: 'div[data-testid="sidebarColumn"]',
SIDEBAR_WRAPPERS: 'div[data-testid="sidebarColumn"] > div > div > div > div > div',
TIMELINE: 'div[data-testid="primaryColumn"] section > h1 + div[aria-label] > div',
TIMELINE_HEADING: 'h2[role="heading"]',
TWEET: '[data-testid="tweet"]',
VERIFIED_TICK: 'svg path[d^="M22.25 12c0-1.43-.88-2.67-2.19-3.34.46-1.39.2-2.9-.81-3.91s-2.52-1.27-3.91-.81c-.66-1.31-1.91-2."]',
}
/** @enum {string} */
const Svgs = {
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',
HOME: '<g><path d="M12 9c-2.209 0-4 1.791-4 4s1.791 4 4 4 4-1.791 4-4-1.791-4-4-4zm0 6c-1.105 0-2-.895-2-2s.895-2 2-2 2 .895 2 2-.895 2-2 2zm0-13.304L.622 8.807l1.06 1.696L3 9.679V19.5C3 20.881 4.119 22 5.5 22h13c1.381 0 2.5-1.119 2.5-2.5V9.679l1.318.824 1.06-1.696L12 1.696zM19 19.5c0 .276-.224.5-.5.5h-13c-.276 0-.5-.224-.5-.5V8.429l7-4.375 7 4.375V19.5z"></path></g>',
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>',
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>',
}
const PROFILE_FOLLOWS_URL_RE = /\/[a-zA-Z\d_]{1,20}\/(following|followers|followers_you_follow)\/?$/
const PROFILE_TABS_URL_RE = /\/[a-zA-Z\d_]{1,20}\/(with_replies|media|likes)\/?$/
// https://twitter.com/${user}'s title ends with (@${user})
const PROFILE_TITLE_RE = /\(@[a-zA-Z\d_]{1,20}\)$/
const THEME_COLORS = new Set([
'rgb(29, 155, 240)', // blue
'rgb(255, 212, 0)', // yellow
'rgb(244, 33, 46)', // pink
'rgb(120, 86, 255)', // purple
'rgb(255, 122, 0)', // orange
'rgb(0, 186, 124)', // green
])
const TITLE_NOTIFICATION_RE = /^\(\d+\+?\) /
const URL_PHOTO_RE = /photo\/\d$/
const URL_LIST_RE = /\/i\/lists\/\d+$/
const URL_TWEET_ID_RE = /\/status\/(\d+)$/
/**
* The quoted Tweet associated with a caret menu that's just been opened.
* @type {import("./types").QuotedTweet}
*/
let quotedTweet = null
/** `true` when a 'Block @${user}' menu item was seen in the last popup. */
let blockMenuItemSeen = false
/** `'Home'` or `'Following'` page title. */
let currentMainTimelineType = ''
/** Notification count in the title (including trailing space), e.g. `'(1) '`. */
let currentNotificationCount = ''
/** Title of the current page, without the `' / Twitter'` suffix. */
let currentPage = ''
/** Current `location.pathname`. */
let currentPath = ''
/**
* CSS rule in the React Native stylesheet which defines the Chirp font-family
* and fallbacks for the whole app.
* @type {CSSStyleRule}
*/
let fontFamilyRule = null
/** @type {string} */
let fontSize = null
/** Set to `true` when a Home/Following heading or Home nav link is used. */
let homeNavigationIsBeingUsed = false
/**
* Cache for the last page title which was used for the main timeline.
* @type {string}
*/
let lastMainTimelineTitle = null
/**
* MutationObservers active on the current page, or anything else we want to
* clean up when the user moves off the current page.
* @type {(import("./types").NamedMutationObserver|{disconnect(): void})[]}
*/
let pageObservers = []
/**
* Title for the fake timeline used to separate out retweets and quote tweets.
* @type {string}
*/
let separatedTweetsTimelineTitle = null
/**
* The current "Color" setting, which can be changed in "Customize your view".
* @type {string}
*/
let themeColor = null
/**
* `true` when "For you" was the last tab selected on the main timeline.
*/
let wasForYouTabSelected = false
function isOnExplorePage() {
return currentPath.startsWith('/explore')
}
function isOnHomeTimeline() {
return currentPage == getString('HOME')
}
function isOnIndividualTweetPage() {
return URL_TWEET_ID_RE.test(currentPath)
}
function isOnLatestTweetsTimeline() {
return currentPage == getString('FOLLOWING')
}
function isOnListPage() {
return URL_LIST_RE.test(currentPath)
}
function isOnMainTimelinePage() {
return currentPath == PagePaths.HOME || (
currentPath == PagePaths.CUSTOMIZE_YOUR_VIEW &&
isOnHomeTimeline() ||
isOnLatestTweetsTimeline() ||
isOnSeparatedTweetsTimeline()
)
}
function isOnNotificationsPage() {
return currentPath.startsWith('/notifications')
}
function isOnProfilePage() {
return PROFILE_TITLE_RE.test(currentPage) && !PROFILE_FOLLOWS_URL_RE.test(currentPath)
}
function isOnQuoteTweetsPage() {
return currentPath.endsWith('/retweets/with_comments')
}
function isOnSearchPage() {
return currentPath.startsWith('/search') || currentPath.startsWith('/hashtag/')
}
function isOnSeparatedTweetsTimeline() {
return currentPage == separatedTweetsTimelineTitle
}
function isOnTopicsPage() {
return currentPath != '/topics' && Boolean(currentPath.match(/\/topics(\/|$)/))
}
function shouldHideSidebar() {
return isOnExplorePage()
}
//#endregion
//#region Utility functions
/**
* @param {string} role
* @return {HTMLStyleElement}
*/
function addStyle(role) {
let $style = document.createElement('style')
$style.dataset.insertedBy = 'tweak-new-twitter'
$style.dataset.role = role
document.head.appendChild($style)
return $style
}
/**
* @param {string} str
* @return {string}
*/
function dedent(str) {
str = str.replace(/^[ \t]*\r?\n/, '')
let indent = /^[ \t]+/m.exec(str)
if (indent) str = str.replace(new RegExp('^' + indent[0], 'gm'), '')
return str.replace(/(\r?\n)[ \t]+$/, '$1')
}
/**
* @param {string} name
*/
function disconnectPageObserver(name) {
for (let i = pageObservers.length -1; i >= 0; i--) {
let pageObserver = pageObservers[i]
if ('name' in pageObserver && pageObserver.name == name) {
pageObserver.disconnect()
pageObservers.splice(i, 1)
log(`disconnected ${name} page observer`)
}
}
}
/**
* @param {string} selector
* @param {{
* name?: string
* stopIf?: () => boolean
* timeout?: number
* context?: Document | HTMLElement
* }} [options]
* @returns {Promise<HTMLElement | null>}
*/
function getElement(selector, {
name = null,
stopIf = null,
timeout = Infinity,
context = document,
} = {}) {
return new Promise((resolve) => {
let startTime = Date.now()
let rafId
let timeoutId
function stop($element, reason) {
if ($element == null) {
warn(`stopped waiting for ${name || selector} after ${reason}`)
}
else if (Date.now() > startTime) {
log(`${name || selector} appeared after ${Date.now() - startTime}ms`)
}
if (rafId) {
cancelAnimationFrame(rafId)
}
if (timeoutId) {
clearTimeout(timeoutId)
}
resolve($element)
}
if (timeout !== Infinity) {
timeoutId = setTimeout(stop, timeout, null, `${timeout}ms timeout`)
}
function queryElement() {
let $element = context.querySelector(selector)
if ($element) {
stop($element)
}
else if (stopIf?.() === true) {
stop(null, 'stopIf condition met')
}
else {
rafId = requestAnimationFrame(queryElement)
}
}
queryElement()
})
}
function log(...args) {
if (debug) {
console.log(`🧨${currentPage ? `(${currentPage})` : ''}`, ...args)
}
}
function warn(...args) {
if (debug) {
console.log(`⚠${currentPage ? `(${currentPage})` : ''}`, ...args)
}
}
function error(...args) {
console.log(`❌${currentPage ? `(${currentPage})` : ''}`, ...args)
}
/**
* @param {() => boolean} condition
* @returns {() => boolean}
*/
function not(condition) {
return () => !condition()
}
/**
* Convenience wrapper for the MutationObserver API - the callback is called
* immediately to support using an observer and its options as a trigger for any
* change, without looking at MutationRecords.
* @param {Node} $element
* @param {MutationCallback} callback
* @param {string} name
* @param {MutationObserverInit} options
* @return {import("./types").NamedMutationObserver}
*/
function observeElement($element, callback, name = '', options = {childList: true}) {
if (name) {
if (options.childList && callback.length > 0) {
log(`observing ${name}`, $element)
} else {
log (`observing ${name}`)
}
}
let observer = new MutationObserver(callback)
callback([], observer)
observer.observe($element, options)
observer['name'] = name
return observer
}
/**
* @param {Partial<import("./types").Config>} configChanges
*/
function onSettingsChanged(configChanges) {
if ('debug' in configChanges) {
log('disabling debug mode')
debug = configChanges.debug
log('enabled debug mode')
configureThemeCss()
return
}
Object.assign(config, configChanges)
configChanged(configChanges)
}
/**
* @param {string} page
* @returns {() => boolean}
*/
function pageIsNot(page) {
return () => page != currentPage
}
/**
* @param {string} path
* @returns {() => boolean}
*/
function pathIsNot(path) {
return () => path != currentPath
}
/**
* @param {number} n
* @returns {string}
*/
function s(n) {
return n == 1 ? '' : 's'
}