-
-
Notifications
You must be signed in to change notification settings - Fork 140
/
Copy pathYABDP4Nitro.plugin.js
3009 lines (2612 loc) · 155 KB
/
YABDP4Nitro.plugin.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
/**
* @name YABDP4Nitro
* @author Riolubruh
* @version 5.6.7
* @invite EFmGEWAUns
* @source https://github.com/riolubruh/YABDP4Nitro
* @donate https://github.com/riolubruh/YABDP4Nitro?tab=readme-ov-file#donate
* @updateUrl https://raw.githubusercontent.com/riolubruh/YABDP4Nitro/main/YABDP4Nitro.plugin.js
* @description Unlock all screensharing modes, and use cross-server & GIF emotes!
*/
/*@cc_on
@if(@_jscript)
// Offer to self-install for clueless users that try to run this directly.
var shell = WScript.CreateObject("WScript.Shell");
var fs = new ActiveXObject("Scripting.FileSystemObject");
var pathPlugins = shell.ExpandEnvironmentStrings("%APPDATA%\\BetterDiscord\\plugins");
var pathSelf = WScript.ScriptFullName;
// Put the user at ease by addressing them in the first person
shell.Popup("It looks like you've mistakenly tried to run me directly. \n(Don't do that!)", 0, "I'm a plugin for BetterDiscord", 0x30);
if(fs.GetParentFolderName(pathSelf) === fs.GetAbsolutePathName(pathPlugins)){
shell.Popup("I'm in the correct folder already.", 0, "I'm already installed", 0x40);
}else if(!fs.FolderExists(pathPlugins)){
shell.Popup("I can't find the BetterDiscord plugins folder.\nAre you sure it's even installed?", 0, "Can't install myself", 0x10);
}else if(shell.Popup("Should I copy myself to BetterDiscord's plugins folder for you?", 0, "Do you need some help?", 0x34) === 6){
fs.CopyFile(pathSelf, fs.BuildPath(pathPlugins, fs.GetFileName(pathSelf)), true);
// Show the user where to put plugins in the future
shell.Exec("explorer " + pathPlugins);
shell.Popup("I'm installed!", 0, "Successfully installed", 0x40);
}
WScript.Quit();
@else@*/
//#region Module Hell
const { Webpack, Patcher, Net, React, UI, Logger, Data, Components, DOM } = BdApi;
const StreamButtons = Webpack.getMangled("RESOLUTION_1080", {
ApplicationStreamFPS: Webpack.Filters.byKeys("FPS_30"),
ApplicationStreamFPSButtons: o => Array.isArray(o) && typeof o[0]?.label === 'number' && o[0]?.value === 15,
ApplicationStreamFPSButtonsWithSuffixLabel: o => Array.isArray(o) && typeof o[0]?.label === 'string' && o[0]?.value === 15,
ApplicationStreamResolutionButtons: o => Array.isArray(o) && o[0]?.value !== undefined,
ApplicationStreamResolutionButtonsWithSuffixLabel: o => Array.isArray(o) && o[0]?.label === "480p",
ApplicationStreamResolutions: Webpack.Filters.byKeys("RESOLUTION_1080"),
ApplicationStreamSettingRequirements: o => Array.isArray(o) && o[0]?.resolution !== undefined,
getApplicationResolution: Webpack.Filters.byStrings('"Unknown resolution: ".concat('),
getApplicationFramerate: Webpack.Filters.byStrings('"Unknown frame rate: ".concat('),
});
const { ApplicationStreamFPS, ApplicationStreamFPSButtons, ApplicationStreamFPSButtonsWithSuffixLabel,
ApplicationStreamResolutionButtons, ApplicationStreamResolutionButtonsWithSuffixLabel,
ApplicationStreamResolutions, ApplicationStreamSettingRequirements } = StreamButtons;
const CloudUploader = Webpack.getModule(Webpack.Filters.byPrototypeKeys("uploadFileToCloud"), { searchExports: true });
const Uploader = Webpack.getByKeys("uploadFiles", "upload");
const CurrentUser = Webpack.getByKeys("getCurrentUser").getCurrentUser();
const ORIGINAL_NITRO_STATUS = CurrentUser.premiumType;
const getBannerURL = Webpack.getByPrototypeKeys("getBannerURL").prototype;
const userProfileMod = Webpack.getByKeys("getUserProfile");
const buttonClassModule = Webpack.getByKeys("lookFilled", "button", "contents");
const Dispatcher = Webpack.getByKeys("subscribe", "dispatch");
const canUserUseMod = Webpack.getMangled(".getFeatureValue(", {
canUserUse: Webpack.Filters.byStrings("getFeatureValue")
});
const AvatarDefaults = Webpack.getByKeys("getEmojiURL");
const LadderModule = Webpack.getModule(Webpack.Filters.byProps("calculateLadder"), { searchExports: true });
const FetchCollectibleCategories = Webpack.getByStrings('{type:"COLLECTIBLES_CATEGORIES_FETCH"', { searchExports: true });
let ffmpeg = undefined;
const MP4Box = Webpack.getByKeys("MP4BoxStream");
const udta = new Uint8Array([0, 0, 0, 89, 109, 101, 116, 97, 0, 0, 0, 0, 0, 0, 0, 33, 104, 100, 108, 114, 0, 0, 0, 0, 0, 0, 0, 0, 109, 100, 105, 114, 97, 112, 112, 108, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 105, 108, 115, 116, 0, 0, 0, 36, 169, 116, 111, 111, 0, 0, 0, 28, 100, 97, 116, 97, 0, 0, 0, 1, 0, 0, 0, 0, 76, 97, 118, 102, 54, 49, 46, 51, 46, 49, 48, 51, 0, 0, 46, 46, 117, 117, 105, 100, 161, 200, 82, 153, 51, 70, 77, 184, 136, 240, 131, 245, 122, 117, 165, 239]);
const udtaBuffer = udta.buffer;
const UserStatusStore = Webpack.getByKeys("getStatus", "getState");
const SelectedGuildStore = Webpack.getStore("SelectedGuildStore");
const ChannelStore = Webpack.getStore("ChannelStore");
const MessageActions = Webpack.getByKeys("jumpToMessage", "_sendMessage");
const SelectedChannelStore = Webpack.getStore("SelectedChannelStore");
const UserStore = Webpack.getStore("UserStore");
const MessageEmojiReact = Webpack.getByStrings(',nudgeAlignIntoViewport:!0,position:', 'jumboable?', { searchExports: true });
const renderEmbedsMod = Webpack.getByPrototypeKeys('renderSocialProofingFileSizeNitroUpsell', { searchExports: true }).prototype;
const messageRender = Webpack.getMangled('.SEND_FAILED,', {
renderMessage: o => typeof o === "object"
});
const stickerSendabilityModule = Webpack.getMangled("SENDABLE_WITH_BOOSTED_GUILD", {
getStickerSendability: Webpack.Filters.byStrings("canUseCustomStickersEverywhere"),
isSendableSticker: Webpack.Filters.byStrings(")=>0===")
});
const clientThemesModule = Webpack.getModule(Webpack.Filters.byProps("isPreview"));
const streamSettingsMod = Webpack.getByPrototypeKeys("getCodecOptions").prototype;
const themesModule = Webpack.getMangled("changes:{appearance:{settings:{clientThemeSettings:{", {
saveClientTheme: Webpack.Filters.byStrings("changes:{appearance:{settings:{clientThemeSettings:{")
});
const accountSwitchModule = Webpack.getByKeys("startSession", "login");
const getAvatarUrlModule = Webpack.getByPrototypeKeys("getAvatarURL").prototype;
const fetchProfileEffects = Webpack.getByStrings("USER_PROFILE_EFFECTS_FETCH", { searchExports: true });
const getSoundMod = Webpack.getByKeys("getSoundById");
const emojiMod = Webpack.getByKeys("getCustomEmojiById");
const isEmojiAvailableMod = Webpack.getByKeys("isEmojiFilteredOrLocked");
const TextClasses = Webpack.getByKeys("errorMessage", "h5");
const FormModalClasses = Webpack.getByKeys("formItemTitleSlim", "modalContent");
const StreamSettingsMod = Webpack.getByStrings("StreamSettings: user cannot be undefined", { defaultExport: false });
const videoOptionFunctions = Webpack.getByPrototypeKeys("updateVideoQuality").prototype;
const appIconModule = Webpack.getByKeys("getCurrentDesktopIcon");
const appIconButtonsModule = Webpack.getByStrings("renderCTAButtons", {defaultExport:false});
//#endregion
const defaultSettings = {
"emojiSize": 64,
"screenSharing": true,
"emojiBypass": true,
"emojiBypassType": 0,
"emojiBypassForValidEmoji": true,
"PNGemote": true,
"uploadStickers": false,
"CustomFPSEnabled": false,
"CustomFPS": 60,
"ResolutionEnabled": false,
"CustomResolution": 1440,
"CustomBitrateEnabled": false,
"minBitrate": -1,
"maxBitrate": -1,
"targetBitrate": -1,
"voiceBitrate": -1,
"ResolutionSwapper": true,
"stickerBypass": false,
"profileV2": false,
"forceStickersUnlocked": false,
"changePremiumType": false,
"videoCodec2": -1,
"clientThemes": true,
"lastGradientSettingStore": -1,
"fakeProfileThemes": true,
"removeProfileUpsell": false,
"removeScreenshareUpsell": true,
"fakeProfileBanners": true,
"fakeAvatarDecorations": true,
"unlockAppIcons": false,
"profileEffects": true,
"killProfileEffects": false,
"avatarDecorations": {},
"customPFPs": true,
"experiments": false,
"userPfpIntegration": true,
"userBgIntegration": true,
"useClipBypass": true,
"alwaysTransmuxClips": false,
"forceClip": false,
"checkForUpdates": true,
"fakeInlineVencordEmotes": true,
"soundmojiEnabled": true
};
//Plugin-wide variables
let settings = {};
let usrBgUsers = [];
let badgeUserIDs = [];
let fetchedUserBg = false;
let fetchedUserPfp = false;
// #region Config
const config = {
info: {
"name": "YABDP4Nitro",
"authors": [{
"name": "Riolubruh",
"discord_id": "359063827091816448",
"github_username": "riolubruh"
}],
"version": "5.6.7",
"description": "Unlock all screensharing modes, and use cross-server & GIF emotes!",
"github": "https://github.com/riolubruh/YABDP4Nitro",
"github_raw": "https://raw.githubusercontent.com/riolubruh/YABDP4Nitro/main/YABDP4Nitro.plugin.js"
},
changelog: [
{
title: "5.6.7",
items: [
"Fixed a regression where the upload emoji bypass would send doubled messages.",
"Fixed soundmoji text being doubled if you sent both an emoji with Upload Emotes enabled and sent a soundmoji at the same time.",
"Changed code in videoQualityModule that would set the video capture and video budget to the FPS and resolution in plugin settings even if you weren't using the custom quality option so that it instead sets it to the current resolution and framerate of the stream in index 0."
]
}
],
settingsPanel: [
{
type: "category",
id: "ScreenShare",
name: "Screen Share Features",
collapsible: true,
shown: false,
settings: [
{ type: "switch", id: "screenSharing", name: "High Quality Screensharing", note: "1080p/Source @ 60fps screensharing. Enable if you want to use any Screen Share related options.", value: () => settings.screenSharing },
{ type: "switch", id: "ResolutionEnabled", name: "Custom Screenshare Resolution", note: "Choose your own screen share resolution!", value: () => settings.ResolutionEnabled },
{ type: "text", id: "CustomResolution", name: "Resolution", note: "The custom resolution you want (in pixels)", value: () => settings.CustomResolution },
{ type: "switch", id: "CustomFPSEnabled", name: "Custom Screenshare FPS", note: "Choose your own screen share FPS!", value: () => settings.CustomFPSEnabled },
{ type: "text", id: "CustomFPS", name: "FPS", note: "The custom FPS you want to stream at.", value: () => settings.CustomFPS },
{ type: "switch", id: "ResolutionSwapper", name: "Stream Settings Quick Swapper", note: "Lets you change your custom resolution and FPS quickly in the stream settings modal!", value: () => settings.ResolutionSwapper },
{ type: "switch", id: "CustomBitrateEnabled", name: "Custom Bitrate", note: "Choose the bitrate for your streams!", value: () => settings.CustomBitrateEnabled },
{ type: "text", id: "minBitrate", name: "Minimum Bitrate", note: "The minimum bitrate (in kbps). If this is set to a negative number, the Discord default of 150kbps will be used.", value: () => settings.minBitrate },
{ type: "text", id: "targetBitrate", name: "Target Bitrate", note: "The target bitrate (in kbps). If this is set to a negative number, the Discord default of 600kbps will be used.", value: () => settings.targetBitrate },
{ type: "text", id: "maxBitrate", name: "Maximum Bitrate", note: "The maximum bitrate (in kbps). If this is set to a negative number, the Discord default of 2500kbps will be used.", value: () => settings.maxBitrate },
{ type: "text", id: "voiceBitrate", name: "Voice Audio Bitrate", note: "Allows you to change the voice bitrate to whatever you want. Does not allow you to go over the voice channel's set bitrate but it does allow you to go much lower. (bitrate in kbps). Disabled if this is set to 128 or -1.", value: () => settings.voiceBitrate },
{
type: "dropdown", id: "videoCodec2", name: "Force Video Codec (Advanced Users Only)", note: `
Allows you to force a specified video codec to be used. Normally, Discord would automatically
choose this based on your hardware, options in Voice & Video, and the viewers watching.
Mobile and Web clients can only view H.264 and VP8 streams.
If a client does not support the codec you choose, the stream will infinitely load for them!`, value: () => settings.videoCodec2, options: [
{ label: "Default (recommended, automatic)", value: -1 },
{ label: "AV1", value: 0 },
{ label: "H265", value: 1 },
{ label: "H264", value: 2 },
{ label: "VP8", value: 3 },
{ label: "VP9", value: 4 },
]
},
]
},
{
type: "category",
id: "emojis",
name: "Emojis",
collapsible: true,
shown: false,
settings: [
{ type: "switch", id: "emojiBypass", name: "Nitro Emotes Bypass", note: "Enable or disable using the emoji bypass.", value: () => settings.emojiBypass },
{
type: "dropdown", id: "emojiSize", name: "Size", note: "The size of the emoji in pixels.", value: () => settings.emojiSize, options: [
{ label: "32px (Default small/inline)", value: 32 },
{ label: "48px (Recommended, default large)", value: 48 },
{ label: "16px", value: 16 },
{ label: "24px", value: 24 },
{ label: "40px", value: 40 },
{ label: "56px", value: 56 },
{ label: "64px", value: 64 },
{ label: "80px", value: 80 },
{ label: "96px", value: 96 },
{ label: "128px (Max emoji size)", value: 128 },
{ label: "256px (Max GIF emoji size)", value: 256 }
]
},
{
type: "dropdown", id: "emojiBypassType", name: "Emoji Bypass Method", note: "The method of bypass to use.", value: () => settings.emojiBypassType,
options: [
{ label: "Upload Emojis", value: 0 },
{ label: "Ghost Link Mode", value: 1 },
{ label: "Classic Mode", value: 2 },
{ label: "Hyperlink/Vencord-Like Mode", value: 3 }
]
},
{ type: "switch", id: "emojiBypassForValidEmoji", name: "Don't Use Emote Bypass if Emote is Unlocked", note: "Disable to use emoji bypass even if bypass is not required for that emoji.", value: () => settings.emojiBypassForValidEmoji },
{ type: "switch", id: "PNGemote", name: "Use PNG instead of WEBP", note: "Use the PNG version of static emoji for higher quality!", value: () => settings.PNGemote },
{ type: "switch", id: "stickerBypass", name: "Sticker Bypass", note: "Enable or disable using the sticker bypass. I recommend using An00nymushun's DiscordFreeStickers over this. Animated APNG/WEBP/Lottie Stickers WILL NOT animate.", value: () => settings.stickerBypass },
{ type: "switch", id: "uploadStickers", name: "Upload Stickers", note: "Upload stickers in the same way as emotes.", value: () => settings.uploadStickers },
{ type: "switch", id: "forceStickersUnlocked", name: "Force Stickers Unlocked", note: "Enable to cause Stickers to be unlocked.", value: () => settings.forceStickersUnlocked },
{ type: "switch", id: "fakeInlineVencordEmotes", name: "Fake Inline Hyperlink Emotes", note: "Makes hyperlinked emojis appear as if they were real emojis, inlined in the message, similar to Vencord FakeNitro emotes.", value: () => settings.fakeInlineVencordEmotes },
{ type: "switch", id:"soundmojiEnabled", name: "Soundmoji Bypass", note: "Unlocks soundmojis and allows you to \"send\" them by automatically replacing them with a MP3 upload and some special text that will make them render as real soundmojis on the client side.", value: () => settings.soundmojiEnabled }
]
},
{
type: "category",
id: "profile",
name: "Profile",
collapsible: true,
shown: false,
settings: [
{ type: "switch", id: "profileV2", name: "Profile Accents", note: "When enabled, you will see (almost) all users with the new Nitro-exclusive look for profiles (the sexier look). When disabled, the default behavior is used. Does not allow you to update your profile accent.", value: () => settings.profileV2 },
{ type: "switch", id: "fakeProfileThemes", name: "Fake Profile Themes", note: "Uses invisible 3y3 encoding to allow profile theming by hiding the colors in your bio.", value: () => settings.fakeProfileThemes },
{ type: "switch", id: "fakeProfileBanners", name: "Fake Profile Banners", note: "Uses invisible 3y3 encoding to allow setting profile banners by hiding the image URL in your bio. Only supports Imgur URLs for security reasons.", value: () => settings.fakeProfileBanners },
{ type: "switch", id: "userBgIntegration", name: "UserBG Integration", note: "Downloads and parses the UserBG JSON database so that UserBG banners will appear for you.", value: () => settings.userBgIntegration },
{ type: "switch", id: "fakeAvatarDecorations", name: "Fake Avatar Decorations", note: "Uses invisible 3y3 encoding to allow setting avatar decorations by hiding information in your bio and/or your custom status.", value: () => settings.fakeAvatarDecorations },
{ type: "switch", id: "profileEffects", name: "Fake Profile Effects", note: "Uses invisible 3y3 encoding to allow setting profile effects by hiding information in your bio.", value: () => settings.profileEffects },
{ type: "switch", id: "killProfileEffects", name: "Kill Profile Effects", note: "Hate profile effects? Enable this and they'll be gone. All of them. Overrides all profile effects.", value: () => settings.killProfileEffects },
{ type: "switch", id: "customPFPs", name: "Fake Profile Pictures", note: "Uses invisible 3y3 encoding to allow setting custom profile pictures by hiding an image URL IN YOUR CUSTOM STATUS. Only supports Imgur URLs for security reasons.", value: () => settings.customPFPs },
{ type: "switch", id: "userPfpIntegration", name: "UserPFP Integration", note: "Imports the UserPFP database so that people who have profile pictures in the UserPFP database will appear with their UserPFP profile picture. There's little reason to disable this.", value: () => settings.userPfpIntegration },
]
},
{
type: "category",
id: "clips",
name: "Clips",
collapsible: true,
shown: false,
settings: [
{ type: "switch", id: "useClipBypass", name: "Use Clips Bypass", note: "Enabling this will effectively set your file upload limit for video files to 100MB. Disable this if you have a file upload limit larger than 100MB.", value: () => settings.useClipBypass },
{ type: "switch", id: "alwaysTransmuxClips", name: "Force Transmuxing", note: "Always transmux the video, even if transmuxing would normally be skipped. Transmuxing is only ever skipped if the codec does not include AVC1 or includes MP42.", value: () => settings.alwaysTransmuxClips },
{ type: "switch", id: "forceClip", name: "Force Clip", note: "Always send video files as a clip, even if the size is below 10MB.", value: () => settings.forceClip }
]
},
{
type: "category",
id: "miscellaneous",
name: "Miscellaneous",
collapsible: true,
shown: false,
settings: [
{ type: "switch", id: "changePremiumType", name: "Change PremiumType", note: "This is now optional. Enabling this may help compatibility for certain things or harm it. SimpleDiscordCrypt requires this to be enabled to have the emoji bypass work. Only enable this if you don't have Nitro.", value: () => settings.changePremiumType },
{ type: "switch", id: "clientThemes", name: "Gradient Client Themes", note: "Allows you to use Nitro-exclusive Client Themes.", value: () => settings.clientThemes },
{ type: "switch", id: "removeProfileUpsell", name: "Remove Profile Customization Upsell", note: "Removes the \"Try It Out\" upsell in the profile customization screen and replaces it with the Nitro variant. Note: does not allow you to use Nitro customization on Server Profiles as the API disallows this.", value: () => settings.removeProfileUpsell },
{ type: "switch", id: "removeScreenshareUpsell", name: "Remove Screen Share Nitro Upsell", note: "Removes the Nitro upsell in the Screen Share quality option menu.", value: () => settings.removeScreenshareUpsell },
{ type: "switch", id: "unlockAppIcons", name: "App Icons", note: "Unlocks app icons. Warning: enabling this will force \"Change Premium Type\" to be enabled.", value: () => settings.unlockAppIcons },
{ type: "switch", id: "experiments", name: "Experiments", note: "Unlocks experiments. Use at your own risk.", value: () => settings.experiments },
{ type: "switch", id: "checkForUpdates", name: "Check for Updates", note: "Should the plugin check for updates on startup?", value: () => settings.checkForUpdates }
]
}
],
"main": "YABDP4Nitro.plugin.js"
};
// #endregion
// #region Exports
module.exports = class YABDP4Nitro {
constructor(meta){
this.meta = meta;
}
getSettingsPanel(){
return UI.buildSettingsPanel({
settings: config.settingsPanel,
onChange: (category, id, value) => {
switch (id){
case "CustomResolution":
case "CustomFPS":
settings[id] = parseInt(value);
this.saveAndUpdate();
break;
case "minBitrate":
case "targetBitrate":
case "maxBitrate":
case "voiceBitrate":
settings[id] = parseFloat(value);
this.saveAndUpdate();
break;
default:
settings[id] = value;
this.saveAndUpdate();
break;
}
}
});
}
// #region Save and Update
saveAndUpdate(){ //Saves and updates settings and runs functions
Data.save(this.meta.name, "settings", settings);
Patcher.unpatchAll(this.meta.name);
if(settings.changePremiumType){
try {
if(!(ORIGINAL_NITRO_STATUS > 1)){
CurrentUser.premiumType = 1;
setTimeout(() => {
if(settings.changePremiumType){
CurrentUser.premiumType = 1;
}
}, 10000);
}
}
catch(err){
Logger.error(this.meta.name, "An error occurred changing premium type." + err);
}
}
if(settings.CustomFPS == 15) settings.CustomFPS = 16;
if(settings.CustomFPS == 30) settings.CustomFPS = 31;
if(settings.CustomFPS == 5) settings.CustomFPS = 6;
if(settings.ResolutionSwapper){
try {
this.resolutionSwapper();
} catch(err){
Logger.error(this.meta.name, err);
}
}
if(settings.stickerBypass){
try {
this.stickerSending();
} catch(err){
Logger.error(this.meta.name, err);
}
}
if(settings.forceStickersUnlocked || settings.stickerBypass){
try {
this.unlockStickers();
} catch(err){
Logger.error(this.meta.name, err);
}
}
if(settings.emojiBypass){
try {
this.emojiBypass();
} catch(err){
Logger.error(this.meta.name, err);
}
}
if(settings.profileV2){
try {
Patcher.after(this.meta.name, userProfileMod, "getUserProfile", (_, args, ret) => {
if(ret == undefined) return;
ret.premiumType = 2;
});
} catch(err){
Logger.error(this.meta.name, err);
}
}
if(settings.screenSharing){
try {
this.customVideoSettings(); //Unlock stream buttons, apply custom resolution and fps, and apply stream quality bypasses
} catch(err){
Logger.error(this.meta.name, "Error occurred during customVideoSettings() " + err);
}
try {
this.videoQualityModule(); //Custom bitrate, fps, resolution module
} catch(err){
Logger.error(this.meta.name, "Error occurred during videoQualityModule() " + err);
}
}
if(settings.clientThemes){
try {
this.clientThemes();
} catch(err){
Logger.warn(this.meta.name, err);
}
}
if(settings.fakeProfileThemes){
try {
this.decodeAndApplyProfileColors();
this.encodeProfileColors();
} catch(err){
Logger.error(this.meta.name, "Error occurred running fakeProfileThemes bypass. " + err);
}
}
BdApi.DOM.removeStyle(this.meta.name);
if(settings.removeScreenshareUpsell){
try {
BdApi.DOM.addStyle(this.meta.name, `
[class*="upsellBanner"] {
display: none;
visibility: hidden;
}`);
} catch(err){
Logger.error(this.meta.name, err);
}
}
BdApi.DOM.removeStyle("UsrBGIntegration");
if(settings.fakeProfileBanners){
this.bannerUrlDecoding();
this.bannerUrlEncoding(this.secondsightifyEncodeOnly);
if(settings.userBgIntegration){
BdApi.DOM.addStyle("UsrBGIntegration", `
:is([class*="userProfile"], [class*="userPopout"]) [class*="bannerPremium"] {
background: center / cover no-repeat;
}
[class*="NonPremium"]:has([class*="bannerPremium"]) [class*="avatarPositionNormal"],
[class*="PremiumWithoutBanner"]:has([class*="bannerPremium"]) [class*="avatarPositionPremiumNoBanner"] {
top: 76px;
}
[style*="background-image"] [class*="background_"] {
background-color: transparent !important;
}`
);
}
}
Dispatcher.unsubscribe("COLLECTIBLES_CATEGORIES_FETCH_SUCCESS", this.storeProductsFromCategories);
if(settings.fakeAvatarDecorations){
this.fakeAvatarDecorations();
}
if(settings.unlockAppIcons){
this.appIcons();
}
if(settings.profileEffects){
try {
this.profileFX(this.secondsightifyEncodeOnly);
} catch(err){
Logger.error(this.meta.name, err);
}
}
if(settings.killProfileEffects){
try {
this.killProfileFX();
} catch(err){
Logger.error(this.meta.name, "Error occured during killProfileFX() " + err);
}
}
BdApi.DOM.removeStyle("YABDP4NitroBadges");
try {
this.honorBadge();
} catch(err){
Logger.error(this.meta.name, "An error occurred during honorBadge() " + err);
}
if(settings.customPFPs){
try {
this.customProfilePictureDecoding();
this.customProfilePictureEncoding(this.secondsightifyEncodeOnly);
} catch(err){
Logger.error(this.meta.name, "An error occurred during customProfilePicture decoding/encoding. " + err);
}
}
if(settings.experiments){
try {
this.experiments();
} catch(err){
Logger.error(this.meta.name, "Error occurred in experiments() " + err);
}
}
Patcher.instead(this.meta.name, canUserUseMod, "canUserUse", (_, [feature, user], originalFunction) => {
//return true;
if(settings.emojiBypass && (feature.name == "emojisEverywhere" || feature.name == "animatedEmojis"))
return true;
if(settings.appIcons && feature.name == 'appIcons')
return true;
if(settings.removeProfileUpsell && feature.name == 'profilePremiumFeatures')
return true;
if(settings.clientThemes && feature.name == 'clientThemes')
return true;
if(settings.soundmojiEnabled && feature.name == 'soundboardEverywhere')
return true;
return originalFunction(feature, user);
});
//Clips Bypass
if(settings.useClipBypass){
try {
this.experiments();
this.overrideExperiment("2023-09_clips_nitro_early_access", 2);
this.overrideExperiment("2022-11_clips_experiment", 1);
this.overrideExperiment("2023-10_viewer_clipping", 1);
this.clipsBypass();
} catch(err){
Logger.error(this.meta.name, err);
}
}
if(settings.fakeInlineVencordEmotes){
this.inlineFakemojiPatch();
}
if(settings.soundmojiEnabled || (settings.emojiBypass && settings.emojiBypassType == 0))
this._sendMessageInsteadPatch();
if(settings.videoCodec2 > -1)
this.videoCodecs();
} //End of saveAndUpdate()
// #endregion
// #region Resolution Swapper
resolutionSwapper(){
Patcher.after(this.meta.name, StreamSettingsMod, "Z", (_, [args], ret) => {
//Only if the selected preset is "Custom"
if(args.selectedPreset === 3){
//Preparations
let streamQualityButtonsSection = ret.props.children.props.children.props.children[1].props.children[0].props.children;
let resolutionButtonsSection = streamQualityButtonsSection[0].props;
let thirdResolutionButton = resolutionButtonsSection.children.props.buttons[2];
let fpsButtonsSection = streamQualityButtonsSection[1].props;
let thirdFpsButton = fpsButtonsSection.children.props.buttons[2];
//make each section into arrays so we can add another element
resolutionButtonsSection.children = [resolutionButtonsSection.children];
fpsButtonsSection.children = [fpsButtonsSection.children];
//Resolution input
resolutionButtonsSection.children.push(React.createElement("div", {
children: [
React.createElement("h1", {
children: "CUSTOM RESOLUTION",
className: `${TextClasses.h5} ${TextClasses.eyebrow} ${FormModalClasses.formItemTitleSlim}`
}),
React.createElement(Components.NumberInput, {
value: settings.CustomResolution,
onChange: (input) => {
settings.CustomResolution = input;
//updates visual
thirdResolutionButton.value = input;
//sets values and saves to settings
this.unlockAndCustomizeStreamButtons();
//simulate click on button -- serves to both select it and to make react re-render it.
thirdResolutionButton.onClick();
}
})
]
}));
fpsButtonsSection.children.push(React.createElement("div", {
children: [
React.createElement("h1", {
children: "CUSTOM FRAME RATE",
className: `${TextClasses.h5} ${TextClasses.eyebrow} ${FormModalClasses.formItemTitleSlim}`
}),
React.createElement(Components.NumberInput, {
value: settings.CustomFPS,
onChange: (input) => {
settings.CustomFPS = input;
//updates visual
thirdFpsButton.value = input;
//sets values and saves to settings
this.unlockAndCustomizeStreamButtons();
//simulate click on button -- serves to both select it and to make react re-render it.
thirdFpsButton.onClick();
}
})
]
}));
}
});
}
// #endregion
unlockStickers(){
Patcher.instead(this.meta.name, stickerSendabilityModule, "getStickerSendability", () => {
return 0; //SENDABLE
});
Patcher.instead(this.meta.name, stickerSendabilityModule, "isSendableSticker", () => {
return true;
});
}
videoCodecs(){
Patcher.after(this.meta.name, streamSettingsMod, "getCodecOptions", (_, args, ret) => {
ret.videoEncoder = ret.videoDecoders[settings.videoCodec2];
});
}
overrideExperiment(type, bucket){
//console.log("applying experiment override " + type + "; bucket " + bucket);
Dispatcher.dispatch({
type: "EXPERIMENT_OVERRIDE_BUCKET",
experimentId: type,
experimentBucket: bucket
});
}
// #region Clips Bypass
async clipsBypass(){
if(ffmpeg == undefined) await this.loadFFmpeg();
async function ffmpegTransmux(arrayBuffer, fileName = "input.mp4"){
if(ffmpeg){
UI.showToast("Transmuxing video...", { type: "info" });
ffmpeg.on("log", ({ message }) => {
console.log(message);
});
await ffmpeg.writeFile(fileName, new Uint8Array(arrayBuffer));
await ffmpeg.exec(["-i", fileName, "-codec", "copy", "-brand", "isom/avc1", "-movflags", "+faststart", "-map", "0", "-map_metadata", "-1", "-map_chapters", "-1", "output.mp4"]);
const data = await ffmpeg.readFile('output.mp4');
return data.buffer;
}
}
Patcher.instead(this.meta.name, Webpack.getByKeys("addFiles"), "addFiles", async (_, [args], originalFunction) => {
//for each file being added
for(let i = 0; i < args.files.length; i++){
const currentFile = args.files[i];
if(currentFile.file.name.endsWith(".dlfc")) return;
//larger than 10mb
if(currentFile.file.size > 10485759 || settings.forceClip){
//if this file is an mp4 file
if(currentFile.file.type == "video/mp4"){
let dontStopMeNow = true;
let mp4BoxFile = MP4Box.createFile();
mp4BoxFile.onError = (e) => {
Logger.error(this.meta.name, e);
dontStopMeNow = false;
};
mp4BoxFile.onReady = async (info) => {
mp4BoxFile.flush();
try {
//check if file is H264 or H265
if(info.videoTracks[0].codec.startsWith("avc") || info.videoTracks[0].codec.startsWith("hev1")){
let hasTransmuxed = false;
if(!info.brands.includes("avc1") || info.brands.includes("mp42") || settings.alwaysTransmuxClips){
arrayBuffer = await ffmpegTransmux(arrayBuffer, currentFile.file.name);
hasTransmuxed = true;
}
let isMetadataPresent = false;
//skip if we transmuxed since we know it won't have the tag
if(!hasTransmuxed){
//Is this file already a Discord clip?
for(let j = 0; j < mp4BoxFile.boxes.length; j++){
if(mp4BoxFile.boxes[j].type == "uuid"){
isMetadataPresent = true;
}
}
}
//If this file is not a Discord clip, append udtaBuffer
if(!isMetadataPresent){
let array1 = ArrayBuffer.concat(arrayBuffer, udtaBuffer);
let video = new File([new Uint8Array(array1)], currentFile.file.name, { type: "video/mp4" });
currentFile.file = video;
}
}else{
//file is not H264 or H265, but is an mp4
arrayBuffer = await ffmpegTransmux(arrayBuffer, currentFile.file.name);
let array1 = ArrayBuffer.concat(arrayBuffer, udtaBuffer);
let video = new File([new Uint8Array(array1)], currentFile.file.name, { type: "video/mp4" });
currentFile.file = video;
}
//send as a "clip"
currentFile.clip = {
"id": "",
"version": 3,
"applicationName": "",
"applicationId": "1301689862256066560",
"users": [
CurrentUser.id
],
"clipMethod": "manual",
"length": currentFile.file.size,
"thumbnail": "",
"filepath": ""
};
} catch(err){
UI.showToast("Something went wrong. See console for details.", { type: "error" });
Logger.error(this.meta.name, err);
} finally {
dontStopMeNow = false;
}
};
let arrayBuffer;
currentFile.file.arrayBuffer().then(obj => {
arrayBuffer = obj;
arrayBuffer.fileStart = 0;
//examine file with mp4Box.
mp4BoxFile.appendBuffer(arrayBuffer);
//onReady will run after the buffer is appended successfully
});
//wait for onReady to finish
while (dontStopMeNow){
await new Promise(r => setTimeout(r, 10));
}
}else if(currentFile.file.type.startsWith("video/")){
//Is a video file, but not MP4
//AVI file warning
if(currentFile.file.type == "video/x-msvideo"){
UI.showToast("[YABDP4Nitro] NOTE: AVI Files will send, but HTML5 does not support playing AVI video codecs!", { type: "warning" });
}
try {
let arrayBuffer = await currentFile.file.arrayBuffer();
let array1 = ArrayBuffer.concat(await ffmpegTransmux(arrayBuffer, currentFile.file.name), udtaBuffer);
let video = new File([new Uint8Array(array1)], currentFile.file.name.substr(0, currentFile.file.name.lastIndexOf(".")) + ".mp4", { type: "video/mp4" });
currentFile.file = video;
//send as a "clip"
currentFile.clip = {
"id": "",
"version": 3,
"applicationName": "",
"applicationId": "1301689862256066560",
"users": [
CurrentUser.id
],
"clipMethod": "manual",
"length": currentFile.file.size,
"thumbnail": "",
"filepath": ""
};
} catch(err){
Logger.error(this.meta.name, err);
}
}
currentFile.platform = 1;
}
}
originalFunction(args);
});
} //End of clipsBypass()
// #endregion
// #region Load FFmpeg.js
async loadFFmpeg(){
const defineTemp = window.global.define;
try {
const ffmpeg_js_baseurl = "https://unpkg.com/@ffmpeg/ffmpeg@0.12.6/dist/umd/";
const ffmpeg_js_core_baseurl = "https://unpkg.com/@ffmpeg/core@0.12.6/dist/umd/";
//load ffmpeg worker
const ffmpegWorkerURL = URL.createObjectURL(await (await fetch(ffmpeg_js_baseurl + "814.ffmpeg.js", { timeout: 100000 })).blob());
//load FFmpeg.WASM
let ffmpegSrc = await (await fetch(ffmpeg_js_baseurl + "ffmpeg.js")).text();
//patch worker URL in the source of ffmpeg.js (why is this a problem lmao)
ffmpegSrc = ffmpegSrc.replace(`new URL(e.p+e.u(814),e.b)`, `"${ffmpegWorkerURL.toString()}"`);
//blob ffmpeg
const ffmpegURL = URL.createObjectURL(new Blob([ffmpegSrc]));
// for some reason, for ffmpeg.js to work we need to set global define to undefined temporarily.
// since for a brief moment it is undefined, any function that uses it may throw an error during that window.
window.global.define = undefined;
//deprecated function, but uhhhh fuck you we need it
await BdApi.linkJS("ffmpeg.js", ffmpegURL);
window.global.define = defineTemp;
ffmpeg = new FFmpegWASM.FFmpeg();
const ffmpegCoreURL = URL.createObjectURL(await (await fetch(ffmpeg_js_core_baseurl + "ffmpeg-core.js", { timeout: 100000 })).blob());
const ffmpegCoreWasmURL = URL.createObjectURL(await (await fetch(ffmpeg_js_core_baseurl + "ffmpeg-core.wasm", { timeout: 100000 })).blob());
await ffmpeg.load({
coreURL: ffmpegCoreURL,
wasmURL: ffmpegCoreWasmURL
});
Logger.info(this.meta.name, "FFmpeg load success!");
} catch(err){
UI.showToast("An error occured trying to load FFmpeg.wasm. Check console for details.", { type: "error" });
Logger.info(this.meta.name, "FFmpeg failed to load. The clips bypass will not work without this unless the file is already the correct format! Error details below.");
Logger.error(this.meta.name, err);
} finally {
//Ensure we return window.global.define to its regular state just in case we errored during the short window where it has to be set to undefined.
window.global.define = defineTemp;
}
} //End of loadFFmpeg()
// #endregion
// #region Experiments
async experiments(){
try {
//wait for modules to be loaded
await Webpack.waitForModule(Webpack.Filters.byStoreName("DeveloperExperimentStore"));
await Webpack.waitForModule(Webpack.Filters.byStoreName("ExperimentStore"));
//code slightly modified from https://gist.github.com/JohannesMP/afdf27383608c3b6f20a6a072d0be93c?permalink_comment_id=4784940#gistcomment-4784940
let wpRequire;
webpackChunkdiscord_app.push([[Math.random()], {}, (req) => { wpRequire = req; }]);
let u = Object.values(wpRequire.c).find((x) => x?.exports?.default?.getCurrentUser && x?.exports?.default?._dispatcher?._actionHandlers).exports.default
let m = Object.values(u._dispatcher._actionHandlers._dependencyGraph.nodes);
u.getCurrentUser().flags |= 1;
m.find((x) => x.name === "DeveloperExperimentStore").actionHandler["CONNECTION_OPEN"]();
try { m.find((x) => x.name === "ExperimentStore").actionHandler["OVERLAY_INITIALIZE"]({ user: { flags: 1 } }); } catch {}
m.find((x) => x.name === "ExperimentStore").storeDidChange();
} catch(err){
//Logger.error(this.meta.name, err);
}
}
// #endregion
// #region Client Themes
clientThemes(){
//delete isPreview property so that we can set our own
delete clientThemesModule.isPreview;
//this property basically unlocks the client theme buttons
Object.defineProperty(clientThemesModule, "isPreview", { //Enabling the nitro theme settings
value: false,
configurable: true,
enumerable: true,
writable: true,
});
//Patching saveClientTheme function.
Patcher.instead(this.meta.name, themesModule, "saveClientTheme", (_, [args]) => {
if(args.backgroundGradientPresetId == undefined){
//If this number is -1, that indicates to the plugin that the current theme we're setting to is not a gradient nitro theme.
settings.lastGradientSettingStore = -1;
//save any changes to settings
//Utilities.saveSettings(this.meta.name, this.settings);
Data.save(this.meta.name, "settings", this.settings);
//if user is trying to set the theme to the default dark theme
if(args.theme == 'dark'){
//dispatch settings update to change to dark theme
Dispatcher.dispatch({
type: "SELECTIVELY_SYNCED_USER_SETTINGS_UPDATE",
changes: {
appearance: {
shouldSync: false, //prevent sync to stop discord api from butting in. Since this is not a nitro theme, shouldn't this be set to true? Idk, but I'm not touching it lol.
settings: {
theme: 'dark', //default dark theme
developerMode: true //genuinely have no idea what this does.
}
}
}
});
//get rid of gradient theming.
resetPreviewClientTheme();
return;
}
//if user is trying to set the theme to the default light theme
if(args.theme == 'light'){
//dispatch settings update event to change to light theme
Dispatcher.dispatch({
type: "SELECTIVELY_SYNCED_USER_SETTINGS_UPDATE",
changes: {
appearance: {
shouldSync: false, //prevent sync to stop discord api from butting in
settings: {
theme: 'light', //default light theme
developerMode: true
}
}
}
});
}
return;
}else{ //gradient themes
//Store the last gradient setting used in settings
settings.lastGradientSettingStore = args.backgroundGradientPresetId;
//save any changes to settings
Data.save(this.meta.name, "settings", this.settings);
//dispatch settings update event to change to the gradient the user chose
Dispatcher.dispatch({
type: "SELECTIVELY_SYNCED_USER_SETTINGS_UPDATE",
changes: {
appearance: {
shouldSync: false, //prevent sync to stop discord api from butting in
settings: {
theme: args.theme, //gradient themes are based off of either dark or light, args.theme stores this information
clientThemeSettings: {
backgroundGradientPresetId: args.backgroundGradientPresetId //preset ID for the gradient theme
},
developerMode: true
}
}
}
});
//update background gradient preset to the one that was just chosen.
Dispatcher.dispatch({
type: "UPDATE_BACKGROUND_GRADIENT_PRESET",
presetId: settings.lastGradientSettingStore
});
}
}); //End of saveClientTheme patch.
//If last appearance choice was a nitro client theme
if(settings.lastGradientSettingStore != -1){
//This sets the gradient on plugin save and load.
Dispatcher.dispatch({
type: "UPDATE_BACKGROUND_GRADIENT_PRESET",
presetId: settings.lastGradientSettingStore
});
}
//startSession patch. This function runs upon switching accounts.
Patcher.after(this.meta.name, accountSwitchModule, "startSession", () => {
setTimeout(() => {
//If last appearance choice was a nitro client theme
if(settings.lastGradientSettingStore != -1){