forked from pparker1930/TwitterYoutubeHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTwitter_X_Youtube_Helper.js
1428 lines (1373 loc) · 66.5 KB
/
Twitter_X_Youtube_Helper.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 Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:ja Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:fr Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:de Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:it Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:ko Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:ru Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:pt Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:es Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:th Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:tr Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:nl Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:pl Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:hr Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:fi Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:el Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:hu Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:id Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:nb Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:sk Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:sr Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:bg Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:cs Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:vi Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:ro Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:sv Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @name:uk Twitter(X)ᴾˡᵘˢ+++ ; Youtubeᴾˡᵘˢ+++
// @description The script will provide some enhancements to Twitter(X) and Youtube, such as: adding time formatting display, high-definition image display, image and video downloading, etc. to Twitter(X), adding video downloading, removing ads, etc. to Youtube. For more function introductions, please check the description~
// @description:ja このスクリプトは、Twitter (X) と Youtube にいくつかの拡張機能を提供します。たとえば、時刻の書式設定表示の追加、高解像度の画像表示、Twitter (X) の画像とビデオのダウンロード、Youtube のビデオダウンロードの追加、広告の削除などです。 。詳しい機能紹介については説明をご確認ください~
// @description:fr Le script fournira des fonctions améliorées pour Twitter (X) et Youtube, telles que : l'ajout de l'affichage du formatage de l'heure, l'affichage d'images haute définition, le téléchargement d'images et de vidéos pour Twitter (X), l'ajout de téléchargement de vidéos, la suppression de publicités, etc. pour Youtube . Veuillez vérifier la description pour plus d'introduction aux fonctions ~
// @description:de Das Skript bietet einige erweiterte Funktionen für Twitter (X) und Youtube, wie zum Beispiel: Hinzufügen einer Zeitformatierungsanzeige, hochauflösende Bildanzeige, Herunterladen von Bildern und Videos für Twitter (X), Hinzufügen von Video-Downloads, Entfernen von Werbung usw. für Youtube . Weitere Funktionseinführungen finden Sie in der Beschreibung
// @description:it Lo script fornirà alcune funzioni migliorate per Twitter (X) e Youtube, come: aggiunta della visualizzazione della formattazione dell'ora, visualizzazione di immagini ad alta definizione, download di immagini e video per Twitter (X), aggiunta del download di video, rimozione di pubblicità, ecc. per Youtube . Si prega di controllare la descrizione per ulteriori informazioni sulle funzioni~
// @description:ko 스크립트는 Twitter(X) 및 Youtube에 시간 형식 표시 추가, 고화질 사진 표시, Twitter(X)용 사진 및 비디오 다운로드, Youtube용 비디오 다운로드 추가, 광고 제거 등과 같은 몇 가지 향상된 기능을 제공합니다. . 자세한 기능 소개는 설명을 확인해주세요~
// @description:es El script proporcionará algunas funciones mejoradas para Twitter (X) y Youtube, tales como: agregar visualización de formato de hora, visualización de imágenes de alta definición, descarga de imágenes y videos para Twitter (X), agregar descarga de videos, eliminar anuncios, etc. para Youtube. . Consulte la descripción para obtener más información sobre la función ~
// @description:ru Скрипт предоставит некоторые расширенные функции для Twitter (X) и Youtube, такие как: добавление отображения форматирования времени, отображение изображений высокой четкости, загрузка изображений и видео для Twitter (X), добавление загрузки видео, удаление рекламы и т. д. для Youtube. . Пожалуйста, проверьте описание для получения дополнительной информации о функциях ~
// @description:pt O script fornecerá algumas funções aprimoradas para Twitter (X) e Youtube, como: adição de exibição de formatação de hora, exibição de imagens em alta definição, download de imagens e vídeos para Twitter (X), adição de download de vídeos, remoção de anúncios, etc. . Por favor, verifique a descrição para mais introdução à função ~
// @description:th สคริปต์นี้จะมอบฟังก์ชันที่ได้รับการปรับปรุงบางอย่างสำหรับ Twitter (X) และ Youtube เช่น: การเพิ่มการแสดงการจัดรูปแบบเวลา การแสดงภาพความละเอียดสูง การดาวน์โหลดรูปภาพและวิดีโอสำหรับ Twitter (X) เพิ่มการดาวน์โหลดวิดีโอ การลบโฆษณา ฯลฯ สำหรับ Youtube . โปรดตรวจสอบคำอธิบายสำหรับการแนะนำฟังก์ชันเพิ่มเติม~
// @description:tr Komut dosyası, Twitter (X) ve Youtube için bazı gelişmiş işlevler sağlayacaktır; örneğin: zaman biçimlendirme ekranı ekleme, yüksek çözünürlüklü resim görüntüleme, Twitter (X) için resim ve video indirme, Youtube için video indirme ekleme, reklamları kaldırma vb. . Daha fazla fonksiyon tanıtımı için lütfen açıklamayı kontrol edin~
// @description:nl Het script biedt een aantal verbeterde functies voor Twitter (X) en YouTube, zoals: het toevoegen van tijdopmaakweergave, high-definition beeldweergave, het downloaden van foto's en video's voor Twitter (X), het toevoegen van videodownloads, het verwijderen van advertenties, enz. voor YouTube . Controleer de beschrijving voor meer functie-introductie~
// @description:pl Skrypt zapewni ulepszone funkcje dla Twittera (X) i YouTube, takie jak: dodanie wyświetlania formatowania czasu, wyświetlanie obrazu w wysokiej rozdzielczości, pobieranie zdjęć i wideo dla Twittera (X), dodawanie pobierania wideo, usuwanie reklam itp. dla Youtube . Proszę sprawdzić opis, aby uzyskać więcej informacji na temat funkcji~
// @description:hr Skripta će omogućiti neke poboljšane funkcije za Twitter (X) i Youtube, kao što su: dodavanje prikaza formatiranja vremena, prikaz slike visoke razlučivosti, preuzimanje slika i videa za Twitter (X), dodavanje preuzimanja videa, uklanjanje reklama itd. za Youtube . Molimo provjerite opis za više predstavljanja funkcija~
// @description:fi Käsikirjoitus tarjoaa joitain parannettuja toimintoja Twitterille (X) ja Youtubelle, kuten: aikamuotoilunäytön lisääminen, teräväpiirtokuvanäyttö, kuvien ja videoiden lataaminen Twitteriin (X), videolatauksen lisääminen, mainosten poistaminen jne. Youtubessa . Katso kuvauksesta lisätietoja toimintojen esittelystä~
// @description:el Το σενάριο θα παρέχει ορισμένες βελτιωμένες λειτουργίες για το Twitter (X) και το Youtube, όπως: προσθήκη οθόνης μορφοποίησης ώρας, προβολή εικόνων υψηλής ευκρίνειας, λήψη εικόνων και βίντεο για το Twitter (X), προσθήκη λήψης βίντεο, αφαίρεση διαφημίσεων κ.λπ. για το YouTube . Ελέγξτε την περιγραφή για περισσότερη εισαγωγή της λειτουργίας~
// @description:hu A szkript néhány továbbfejlesztett funkciót biztosít a Twitter (X) és a Youtube számára, mint például: időformátum-megjelenítés hozzáadása, nagy felbontású képmegjelenítés, kép- és videóletöltés a Twitterhez (X), videóletöltés hozzáadása, hirdetések eltávolítása stb. . Kérjük, tekintse meg a leírást a további funkciók bemutatásához~
// @description:id Script akan menyediakan beberapa fungsi yang ditingkatkan untuk Twitter (X) dan Youtube, seperti: menambahkan tampilan pemformatan waktu, tampilan gambar definisi tinggi, pengunduhan gambar dan video untuk Twitter (X), menambahkan pengunduhan video, menghapus iklan, dll. untuk Youtube . Silakan periksa deskripsi untuk pengenalan fungsi lebih lanjut~
// @description:nb Skriptet vil gi noen forbedrede funksjoner for Twitter (X) og Youtube, for eksempel: legge til tidsformateringsvisning, høyoppløselig bildevisning, bilde- og videonedlasting for Twitter (X), legge til videonedlasting, fjerne annonser osv. for Youtube . Vennligst sjekk beskrivelsen for mer funksjonsintroduksjon~
// @description:ro Scriptul va oferi câteva funcții îmbunătățite pentru Twitter (X) și Youtube, cum ar fi: adăugarea de afișare cu formatare a timpului, afișarea imaginilor de înaltă definiție, descărcarea de imagini și videoclipuri pentru Twitter (X), adăugarea de descărcare video, eliminarea reclamelor etc. pentru Youtube . Vă rugăm să verificați descrierea pentru mai multe introducere a funcției~
// @description:sk Skript poskytne niektoré vylepšené funkcie pre Twitter (X) a Youtube, ako napríklad: pridanie zobrazenia formátovania času, zobrazenie obrázkov vo vysokom rozlíšení, sťahovanie obrázkov a videí pre Twitter (X), pridanie sťahovania videa, odstránenie reklám atď. pre Youtube . Pozrite si popis pre ďalšie predstavenie funkcií~
// @description:sr Скрипта ће обезбедити неке побољшане функције за Твиттер (Кс) и Иоутубе, као што су: додавање приказа форматирања времена, приказ слике високе дефиниције, преузимање слика и видео записа за Твиттер (Кс), додавање преузимања видео записа, уклањање реклама, итд. за Иоутубе . Молимо погледајте опис за више упознавања са функцијама~
// @description:sv Skriptet kommer att tillhandahålla några förbättrade funktioner för Twitter (X) och Youtube, såsom: lägga till tidsformateringsvisning, högupplöst bildvisning, bild- och videonedladdning för Twitter (X), lägga till videonedladdning, ta bort annonser etc. för Youtube . Kontrollera beskrivningen för mer funktionsintroduktion~
// @description:uk Сценарій забезпечить деякі розширені функції для Twitter (X) і Youtube, такі як: додавання дисплея форматування часу, відображення зображення високої чіткості, завантаження зображень і відео для Twitter (X), додавання завантаження відео, видалення реклами тощо для Youtube . Будь ласка, перегляньте опис, щоб дізнатися більше про функції ~
// @description:vi Kịch bản sẽ cung cấp một số chức năng nâng cao cho Twitter (X) và Youtube như: thêm hiển thị định dạng thời gian, hiển thị hình ảnh độ phân giải cao, tải ảnh và video cho Twitter (X), thêm tải video, xóa quảng cáo, v.v. cho Youtube . Vui lòng kiểm tra mô tả để biết thêm giới thiệu chức năng ~
// @description:bg Скриптът ще предостави някои подобрени функции за Twitter (X) и Youtube, като например: добавяне на дисплей за форматиране на времето, показване на картина с висока разделителна способност, изтегляне на картина и видео за Twitter (X), добавяне на изтегляне на видео, премахване на реклами и др. за Youtube . Моля, проверете описанието за повече представяне на функцията ~
// @description:cs Skript poskytne některé vylepšené funkce pro Twitter (X) a Youtube, jako je: přidání zobrazení formátování času, zobrazení obrázků ve vysokém rozlišení, stahování obrázků a videí pro Twitter (X), přidání stahování videa, odstranění reklam atd. pro Youtube . Další informace o funkcích naleznete v popisu~
// @icon data:image/png;base64,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
// @namespace PeterParker_X_Y_NameScope
// @version 1.0.5
// @author PeterParker
// @include *://x.com/*
// @include *://twitter.com/*
// @include *://mobile.x.com/*
// @include *://www.youtube.com/watch**
// @include *://www.youtube.com/shorts**
// @include *://www.tiktok.com/@*
// @exclude *://accounts.youtube.com/*
// @exclude *://www.youtube.com/live_chat_replay*
// @exclude *://www.youtube.com/persist_identity*
// @exclude *://x.com/i/flow/*
// @grant GM_registerMenuCommand
// @grant GM_openInTab
// @grant GM.openInTab
// @grant GM_addStyle
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_xmlhttpRequest
// @grant GM_download
// @connect api.cobalt.tools
// @connect tikdownloader.io
// @license MIT
// @charset UTF-8
// @run-at document-idle
// ==/UserScript==
(function(){
'use strict';
/**
* Copyright (c) 2024, PeterParker. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
const host = window.location.host;
const lang = (navigator.language.indexOf("-")!=-1 ? navigator.language.split("-")[0] : navigator.language).toLocaleLowerCase();
const language={
"zh":{
"dateFormat":{
"week":['日', '一', '二', '三', '四', '五', '六']
},
"download":{
"download": '下载', "completed": '下载完成', "tip":"点击下载视频"
,"preparing":"正在准备下载,请稍后..."
},
"menuCommand":{
"command":"设置", "titleDateFormat":"时间格式设置:","buttonClose":"关闭"
}
},
"en":{
"dateFormat":{
"week":['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']
},
"download":{
"download": 'Download', "completed": 'Download Completed', "tip":"Click to download video"
,"preparing":"Preparing to download, please wait..."
},
"menuCommand":{
"command":"Settings", "titleDateFormat":"Time format settings:", "buttonClose":"Close"
}
},
"ja":{
"dateFormat":{
"week":['日', '月', '火', '水', '木', '金', '土']
},
"download":{
"download": 'ダウンロード', "completed": 'ダウンロード完了',"tip":"クリックしてビデオをダウンロード"
,"preparing":"ダウンロードの準備をしています。お待ちください..."
},
"menuCommand":{
"command":"設定", "titleDateFormat":"時刻形式の設定:", "buttonClose":"閉鎖"
}
},
"fr":{
"dateFormat":{
"week":['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam']
},
"download":{
"download": 'télécharger', "completed": 'éléchargement terminé', "tip":"Cliquez pour télécharger la vidéo"
,"preparing":"Vous êtes en train de télécharger, veuillez patienter..."
},
"menuCommand":{
"command":"installation", "titleDateFormat":"Paramètres du format de l'heure :","buttonClose":"fermeture"
}
},
"de":{
"dateFormat":{
"week":['Son', 'Mon', 'Die', 'Mit', 'Don', 'Fre', 'Sam']
},
"download":{
"download": 'herunterladen', "completed": 'Download abgeschlossen',"tip":"Klicken Sie hier, um das Video herunterzuladen"
,"preparing":"Der Download wird vorbereitet, bitte warten..."
},
"menuCommand":{
"command":"aufstellen", "titleDateFormat":"Einstellungen für das Zeitformat:","buttonClose":"Schließung"
}
},
"it":{
"dateFormat":{
"week":['Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab']
},
"download":{
"download": 'scaricamento', "completed": 'Download completato', "tip":"Fare clic per scaricare il video"
,"preparing":"Preparazione al download, attendere..."
},
"menuCommand":{
"command":"impostare", "titleDateFormat":"Impostazioni del formato dell'ora:","buttonClose":"chiusura"
}
},
"ko":{
"dateFormat":{
"week":['일', '월', '화', '수', '목', '금', '토']
},
"download":{
"download": '다운로드', "completed": '다운로드 완료',"tip":"비디오를 다운로드하려면 클릭하세요"
,"preparing":"다운로드 준비 중입니다. 잠시 기다려 주세요..."
},
"menuCommand":{
"command":"설정", "titleDateFormat":"시간 형식 설정:","buttonClose":"폐쇄"
}
},
"ru":{
"dateFormat":{
"week":['ВС', 'ПН', 'ВТ', 'СР', 'ЧТ', 'ПТ', 'СБ']
},
"download":{
"download": 'скачать', "completed": 'Загрузка завершена',"tip":"Нажмите, чтобы скачать видео"
,"preparing":"Подготовка к загрузке, пожалуйста, подождите..."
},
"menuCommand":{
"command":"настраивать", "titleDateFormat":"Настройки формата времени:","buttonClose":"закрытие"
}
},
"pt":{
"dateFormat":{
"week":['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb']
},
"download":{
"download": 'descargar', "completed": 'Descarga completa',"tip":"Clique para baixar o vídeo"
,"preparing":"Preparando o download, aguarde..."
},
"menuCommand":{
"command":"configuración", "titleDateFormat":"Configuración de formato de hora:","buttonClose":"cierre"
}
},
"es":{
"dateFormat":{
"week":['DOM', 'LUN', 'MAR', 'MIER', 'JUE', 'VIE', 'SÁB']
},
"download":{
"download": 'descargar', "completed": 'Descarga completa', "tip":"Haga clic para descargar el vídeo"
,"preparing":"Preparándose para descargar, espere..."
},
"menuCommand":{
"command":"configuración", "titleDateFormat":"Configuración de formato de hora:","buttonClose":"cierre"
}
}
}
const selectLanguage=()=>{
return language[lang] ?? language["en"];
}
const Toast={
initStyle:function(){
GM_addStyle(`
@keyframes fadeIn {
0% {opacity: 0}
100% {opacity: 1}
}
@-webkit-keyframes fadeIn {
0% {opacity: 0}
100% {opacity: 1}
}
@-moz-keyframes fadeIn {
0% {opacity: 0}
100% {opacity: 1}
}
@-o-keyframes fadeIn {
0% {opacity: 0}
100% {opacity: 1}
}
@-ms-keyframes fadeIn {
0% {opacity: 0}
100% {opacity: 1}
}
@keyframes fadeOut {
0% {opacity: 1}
100% {opacity: 0}
}
@-webkit-keyframes fadeOut {
0% {opacity: 1}
100% {opacity: 0}
}
@-moz-keyframes fadeOut {
0% {opacity: 1}
100% {opacity: 0}
}
@-o-keyframes fadeOut {
0% {opacity: 1}
100% {opacity: 0}
}
@-ms-keyframes fadeOut {
0% {opacity: 1}
100% {opacity: 0}
}
.toast-style-kk998y{
position: fixed;
background: rgba(0, 0, 0, 0.7);
color: #fff;
font-size: 14px;
line-height: 1;
padding:10px;
border-radius: 3px;
left: 50%;
transform: translateX(-50%);
-webkit-transform: translateX(-50%);
-moz-transform: translateX(-50%);
-o-transform: translateX(-50%);
-ms-transform: translateX(-50%);
z-index: 999999999999999999999999999;
white-space: nowrap;
}
.fadeOut{
animation: fadeOut .5s;
}
.fadeIn{
animation:fadeIn .5s;
}
`);
},
show:function(params){
let time = params.time;
let background = params.background;
let color = params.color;
let position = params.position; //center-top, center-bottom
let defaultMarginValue = 50;
if(time == undefined || time == ''){
time = 1500;
}
if(position==undefined || position==''){
position = "center-bottom";
}
const el = document.createElement("div");
if(background!=undefined && background!=''){
el.style.backgroundColor=background;
}
if(color!=undefined && color!=''){
el.style.color=color;
}
el.setAttribute("class", "toast-style-kk998y");
el.innerText = params.message;
el.style.zIndex=999999999;
if(position==="center-bottom"){
el.style.bottom = defaultMarginValue+"px";
}else{
el.style.top = defaultMarginValue+"px";
}
document.body.appendChild(el);
el.classList.add("fadeIn");
setTimeout(function () {
el.classList.remove("fadeIn");
el.classList.add("fadeOut");
el.addEventListener("animationend", function () {
document.body.removeChild(el);
});
el.addEventListener("webkitAnimationEnd", function () {
document.body.removeChild(el);
});
}, time);
}
}
/**
* Variable & Constant
*/
const FMT = 7; // 70/12/31(Th) 23:59
let fmt = FMT;
/**
* script value init
*/
const ScriptValue={
init:function(){
Toast.initStyle();
fmt = GM_getValue("fmt", FMT);
}
}
const SettingsDialog={
number:Math.ceil(Math.random()*100000000),
formats:[
"Do nothing",
"31.12.70 23:59",
"31.12.70 23:59:59",
"31.12.70(Th) 23:59",
"31.12.70(Th) 23:59:59",
"70/12/31 23:59",
"70/12/31 23:59:59",
"70/12/31(Th) 23:59",
"70/12/31(Th) 23:59:59 [ye/mo/da(we) ho:mi:se]",
"70-12/31 23:59",
"70-12/31 23:59'59",
"70-12/31(Th) 23:59",
"70-12/31(Th) 23:59'59",
"M59-12-31 23:59",
"M59-12-31 23:59:59",
"M59-12-31(Th) 23:59",
"M59-12-31(Th) 23:59:59"
],
make:function(){
let dialog = document.createElement('div');
dialog.className = 'dialog_u_'+this.number;
dialog.style.all = 'initial';
dialog.style.backgroundColor = 'rgb(235, 235, 235)';
dialog.style.borderRadius = '2px';
dialog.style.display = 'none';
dialog.style.fontFamily = 'monospace';
dialog.style.fontSize = '12px';
dialog.style.width = '480px';
dialog.style.paddingLeft = '5px';
dialog.style.paddingRight = '5px';
dialog.style.paddingTop = '5px';
dialog.style.paddingBottom = '5px';
dialog.style.position = 'fixed';
dialog.style.right = '8px';
dialog.style.top = '8px';
dialog.style.zIndex = '2147483647';
dialog.style.overflow = 'auto';
let formatsHtml = `<table border="0" style="width:100%;padding:5px;">`;
for(var i=1; i<=this.formats.length;i++){
if(i%2!=0){
formatsHtml += `<tr style="width:100%;">`;
}
formatsHtml += `<td width="50"><input type="radio" name="fmt" value="`+(i-1)+`" class="top_r" />`+(i+"."+this.formats[i-1])+`</td>`;
if(i%2==0){
formatsHtml += `</tr>`;
}
}
formatsHtml += `</table>`;
let html=`
<div style="font-size:15px;font-weight:bold;margin-bottom:5px;">`+selectLanguage().menuCommand.titleDateFormat+`</div>
<div>`+formatsHtml+`</div>
<div style="margin-top:15px;text-align:center;">
<button name="closex">`+selectLanguage().menuCommand.buttonClose+`</button>
</div>
`;
dialog.innerHTML = html;
return dialog;
},
addEvent:function(dialog){
dialog.querySelector("button[name='closex']").addEventListener("click", function(event){
for (let e of dialog.querySelectorAll('input[name="fmt"]')) {
if (e.checked) {
fmt = +e.value;
break;
}
}
GM_setValue('fmt', fmt);
dialog.style.display = 'none';
},false);
},
init:function(){
let dialog = this.make();
this.addEvent(dialog);
document.body.appendChild(dialog);
GM_registerMenuCommand(selectLanguage().menuCommand.command, function () {
if (dialog.style.display == 'none') {
dialog.querySelector('input[name="fmt"][value="' + fmt + '"]').checked = true;
dialog.style.display = 'block';
}
});
}
}
const Tools = {
platform:function(){
const isX = /twitter|x\.com$/.test(host);
const isAliexpress = /([a-zA-Z0-9]+\.)?aliexpress\.[a-zA-Z]+/.test(host);
const isYoutube = /youtube\.com$/.test(host);
const isAmazon = /www\.amazon\.com$/.test(host);
const isEbay = /www\.ebay\.[a-zA-Z]+/.test(host);
const isTiktok = /www\.tiktok\.com/.test(host);
if(isX) return "x";
if(isAliexpress) return "aliexpress";
if(isYoutube) return "youtube";
if(isAmazon) return "amazon";
if(isEbay) return "ebay";
if(isTiktok) return "tiktok";
return "unknown";
},
waitForElementByInterval: function(selector, target=document.body, allowEmpty = true, delay=10, maxDelay=10 * 1000){
return new Promise((resolve,reject) =>{
let totalDelay = 0;
let element = target.querySelector(selector);
let result = allowEmpty ? !!element : (!!element && !!element.innerHTML);
if(result){
resolve(element);
}
const elementInterval = setInterval(()=>{
if(totalDelay >= maxDelay){
clearInterval(elementInterval);
resolve(null);
}
element = target.querySelector(selector);
result = allowEmpty ? !!element : (!!element && !!element.innerHTML);
if(result){
clearInterval(elementInterval);
resolve(element);
}else{
totalDelay += delay;
}
}, delay);
});
},
randomNumber: function(){
return Math.ceil(Math.random()*100000000);
},
elementInContainer:function(container, element) {
return container.contains(element);
},
openInTab:function(url, options={"active":true, "insert":true, "setParent":true}){
if (typeof GM_openInTab === "function") {
GM_openInTab(url, options);
} else {
GM.openInTab(url, options);
}
},
request:function(mothed, url, param, headers={"Content-Type": "application/json;charset=UTF-8"}){
return new Promise(function(resolve, reject){
GM_xmlhttpRequest({
url: url,
method: mothed,
data:param,
headers:headers,
onload: function(response) {
const status = response.status;
if(status==200 || status=='200'){
var responseText = response.responseText;
resolve({"code":"success", "result":responseText});
}else{
resolve({"code":"error", "result":null});
}
},
onabort:function(){
resolve({"code":"error", "result":null});
},
onerror:function(){
resolve({"code":"error", "result":null});
}
});
})
}
}
/**
* The code here is referenced from:
* https://qiita.com/libraplanet/items/0bdd7ef1a13e7af8f48f
* https://greasyfork.org/zh-CN/scripts/462064-show-date-normally-on-twitter
*
* Optimization was made based on the source code and some bugs were modified.
* Include Fun XDateFormat、XOrigimg,XHidepromo
*
* Author:@PeterParker & @AeamaN & @libraplanet
*/
const XDateFormat = {
df:function(date, f){
const WEEK = selectLanguage().dateFormat.week;
const YE = date.getFullYear().toString().slice(-2);
const YM = date.getFullYear() - 1911;
const MO = ('0' + (date.getMonth() + 1)).slice(-2);
const DA = ('0' + date.getDate()).slice(-2);
const WE = WEEK[date.getDay()];
const HO = ('0' + date.getHours()).slice(-2);
const MI = ('0' + date.getMinutes()).slice(-2);
const SE = ('0' + date.getSeconds()).slice(-2);
const F = [
DA+'.'+MO+'.'+YE+' '+HO+':'+MI, // 0=1
DA+'.'+MO+'.'+YE+' '+HO+':'+MI+':'+SE,
DA+'.'+MO+'.'+YE+'('+WE+') '+HO+':'+MI,
DA+'.'+MO+'.'+YE+'('+WE+') '+HO+':'+MI+':'+SE,
YE+'/'+MO+'/'+DA+' '+HO+':'+MI,
YE+'/'+MO+'/'+DA+' '+HO+':'+MI+':'+SE,
YE+'/'+MO+'/'+DA+'('+WE+') '+HO+':'+MI,
YE+'/'+MO+'/'+DA+'('+WE+') '+HO+':'+MI+':'+SE,
YE+'-'+MO+'/'+DA+' '+HO+':'+MI,
YE+'-'+MO+'/'+DA+' '+HO+':'+MI+"'"+SE,
YE+'-'+MO+'/'+DA+'('+WE+') '+HO+':'+MI,
YE+'-'+MO+'/'+DA+'('+WE+') '+HO+':'+MI+"'"+SE,
'M'+YM+'-'+MO+'-'+DA+' '+HO+':'+MI,
'M'+YM+'-'+MO+'-'+DA+' '+HO+':'+MI+":"+SE,
'M'+YM+'-'+MO+'-'+DA+'('+WE+') '+HO+':'+MI,
'M'+YM+'-'+MO+'-'+DA+'('+WE+') '+HO+':'+MI+":"+SE,
YE+'/'+MO+'/'+DA+'('+WE+') '+HO+':'+MI+':'+SE
];
return F[f - 1] ?? F[16];
},
repldatetime:function(){
const MYNAME = "peter_parker_x1190";
const SEL =
'main div[data-testid="primaryColumn"] section article time[datetime*=":"]';
const SEL_2 =
'div[aria-labelledby="modal-header"] div[data-testid^="User-Name"] time[datetime]';
const SEL_3 =
'div[aria-labelledby="modal-header"] div[aria-label] time[datetime]';
const SEL_4 =
'main section[aria-labelledby="detail-header"] article div[data-testid^="User-Name"] time[datetime]';
const SEL_5 =
'main section div[data-testid="conversation"] div[aria-label] time[datetime]'; // DM list
document.querySelectorAll(SEL + ', ' + SEL_2 + ', ' + SEL_3 + ', ' + SEL_4 + ', ' + SEL_5).forEach((e)=>{
const SEL_ADD = 'span.us-' + MYNAME;
let d = e.getAttribute('datetime');
let df = this.df(new Date(d), fmt);
let pe = e.parentNode;
let old = pe.querySelectorAll(SEL_ADD);
if (!old.length) {
let span = document.createElement('span');
span.className = 'us-' + MYNAME;
span.setAttribute('datetime', d);
span.setAttribute('local-datetime', df);
span.textContent = df;
span.style = e.style;
e.style.setProperty('display', 'none');
pe.appendChild(span);
} else if (old[0].getAttribute('local-datetime') != df) { // 时间发生变化
old[0].setAttribute('local-datetime', df);
old[0].textContent = df;
old[0].style = e.style;
}
})
}
}
/**
* Display the original size of the picture, which is clearer, but also consumes more traffic.
*/
const XOrigimg=()=>{
const SEL_D = 'div[style*="background-image:"]';
const SEL_I = 'img';
let elms = document.querySelectorAll(SEL_D + ', ' + SEL_I);
for (let e of elms) {
let regex = /^(.+pbs\.twimg\.com\/[^?]+\?format=\w+)(&|&)(name=)(\w+)([")]*)$/;
let ss; // Temp.
if (/div/i.test(e.tagName)) {
let r = regex.exec(e.style.backgroundImage);
if (r && r[4] != 'orig') {
e.style.backgroundImage = r[1] + r[2] + r[3] + 'orig' + r[5];
continue;
}
continue;
}
let r = regex.exec(e.getAttribute('src'));
if (r && r[4] != 'orig') {
e.setAttribute('src', r[1] + r[2] + r[3] + 'orig' + r[5]);
continue;
}
}
}
/**
* Hide promotional posts
*/
const XHidepromo=()=>{
const SEL = 'path[d^="M19.498 3h-15c-1.381 0-2.5 1.12-2.5 2.5v13c0 1.38 1.119 2.5"]';
const SEL_2 = 'main div[data-testid="sidebarColumn"] section div[data-testid="trend"] div.r-14gqq1x ' +
'span.css-1qaijid.r-bcqeeo.r-qvutc0'; // def-ja, def-en, ble-ja, ble-en
const SEL_3 = 'main div[data-testid="primaryColumn"] section article ' +
'span.css-1jxf684.r-bcqeeo.r-qvutc0.r-poiln3';
const SEL_4 =
'main div[data-testid="primaryColumn"] section ' +
'span.css-901oao.css-16my406.r-bcqeeo.r-qvutc0';
// Lone label def-ja, def-en, ble-ja, ble-en
let elms = document.querySelectorAll(SEL);
let elms_2 = document.querySelectorAll(SEL_2);
let elms_3 = document.querySelectorAll(SEL_3);
let elms_4 = document.querySelectorAll(SEL_4);
const PROMO = {
'ja': 'によるプロモーション$',
'ko': ' 님이 프로모션함$',
'zh': '^由 .+ 推广$',
'ru': '^Реклама от ',
'de': '^Gesponsert von ',
'it': '^Sponsorizzato da ',
'fr': '^Sponsorisé par ',
'pt': '^Promovido por ',
'en': '^Promoted by ' // Add your language
};
const PROMO_L = PROMO[lang] ?? PROMO['en'];
const PROMO_2 = {
'ja': 'プロモポスト',
'ko': 'Promoted Post',
'zh': '推广帖',
'ru': 'Promoted Post',
'de': 'Gesponserter Post',
'it': 'Promoted Post',
'fr': 'Promoted Post',
'pt': 'Post promovido',
'en': 'Promoted Post' // Add your language
};
const PROMO_L_2 = PROMO_2[lang] ?? PROMO_2['en'];
let ss; // Temp.
for (let e of elms) {
let xpe = e.closest('div[data-testid="cellInnerDiv"]');
if (!xpe) xpe = e.closest('div.css-175oi2r.r-1adg3ll.r-1ny4l3l'); // def-ja, def-en, ble-ja, ble-en
if (!xpe) xpe = e.closest('div.css-175oi2r.r-1ny4l3l[data-testid="UserCell"]'); // def-ja, def-en, ?, ble-en
if (xpe) xpe.style.setProperty('display', 'none'); // Right column のおすすめユーザー'
}
for (let e of elms_2) {
const REGEX = new RegExp(PROMO_L, 'i');
if (!REGEX.test(e.textContent)) continue;
let xpe = e.closest('div.css-175oi2r.r-1adg3ll.r-1ny4l3l');
xpe.style.setProperty('display', 'none');
}
for (let e of elms_3) {
if (e.textContent != 'Ad') continue;
let xpe = e.closest('div[data-testid="cellInnerDiv"]');
xpe.style.setProperty('display', 'none');
}
for (let e of elms_4) {
if (e.textContent != PROMO_2['en'] && e.textContent != PROMO_L_2) continue;
let xpe = e.closest('div[data-testid="cellInnerDiv"]');
xpe.style.setProperty('display', 'none');
}
}
/**
* The code here is referenced from:
* https://github.com/ne0lith/random-userscripts/blob/main/twitter-media-downloader.user.js
*
* The code adopts the MIT open source license. Please note that it is appreciated!
* Author:@PeterParker & @ne0lith
*/
const XDownload={
history:[],
show_sensitive:true,
is_tweetdeck:host.indexOf('tweetdeck') >= 0,
filename:'twitter_{user-name}(@{user-id})_{date-time}_{status-id}_{file-type}',
css: `
.tmd-down {margin-left: 12px; order: 99;}
.tmd-down:hover > div > div > div > div {color: rgba(29, 161, 242, 1.0);}
.tmd-down:hover > div > div > div > div > div {background-color: rgba(29, 161, 242, 0.1);}
.tmd-down:active > div > div > div > div > div {background-color: rgba(29, 161, 242, 0.2);}
.tmd-down:hover svg {color: rgba(29, 161, 242, 1.0);}
.tmd-down:hover div:first-child:not(:last-child) {background-color: rgba(29, 161, 242, 0.1);}
.tmd-down:active div:first-child:not(:last-child) {background-color: rgba(29, 161, 242, 0.2);}
.tmd-down.tmd-media {position: absolute; right: 0;}
.tmd-down.tmd-media > div {display: flex; border-radius: 99px; margin: 2px;}
.tmd-down.tmd-media > div > div {display: flex; margin: 6px; color: #fff;}
.tmd-down.tmd-media:hover > div {background-color: rgba(255,255,255, 0.6);}
.tmd-down.tmd-media:hover > div > div {color: rgba(29, 161, 242, 1.0);}
.tmd-down.tmd-media:not(:hover) > div > div {filter: drop-shadow(0 0 1px #000);}
.tmd-down g {display: none;}
.tmd-down.download g.download, .tmd-down.completed g.completed, .tmd-down.loading g.loading,.tmd-down.failed g.failed {display: unset;}
.tmd-down.loading svg {animation: spin 1s linear infinite;}
@keyframes spin {0% {transform: rotate(0deg);} 100% {transform: rotate(360deg);}}
.tmd-btn {display: inline-block; background-color: #1DA1F2; color: #FFFFFF; padding: 0 20px; border-radius: 99px;}
.tmd-tag {display: inline-block; background-color: #FFFFFF; color: #1DA1F2; padding: 0 10px; border-radius: 10px; border: 1px solid #1DA1F2; font-weight: bold; margin: 5px;}
.tmd-btn:hover {background-color: rgba(29, 161, 242, 0.9);}
.tmd-tag:hover {background-color: rgba(29, 161, 242, 0.1);}
.tmd-notifier {display: none; position: fixed; left: 16px; bottom: 16px; color: #000; background: #fff; border: 1px solid #ccc; border-radius: 8px; padding: 4px;}
.tmd-notifier.running {display: flex; align-items: center;}
.tmd-notifier label {display: inline-flex; align-items: center; margin: 0 8px;}
.tmd-notifier label:before {content: " "; width: 32px; height: 16px; background-position: center; background-repeat: no-repeat;}
.tmd-notifier label:nth-child(1):before {background-image:url("data:image/svg+xml;charset=utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%2216%22 height=%2216%22 viewBox=%220 0 24 24%22><path d=%22M3,14 v5 q0,2 2,2 h14 q2,0 2,-2 v-5 M7,10 l4,4 q1,1 2,0 l4,-4 M12,3 v11%22 fill=%22none%22 stroke=%22%23666%22 stroke-width=%222%22 stroke-linecap=%22round%22 /></svg>");}
.tmd-notifier label:nth-child(2):before {background-image:url("data:image/svg+xml;charset=utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%2216%22 height=%2216%22 viewBox=%220 0 24 24%22><path d=%22M12,2 a1,1 0 0 1 0,20 a1,1 0 0 1 0,-20 M12,5 v7 h6%22 fill=%22none%22 stroke=%22%23999%22 stroke-width=%222%22 stroke-linejoin=%22round%22 stroke-linecap=%22round%22 /></svg>");}
.tmd-notifier label:nth-child(3):before {background-image:url("data:image/svg+xml;charset=utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%2216%22 height=%2216%22 viewBox=%220 0 24 24%22><path d=%22M12,0 a2,2 0 0 0 0,24 a2,2 0 0 0 0,-24%22 fill=%22%23f66%22 stroke=%22none%22 /><path d=%22M14.5,5 a1,1 0 0 0 -5,0 l0.5,9 a1,1 0 0 0 4,0 z M12,17 a2,2 0 0 0 0,5 a2,2 0 0 0 0,-5%22 fill=%22%23fff%22 stroke=%22none%22 /></svg>");}
.tmd-down.tmd-img {position: absolute; right: 0; bottom: 0; display: none !important;}
.tmd-down.tmd-img > div {display: flex; border-radius: 99px; margin: 2px; background-color: rgba(255,255,255, 0.6);}
.tmd-down.tmd-img > div > div {display: flex; margin: 6px; color: #fff !important;}
.tmd-down.tmd-img:not(:hover) > div > div {filter: drop-shadow(0 0 1px #000);}
.tmd-down.tmd-img:hover > div > div {color: rgba(29, 161, 242, 1.0);}
:hover > .tmd-down.tmd-img, .tmd-img.loading, .tmd-img.completed, .tmd-img.failed {display: block !important;}
.tweet-detail-action-item {width: 20% !important;}
`,
css_ss: `
/* show sensitive in media tab */
li[role="listitem"]>div>div>div>div:not(:last-child) {filter: none;}
li[role="listitem"]>div>div>div>div+div:last-child {display: none;}
`,
svg: `
<g class="download"><path d="M3,14 v5 q0,2 2,2 h14 q2,0 2,-2 v-5 M7,10 l4,4 q1,1 2,0 l4,-4 M12,3 v11" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" /></g>
<g class="completed"><path d="M3,14 v5 q0,2 2,2 h14 q2,0 2,-2 v-5 M7,10 l3,4 q1,1 2,0 l8,-11" fill="none" stroke="#1DA1F2" stroke-width="2" stroke-linecap="round" /></g>
<g class="loading"><circle cx="12" cy="12" r="10" fill="none" stroke="#1DA1F2" stroke-width="4" opacity="0.4" /><path d="M12,2 a10,10 0 0 1 10,10" fill="none" stroke="#1DA1F2" stroke-width="4" stroke-linecap="round" /></g>
<g class="failed"><circle cx="12" cy="12" r="11" fill="#f33" stroke="currentColor" stroke-width="2" opacity="0.8" /><path d="M14,5 a1,1 0 0 0 -4,0 l0.5,9.5 a1.5,1.5 0 0 0 3,0 z M12,17 a2,2 0 0 0 0,4 a2,2 0 0 0 0,-4" fill="#fff" stroke="none" /></g>
`,
getCookie: function(){
const cookieString = document.cookie;
const cookiePairs = cookieString.split(';');
const cookiesObject = {};
for (const pair of cookiePairs) {
const [key, value] = pair.split('=');
cookiesObject[key.trim()] = value.trim();
}
return cookiesObject;
},
formatDate: function (i, o, tz) {
let d = new Date(i);
if (tz){
d.setMinutes(d.getMinutes() - d.getTimezoneOffset());
}
let m = ['JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC'];
let v = {
YYYY: d.getUTCFullYear().toString(),
YY: d.getUTCFullYear().toString(),
MM: d.getUTCMonth() + 1,
MMM: m[d.getUTCMonth()],
DD: d.getUTCDate(),
hh: d.getUTCHours(),
mm: d.getUTCMinutes(),
ss: d.getUTCSeconds(),
h2: d.getUTCHours() % 12,
ap: d.getUTCHours() < 12 ? 'AM' : 'PM'
};
return o.replace(/(YY(YY)?|MMM?|DD|hh|mm|ss|h2|ap)/g, n => ('0' + v[n]).substr(-n.length));
},
detect: function(node) {
let article = node.tagName == 'ARTICLE' && node || node.tagName == 'DIV' && (node.querySelector('article') || node.closest('article'));
if (article){
this.addButtonTo(article);
}
let listitems = node.tagName == 'LI' && node.getAttribute('role') == 'listitem' && [node] || node.tagName == 'DIV' && node.querySelectorAll('li[role="listitem"]');
if (listitems){
this.addButtonToMedia(listitems);
}
},
addButtonTo: function(article) {
if(article.dataset.detected){
return;
}
article.dataset.detected = 'true';
const media_selector = ['a[href*="/photo/1"]', 'div[role="progressbar"]', 'button[data-testid="playButton"]', 'a[href="/settings/content_you_see"]', //hidden content
'div.media-image-container', // for tweetdeck
'div.media-preview-container', // for tweetdeck
'div[aria-labelledby]>div:first-child>div[role="button"][tabindex="0"]' //for audio (experimental)
];
const media = article.querySelector(media_selector.join(','));
if(media){
let status_id = article.querySelector('a[href*="/status/"]').href.split('/status/').pop().split('/').shift();
//选择底部菜单栏,并拷贝一个元素
let btn_group = article.querySelector('div[role="group"]:last-of-type, ul.tweet-actions, ul.tweet-detail-actions');
let btn_share = Array.from(btn_group.querySelectorAll(':scope>div>div, li.tweet-action-item>a, li.tweet-detail-action-item>a')).pop().parentNode;
let btn_down = btn_share.cloneNode(true);
btn_down.querySelector('button').removeAttribute('disabled');
if (this.is_tweetdeck) {
btn_down.firstElementChild.innerHTML = '<svg viewBox="0 0 24 24" style="width: 18px; height: 18px;">' + this.svg + '</svg>';
btn_down.firstElementChild.removeAttribute('rel');
btn_down.classList.replace("pull-left", "pull-right");
} else {
btn_down.querySelector('svg').innerHTML = this.svg;
}
let is_exist = this.history.indexOf(status_id) >= 0;
this.status(btn_down, 'tmd-down');
this.status(btn_down, is_exist ? 'completed': 'download', is_exist ? selectLanguage().download.completed: selectLanguage().download.download);
btn_group.insertBefore(btn_down, btn_share.nextSibling);
btn_down.onclick = () =>{
this.click(btn_down, status_id, is_exist)
}
if(this.show_sensitive) {
let btn_show = article.querySelector('div[aria-labelledby] div[role="button"][tabindex="0"]:not([data-testid]) > div[dir] > span > span');
if (btn_show){
btn_show.click();
}
}
}
const imgs = article.querySelectorAll('a[href*="/photo/"]');
if (imgs.length > 1) {
let status_id = article.querySelector('a[href*="/status/"]').href.split('/status/').pop().split('/').shift();
let btn_group = article.querySelector('div[role="group"]:last-of-type');
let btn_share = Array.from(btn_group.querySelectorAll(':scope>div>div')).pop().parentNode;
imgs.forEach(img =>{
let index = img.href.split('/status/').pop().split('/').pop();
let is_exist = this.history.indexOf(status_id) >= 0;
let btn_down = document.createElement('div');
btn_down.innerHTML = '<div><div><svg viewBox="0 0 24 24" style="width: 18px; height: 18px;">' + this.svg + '</svg></div></div>';
btn_down.classList.add('tmd-down', 'tmd-img');
this.status(btn_down, 'download');
img.parentNode.appendChild(btn_down);
btn_down.onclick= (e) =>{
e.preventDefault();
this.click(btn_down, status_id, is_exist, index);
}
});
}
},
addButtonToMedia: function(listitems) {
listitems.forEach(li =>{
if (li.dataset.detected) return;
li.dataset.detected = 'true';
let status_id = li.querySelector('a[href*="/status/"]').href.split('/status/').pop().split('/').shift();
let is_exist = this.history.indexOf(status_id) >= 0;
let btn_down = document.createElement('div');
btn_down.innerHTML = '<div><div><svg viewBox="0 0 24 24" style="width: 18px; height: 18px;">' + this.svg + '</svg></div></div>';
btn_down.classList.add('tmd-down', 'tmd-media');
this.status(btn_down, is_exist ? 'completed': 'download', is_exist ? selectLanguage().download.completed: selectLanguage().download.download);
li.appendChild(btn_down);
btn_down.onclick= () =>{
this.click(btn_down, status_id, is_exist);
}
});
},
status: function (btn, css, title, style) {
if (css) {
btn.classList.remove('download', 'completed', 'loading', 'failed');
btn.classList.add(css);
}
if (title) btn.title = title;
if (style) btn.style.cssText = style;
},
fetchJson:async function(status_id){
const base_url = `https://${host}/i/api/graphql/NmCeCgkVlsRGS1cAwqtgmw/TweetDetail`;
const variables = {
"focalTweetId":status_id,
"with_rux_injections":false,
"includePromotedContent":true,
"withCommunity":true,
"withQuickPromoteEligibilityTweetFields":true,
"withBirdwatchNotes":true,
"withVoice":true,
"withV2Timeline":true
};
const features = {
"rweb_lists_timeline_redesign_enabled":true,
"responsive_web_graphql_exclude_directive_enabled":true,
"verified_phone_label_enabled":false,
"creator_subscriptions_tweet_preview_api_enabled":true,
"responsive_web_graphql_timeline_navigation_enabled":true,
"responsive_web_graphql_skip_user_profile_image_extensions_enabled":false,
"tweetypie_unmention_optimization_enabled":true,
"responsive_web_edit_tweet_api_enabled":true,
"graphql_is_translatable_rweb_tweet_is_translatable_enabled":true,
"view_counts_everywhere_api_enabled":true,
"longform_notetweets_consumption_enabled":true,
"responsive_web_twitter_article_tweet_consumption_enabled":false,
"tweet_awards_web_tipping_enabled":false,
"freedom_of_speech_not_reach_fetch_enabled":true,
"standardized_nudges_misinfo":true,
"tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled":true,
"longform_notetweets_rich_text_read_enabled":true,
"longform_notetweets_inline_media_enabled":true,
"responsive_web_media_download_video_enabled":false,
"responsive_web_enhance_cards_enabled":false
};
const url = encodeURI(`${base_url}?variables=${JSON.stringify(variables)}&features=${JSON.stringify(features)}`);
const cookies = this.getCookie();
const headers = {
'authorization': 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
'x-twitter-active-user': 'yes',
'x-twitter-client-language': cookies.lang,
'x-csrf-token': cookies.ct0
};
if (cookies.ct0.length == 32) headers['x-guest-token'] = cookies.gt;
let tweet_detail = await fetch(url, {headers: headers}).then(result => result.json());
let tweet_entrie = tweet_detail.data.threaded_conversation_with_injections_v2.instructions[0].entries.find(n => n.entryId == `tweet-${status_id}`);
let tweet_result = tweet_entrie.content.itemContent.tweet_results.result;
return tweet_result.tweet || tweet_result;
},
click:async function(btn, status_id, is_exist, index){
if (btn.classList.contains('loading')) return;
this.status(btn, 'loading');
let save_history = await GM_getValue('save_history', true);
let json = await this.fetchJson(status_id);
let tweet = json.legacy;
let user = json.core.user_results.result.legacy;
let invalid_chars = {
'\\': '\',
'\/': '/',
'\|': '|',
'<': '<',
'>': '>',
':': ':',
'*': '*',
'?': '?',
'"': '"',
'\u200b': '',
'\u200c': '',
'\u200d': '',
'\u2060': '',
'\ufeff': '',
'🔞': ''
};
let datetime = this.filename.match(/{date-time(-local)?:[^{}]+}/)
? this.filename.match(/{date-time(?:-local)?:([^{}]+)}/)[1].replace(/[\\/ | <>*?:"]/g, v => invalid_chars[v]) : 'YYYYMMDD-hhmmss';
let info = {};
info['status-id'] = status_id;
info['user-name'] = user.name.replace(/([\\/|*?:"] | [\u200b - \u200d\u2060\ufeff] | 🔞) /g, v =>invalid_chars[v]);
info['user-id'] = user.screen_name;
info['date-time'] = this.formatDate(tweet.created_at, datetime);
info['date-time-local'] = this.formatDate(tweet.created_at, datetime, true);
info['full-text'] = tweet.full_text.split('\n').join(' ').replace(/\s*https:\/\/t\.co\/\w+/g, '').replace(/[\\/ | <>*?:"]|[\u200b-\u200d\u2060\ufeff]/g, v => invalid_chars[v]);
let medias = tweet.extended_entities && tweet.extended_entities.media;
if(medias == undefined){
medias = JSON.parse(json.card.legacy.binding_values[0].value.string_value).media_entities;
medias = Object.values(medias);
}
if(index){
medias = [medias[index - 1]];
}
if(medias.length > 0){
let tasks = medias.length;
let tasks_result = [];