This repository has been archived by the owner on Sep 4, 2024. It is now read-only.
forked from d0t3k1/d0t-s0urce-prettier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnalegified-d0urce.js
1772 lines (1625 loc) · 92 KB
/
nalegified-d0urce.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 nalegified-d0urce
// @namespace http://tampermonkey.net/
// @version 1.6.4-1
// @description Get a prettier s0urce.io environment! Template made by Xen0o2.
// @author Xen0o2, d0t, Naleg
// @match https://s0urce.io/
// @icon https://www.google.com/s2/favicons?sz=64&domain=s0urce.io
// @grant none
// @downloadURL https://raw.githubusercontent.com/NalegFR/nalegified-d0urce/main/nalegified-d0urce.js
// @updateURL https://raw.githubusercontent.com/NalegFR/nalegified-d0urce/main/nalegified-d0urce.js
// ==/UserScript==
const VERSION = "1.6.4"
const themes = {
"No Theme": ":root{--color-terminal:#85ff49;--color-darkgreen:#85ff492f} .window:has(img[src='icons/terminal.svg']){border-color: #85ff49} #section-code{background: linear-gradient(180deg, #000000 3%, #85ff4940 123%)} #themes{border: 1px solid #85ff49} .target-bar{outline: 1px solid #85ff49 !important}",
"Atom One": "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#b270ff;}.hljs-comment,.hljs-quote{color:#b270ff;font-style:italic}.hljs-doctag,.hljs-formula,.hljs-keyword{color:#b270ff}.hljs-deletion,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-subst{color:#b270ff}.hljs-literal{color:#b270ff}.hljs-addition,.hljs-attribute,.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#b270ff}.hljs-attr,.hljs-number,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-pseudo,.hljs-template-variable,.hljs-type,.hljs-variable{color:#b270ff}.hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-symbol,.hljs-title{color:#b270ff}.hljs-built_in,.hljs-class .hljs-title,.hljs-title.class_{color:#b270ff}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-link{text-decoration:underline}:root{--color-terminal:#b270ff;--color-darkgreen:#b270ff2f} .window:has(img[src='icons/terminal.svg']){border-color: #b270ff} #section-code{background: linear-gradient(180deg, #000000 3%, #b270ff40 123%)} #themes{border: 1px solid #b270ff} .target-bar{outline: 1px solid #b270ff !important}",
"Monokai": "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#ff3838}.hljs-subst,.hljs-tag{color:#ff3838}.hljs-emphasis,.hljs-strong{color:#ff3838}.hljs-bullet,.hljs-link,.hljs-literal,.hljs-number,.hljs-quote,.hljs-regexp{color:#ff3838}.hljs-code,.hljs-section,.hljs-selector-class,.hljs-title{color:#ff3838}.hljs-strong{font-weight:700}.hljs-emphasis{font-style:italic}.hljs-attr,.hljs-keyword,.hljs-name,.hljs-selector-tag{color:#ff3838}.hljs-attribute,.hljs-symbol{color:#ff3838}.hljs-class .hljs-title,.hljs-params,.hljs-title.class_{color:#ff3838}.hljs-addition,.hljs-built_in,.hljs-selector-attr,.hljs-selector-id,.hljs-selector-pseudo,.hljs-string,.hljs-template-variable,.hljs-type,.hljs-variable{color:#ff3838}.hljs-comment,.hljs-deletion,.hljs-meta{color:#ff3838}:root{--color-terminal:#ff3838;--color-darkgreen:#ff38382f} .window:has(img[src='icons/terminal.svg']){border-color: #ff3838} #section-code{background: linear-gradient(180deg, #000000 3%, #ff383840 123%)} #themes{border: 1px solid #ff3838} .target-bar{outline: 1px solid #ff3838 !important}",
"The Deep": "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#3d8566}.hljs-keyword{color:#3d8566;font-style:italic}.hljs-built_in{color:#3d8566;font-style:italic}.hljs-type{color:#3d8566}.hljs-literal{color:#3d8566}.hljs-number{color:#3d8566}.hljs-regexp{color:#3d8566}.hljs-string{color:#3d8566}.hljs-subst{color:#3d8566}.hljs-symbol{color:#3d8566}.hljs-class{color:#3d8566}.hljs-function{color:#3d8566}.hljs-title{color:#3d8566;font-style:italic}.hljs-params{color:#3d8566}.hljs-comment{color:#3d8566;font-style:italic}.hljs-doctag{color:#3d8566}.hljs-meta,.hljs-meta .hljs-keyword{color:#3d8566}.hljs-meta .hljs-string{color:#3d8566}.hljs-section{color:#3d8566}.hljs-attr,.hljs-name,.hljs-tag{color:#3d8566}.hljs-attribute{color:#3d8566}.hljs-variable{color:#3d8566}.hljs-bullet{color:#3d8566}.hljs-code{color:#3d8566}.hljs-emphasis{color:#3d8566;font-style:italic}.hljs-strong{color:#3d8566;font-weight:700}.hljs-formula{color:#3d8566}.hljs-link{color:#3d8566}.hljs-quote{color:#3d8566;font-style:italic}.hljs-selector-tag{color:#3d8566}.hljs-selector-id{color:#3d8566}.hljs-selector-class{color:#3d8566;font-style:italic}.hljs-selector-attr,.hljs-selector-pseudo{color:#3d8566;font-style:italic}.hljs-template-tag{color:#3d8566}.hljs-template-variable{color:#3d8566}.hljs-addition{color:#3d8566;font-style:italic}.hljs-deletion{color:#3d8566;font-style:italic}:root{--color-terminal:#3d8566;--color-darkgreen:#3d85662f} .window:has(img[src='icons/terminal.svg']){border-color: #3d8566} #section-code{background: linear-gradient(180deg, #000000 3%, #3d856640 123%)} #themes{border: 1px solid #3d8566} .target-bar{outline: 1px solid #3d8566 !important}",
"Light Mode": "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#ffffff}.hljs-keyword{color:#ffffff;font-style:italic}.hljs-built_in{color:#ffffff;font-style:italic}.hljs-type{color:#ffffff}.hljs-literal{color:#ffffff}.hljs-number{color:#ffffff}.hljs-regexp{color:#ffffff}.hljs-string{color:#ffffff}.hljs-subst{color:#ffffff}.hljs-symbol{color:#ffffff}.hljs-class{color:#ffffff}.hljs-function{color:#ffffff}.hljs-title{color:#ffffff;font-style:italic}.hljs-params{color:#ffffff}.hljs-comment{color:#ffffff;font-style:italic}.hljs-doctag{color:#ffffff}.hljs-meta,.hljs-meta .hljs-keyword{color:#ffffff}.hljs-meta .hljs-string{color:#ffffff}.hljs-section{color:#ffffff}.hljs-attr,.hljs-name,.hljs-tag{color:#ffffff}.hljs-attribute{color:#ffffff}.hljs-variable{color:#ffffff}.hljs-bullet{color:#ffffff}.hljs-code{color:#ffffff}.hljs-emphasis{color:#ffffff;font-style:italic}.hljs-strong{color:#ffffff;font-weight:700}.hljs-formula{color:#c792ea}.hljs-link{color:#ffffff}.hljs-quote{color:#ffffff;font-style:italic}.hljs-selector-tag{color:#ffffff}.hljs-selector-id{color:#ffffff}.hljs-selector-class{color:#ffffff;font-style:italic}.hljs-selector-attr,.hljs-selector-pseudo{color:#ffffff;font-style:italic}.hljs-template-tag{color:#ffffff}.hljs-template-variable{color:#ffffff}.hljs-addition{color:#ffffff;font-style:italic}.hljs-deletion{color:#ffffff;font-style:italic}:root{--color-terminal:#ffffff;--color-darkgreen:#ffffff2f} .window:has(img[src='icons/terminal.svg']){border-color: #ffffff} #section-code{background: linear-gradient(180deg, #000000 3%, #ffffff40 123%)} #themes{border: 1px solid #ffffff} .target-bar{outline: 1px solid #ffffff !important}",
"Mythic Myer": "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#05a8ff;}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#05a8ff}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#05a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#05a8ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#05a8ff}.hljs-built_in,.hljs-symbol{color:#05a8ff}.hljs-code,.hljs-comment,.hljs-formula{color:#05a8ff}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#05a8ff}.hljs-subst{color:#05a8ff}.hljs-section{color:#05a8ff;font-weight:700}.hljs-bullet{color:#05a8ff}.hljs-emphasis{color:#05a8ff;font-style:italic}.hljs-strong{color:#05a8ff;font-weight:700}.hljs-addition{color:#05a8ff;background-color:#05a8ff}.hljs-deletion{color:#05a8ff;background-color:#05a8ff}:root{--color-terminal:#05a8ff;--color-darkgreen:#05a8ff2f} .window:has(img[src='icons/terminal.svg']){border-color: #05a8ff} #section-code{background: linear-gradient(180deg, #000000 3%, #05a8ff40 123%)} #themes{border: 1px solid #05a8ff} .target-bar{outline: 1px solid #05a8ff !important}",
"Ethereal Enjoyer": "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#ffb74e}.hljs-subst,.hljs-tag{color:#ffb74e}.hljs-emphasis,.hljs-strong{color:#ffb74e}.hljs-bullet,.hljs-link,.hljs-literal,.hljs-number,.hljs-quote,.hljs-regexp{color:#ffb74e}.hljs-code,.hljs-section,.hljs-selector-class,.hljs-title{color:#ffb74e}.hljs-strong{font-weight:700}.hljs-emphasis{font-style:italic}.hljs-attr,.hljs-keyword,.hljs-name,.hljs-selector-tag{color:#ffb74e}.hljs-attribute,.hljs-symbol{color:#ffb74e}.hljs-class .hljs-title,.hljs-params,.hljs-title.class_{color:#ffb74e}.hljs-addition,.hljs-built_in,.hljs-selector-attr,.hljs-selector-id,.hljs-selector-pseudo,.hljs-string,.hljs-template-variable,.hljs-type,.hljs-variable{color:#ffb74e}.hljs-comment,.hljs-deletion,.hljs-meta{color:#ffb74e}:root{--color-terminal:#ffb74e;--color-darkgreen:#ffb74e2f} .window:has(img[src='icons/terminal.svg']){border-color: #ffb74e} #section-code{background: linear-gradient(180deg, #000000 3%, #ffb74e40 123%)} #themes{border: 1px solid #ffb74e} .target-bar{outline: 1px solid #ffb74e !important}:root{--color-terminal:#ffb74e;--color-darkgreen:#ffb74e2f} .window:has(img[src='icons/terminal.svg']){border-color: #ffb74e} #section-code{background: linear-gradient(180deg, #000000 3%, #ffb74e40 123%)} #themes{border: 1px solid #ffb74e} .target-bar{outline: 1px solid #ffb74e !important}",
}
class Component {
prepend;
element;
constructor(type, options) {
this.prepend = options.prepend;
const element = document.createElement(type);
if (options.classList)
element.classList.add(...options.classList);
for (let attribute of Object.keys(options.style || {}))
element.style[attribute] = options.style[attribute];
if (options.id)
element.id = options.id;
if (options.src)
element.src = options.src;
if (options.type)
element.type = options.type;
if (options.innerText)
element.innerText = options.innerText
if (options.innerHTML)
element.innerHTML = options.innerHTML;
if (options.placeholder)
element.placeholder = options.placeholder;
if (options.value)
element.value = options.value;
if (options.onclick)
element.onclick = options.onclick;
if (options.onchange)
element.onchange = options.onchange;
if (options.selected)
element.selected = options.selected;
if (options.onfocusout)
element.onfocusout = options.onfocusout;
if (options.onblur)
element.onblur = options.onblur;
if (options.onmouseenter)
element.onmouseenter = options.onmouseenter;
if (options.onmouseleave)
element.onmouseleave = options.onmouseleave;
options.children?.forEach(child => {
child.prepend ? element.prepend(child.element) : element.append(child.element)
})
this.element = element;
return this;
}
}
const removeContextMenu = (removeSelection) => {
document.querySelector(".context-menu-container")?.remove();
const selectedItem = document.querySelectorAll(".item-selected")
selectedItem.forEach(item => {
item.style.outline = null;
item.classList.remove("item-selected")
})
if (removeSelection)
player.selectedItems = [];
}
class Popup {
#popup;
#dimensions = {
width: 150,
height: 0,
}
#pointer;
constructor (pointer) {
this.#pointer = pointer;
const popup = new Component("div", {
classList: ["context-menu", "context-menu-container"],
style: {
position: "absolute", width: `${this.#dimensions.width}px`,
backgroundColor: "#000000E6", borderRadius: "8px", display: "flex", flexDirection: "column", gap: "5px", zIndex: "1000", padding: "5px",
boxShadow: "5px 5px 15px 5px #000000",
border: "1px solid #ffffff66"
},
children: [
new Component("div", {
classList: ["context-menu", "context-menu-title"],
style: { color: "var(--color-lightgrey)", padding: "7px", order: 1, fontSize: "10px", borderTop: "1px solid var(--color-lightgrey)", display: "none" }
})
]
})
this.#popup = popup.element;
return this;
}
#getPosition = (pointer, dimensions) => {
const finalPosition = {...pointer};
const windowDimensions = { height: document.body.clientHeight, width: document.body.clientWidth };
if (pointer.clientY > windowDimensions.height - (dimensions.height + 20))
finalPosition.clientY -= (dimensions.height + 10);
else
finalPosition.clientY += 10;
if (pointer.clientX > windowDimensions.width - (dimensions.width + 20))
finalPosition.clientX -= (dimensions.width + 10);
else
finalPosition.clientX += 10;
return finalPosition;
}
setTitle(text) {
this.#popup.querySelector(".context-menu-title").innerText = text;
this.#popup.querySelector(".context-menu-title").style.display = "flex";
}
addAction(text, action, option = {isDangerous: false, selectionLimit: 0}) {
const component = new Component("div", {
classList: [
"context-menu",
"context-menu-option",
"context-menu-option-" + (this.#dimensions.height / 40 + 1),
"context-menu-option-limit-" + option.selectionLimit,
],
innerText: text,
style: { width: "100%", borderRadius: "4px", padding: "5px", cursor: "pointer", color: option.isDangerous ? "var(--color-red)" : "white" },
onmouseenter: (e) => e.target.style.backgroundColor = "#5be22e66",
onmouseleave: (e) => e.target.style.backgroundColor = "unset",
onclick: async () => {
removeContextMenu();
if (action)
await action();
player.selectedItems = [];
},
})
this.#popup.appendChild(component.element);
this.#dimensions.height += 40;
return this;
}
create() {
const position = this.#getPosition(this.#pointer, this.#dimensions);
this.#popup.style.top = `${position.clientY}px`;
this.#popup.style.left = `${position.clientX}px`,
document.body.appendChild(this.#popup);
}
}
const windowNames = [
"Filament",
"Inventory",
"Item Seller",
"Computer",
]
const lootRarity = [
{ name: "common", color: "linear-gradient(211deg, #585d66 0%, #7d848f 100%)" },
{ name: "uncommon", color: "linear-gradient(211deg, #007c37 0%, #83b200 100%)" },
{ name: "rare", color: "linear-gradient(211deg, #00427c 0%, #0092ed 100%)" },
{ name: "epic", color: "linear-gradient(211deg, #5c045a 0%, #a90052 100%)" },
{ name: "legendary", color: "linear-gradient(112deg, #a95300 4%, #ff9605 34%, #a95300 66%, #ff9605 100%)" },
{ name: "mythic", color: "linear-gradient(112deg, #40f5ff 4%, #05a8ff 34%, #40f5ff 66%, #05a8ff 100%)" },
{ name: "ethereal", color: "linear-gradient(112deg, #ffb74e 4%, #ffe6a2 34%, #ffb74e 66%, #ffe6a2 100%)" },
];
const raritiesVariables = {
"var(--color-SSS)": "ethereal",
"var(--color-SS)": "mythic",
"var(--color-S)" : "legendary",
"var(--color-A)" : "epic",
"var(--color-B)" : "rare",
"var(--color-C)" : "uncommon",
"var(--color-D)" : "common"
}
const lootButtons = {
"take" : "button > img[src='icons/inventory.svg']",
"sell" : "button > img[src='icons/btc.svg']",
"shred": "button > img[src='icons/filament.svg']"
}
const player = {
username: document.querySelector("img[src='icons/online.svg']")?.parentNode?.innerText?.trim(),
hacksInProgress: [],
currentlyHacking: null,
lastHacked: null,
configuration: {
openInSilent: [],
displayCustomFilament: "ethereal",
currentTheme: localStorage.getItem("prettier-currentTheme") || Object.keys(themes)[0],
codeSyntaxing: !!localStorage.getItem("prettier-codeSyntaxing")
},
input: {
isShiftDown: false,
},
selectedItems: [],
autoloot: localStorage.getItem("prettier-autoloot") ?
JSON.parse(localStorage.getItem("prettier-autoloot")) :
{
common: "take",
uncommon: "take",
rare: "take",
epic: "take",
legendary: "take",
mythic: "take",
},
}
const stats = {
cpu: [
{ hack: [8, 18], trueDam: [0, 0], pen: [0, 0], chance: [0, 0], dam: [0, 0] },
{ hack: [18.5, 33.5], trueDam: [0, 10], pen: [0, 5], chance: [0, 2.5], dam: [1, 5] },
{ hack: [34, 54], trueDam: [0, 20], pen: [0, 15], chance: [2.5, 3.25], dam: [5, 7.5] },
{ hack: [55, 64.25], trueDam: [0, 30], pen: [0, 20], chance: [4, 6.25], dam: [8.25, 15] },
{ hack: [68.75, 84.75], trueDam: [0, 40], pen: [13, 25], chance: [6.5, 7.5], dam: [17, 25] },
{ hack: [91, 105], trueDam: [43, 50], pen: [19.5, 30], chance: [8.25, 10], dam: [19.5, 30] },
{ hack: [125.5,135.5], trueDam: [55,60], pen: [32.5,35], chance: [11.25,12.5], dam: [32.5,35] }
],
firewall: [
{ hp: [22,62], rd: [0,0], regen: [0,0], medium: [0,0], long: [0,0] },
{ hp: [64,114], rd: [0,7.5], regen: [0,2.5], medium: [0,0], long: [0,0] },
{ hp: [116,166], rd: [0,10], regen: [0,5], medium: [0,30], long: [0,0] },
{ hp: [172,217], rd: [0,12.5], regen: [0,7.5], medium: [22,40], long: [0,25] },
{ hp: [234,269], rd: [0,15], regen: [8,10], medium: [34,0], long: [22,30] },
{ hp: [285,320], rd: [11.5,15], regen: [10.75,12.5], medium: [65,47.5], long: [28,35] },
{ hp: [372,397], rd: [16.25,17.5], regen: [13.75,15], medium: [80,70], long: [37.5,45] }
],
gpu: [
{ idle: [0.000010,0.000014], bart: [0,0], crip: [0,0], },
{ idle: [0.000011,0.000024], bart: [0,10], crip: [2.5,10], },
{ idle: [0.000016,0.000033], bart: [0,12.5], crip: [2.5,12.5], },
{ idle: [0.0000223,0.000043], bart: [0,15], crip: [6,15], },
{ idle: [0.0000348,0.000054], bart: [0,20], crip: [10,20], },
{ idle: [0.0000516,0.000074], bart: [16.25,25], crip: [16.25,25], },
{ idle: [0.000077,0.000094], bart: [22.5,30], crip: [22.5,30], }
],
psu: [
{ boost: [1, 5], },
{ boost: [5, 10], },
{ boost: [10, 15], },
{ boost: [16, 25], },
{ boost: [27, 35], },
{ boost: [36.5, 40], },
{ boost: [50, 55], },
],
port: [
{ hp: 1000+3*60, rd: 0 },
{ hp: 1000+3*114, rd: 3*0.075 },
{ hp: 1000+3*166, rd: 3*0.1 },
{ hp: 1000+3*217, rd: 3*0.125 },
{ hp: 1000+3*269, rd: 3*0.15 },
{ hp: 1000+3*320, rd: 3*0.15 },
{ hp: 1000+3*397, rd: 3*0.175}
],
cputerm: [
3, 3.5, 4, 4.25, 4.75, 5, 5.5
],
fireterm: [
12, 14, 16, 17, 19, 20, 22
],
gpu_term: [
0.0000042*0.6, 0.0000042*0.7, 0.0000042*0.8, 0.0000042*0.85, 0.0000042*0.95, 0.0000042, 0.0000042*1.1
],
psu_term: [
1.2, 1.4, 1.6, 1.7, 1.9, 2, 2.2
],
// Last updated as of 7/4/2024
filament_price: [
0.01, 0.03, 0.1, 0.3, 1.5, 4.5, 67.5
],
};
(function() {
'use strict';
const sleep = (ms) => {
return new Promise(resolve => setTimeout(resolve, ms));
}
const editProgressBar = () => {
const progressBar = (document.querySelectorAll(".topbar-value") || [])[2]
if (!progressBar)
return;
progressBar.style.resize = "horizontal";
}
const prettierLoadFails = (code) => {
alert(`Prettier-s0urce loading failed, please contact Xen0o2 on Discord (error code: ${code})`);
}
const sendLog = async (HTMLContent) => {
const wrapper = document.querySelector("#wrapper.svelte-182ewru");
if (!wrapper)
return;
const message = new Component("div", {
innerHTML: HTMLContent,
style: { padding: "5px 0" },
classList: ["message"],
})
const separator = new Component("div", {
style: { margin: "10px 0" },
classList: ["line", "svelte-182ewru"]
})
wrapper.append(message.element);
wrapper.append(separator.element);
await sleep(100);
wrapper.scrollTop = wrapper.scrollHeight;
}
const manageMessagesToDelete = (message) => {
const deleteSample = [
"Hack successful",
"to reach level",
"earned",
]
if (deleteSample.some(sample => message.innerText.includes(sample)))
message.remove();
}
const colorizeTerminal = async () => {
const codeElement = document.querySelector("#code-list");
const codeSection = document.querySelector("#section-code");
if (!codeElement || !codeSection) return;
document.querySelector("#highlighted")?.remove();
codeElement.style.display = "none";
const codeContent = codeElement.innerHTML
.replace(/<br(\/)?>/g, "\n")
.replace(/<span style="margin-left: 30px;">/g, "\t");
const highlighted = new Component("pre", {
id: "highlighted",
children: [
new Component("code", {
innerHTML: codeContent,
classList: ["language-python"],
style: { tabSize: "30px" }
})
]
})
codeSection.appendChild(highlighted.element);
hljs.highlightAll();
await sleep(100);
codeSection.scrollTop = codeSection.scrollHeight;
}
const customTerminal = () => {
const wrapper = document.querySelector("#section-target > div");
if (!wrapper) return;
const component = new Component("div", {
classList: ["svelte-1fdvo7g"],
style: { height: "30px", width: "59%", display: "flex", alignItems: "center", justifyContent: "space-between", marginTop: "10px" },
children: [
new Component("span", {
innerText: "Theme",
}),
new Component("div", {
id: "themes",
style: { textAlign: "left", position: "relative", height: "100%", width: "200px", display: "flex", justifyContent: "center", alignItems: "center", border: "1px solid var(--color-terminal)", borderRadius: "2px", fontFamily: "var(--font-family-2)", color: "var(--color-terminal)", fontWeight: 500 },
children: [
new Component("div", {
style: { display: "flex", justifyContent: "space-between", alignItems: "center", width: "85%" },
children: [
new Component("span", {
id: "selected-theme",
innerText: player.configuration.currentTheme,
}),
new Component("img", {
src: "https://upload.wikimedia.org/wikipedia/commons/9/96/Chevron-icon-drop-down-menu-WHITE.png",
style: { height: "10px", opacity: "0.8" }
}),
]
}),
new Component("select", {
style: { position: "absolute", left: 0, height: "100%", width: "100%", opacity: "0" },
onchange: (e) => {
player.configuration.currentTheme = e.target.value;
localStorage.setItem("prettier-currentTheme", e.target.value);
document.querySelector("#selected-theme").innerText = e.target.value;
updateThemeStyle();
},
children: Object.keys(themes).map(theme => {
return new Component("option", {
value: theme,
innerText: theme,
selected: theme === player.configuration.currentTheme
})
})
})
]
})
]
})
wrapper.appendChild(component.element);
}
const counterHack = (hackInProgress) => {
hackInProgress.footer?.remove();
const terminalProgressBar = document.querySelector(".target-bar-progress");
const wrapper = document.querySelector("#wrapper.svelte-182ewru");
if (!terminalProgressBar || !wrapper)
return;
const counterLabel = new Component("span", {
innerText: "Counter hack progression (0%)",
})
const counterProgressBar = new Component("div", {
style: { width: "100%", height: "15px", background: "var(--color-grey)", borderRadius: "4px", margin: "5px 0", display: "flex", justifyContent: "space-between", alignItems: "center" },
})
const counterProgressBarValue = new Component("div", {
style: { width: terminalProgressBar.style.width, height: "15px", background: "var(--color-terminal)", borderRadius: "4px", transitionDuration: "0.3s" }
})
hackInProgress.message?.append(counterLabel.element);
hackInProgress.message?.append(counterProgressBar.element);
counterProgressBar.element.append(counterProgressBarValue.element);
wrapper.scrollTop = wrapper.scrollHeight;
hackInProgress.counterLabel = counterLabel.element;
hackInProgress.counterProgressBar = counterProgressBar.element;
hackInProgress.counterProgressBarValue = counterProgressBarValue.element;
const hackObserver = new MutationObserver(function(mutations) {
const value = parseInt(mutations[0].target.style.width.slice(0, -1));
counterLabel.element.innerText = counterLabel.element.innerText.replace(/\d{1,3}%/, value + "%");
counterProgressBarValue.element.style.width = value + "%";
});
hackObserver.observe(terminalProgressBar, { attributes: true, attributeFilter: ["style"] });
hackInProgress.hackObserver = hackObserver;
}
const manageBeingHacked = (message) => {
const hacker = message.querySelectorAll(".tag")[0]?.innerText || (message.innerText.match(/by .+ on/) || [])[0]?.slice(3, -3);
const port = (message.innerText.match(/on port \d+\./) || [])[0]?.slice(8, -1);
const already = player.hacksInProgress.find(e => e.hacker == hacker);
const progression = parseInt((message.innerText.match(/\d{1,3}(\.\d{1,2})?%/) || ["100%"])[0].slice(0, -1));
if (already) {
if (progression == 100) {
already.separator?.remove();
already.message?.remove();
player.hacksInProgress.splice(player.hacksInProgress.indexOf(already), 1);
} else {
already.hackLabel.innerText = already.hackLabel.innerText.replace(/\d+%/, progression + "%");
already.progressBarValue.style.width = progression + "%";
}
message.remove();
} else if (port) {
const redButtons = message.querySelectorAll(".tag");
redButtons[0].remove();
message.innerText = ""
const iconElement = new Component("img", {
src: "icons/hack-red.svg",
classList: ["icon"],
style: { marginRight: "9px" }
})
const hackLabel = new Component("span", {
innerText: `${hacker} is hacking you (${progression}%) on port ${port}`,
})
const progressBar = new Component("div", {
style: { width: "100%", height: "15px", background: "var(--color-grey)", borderRadius: "4px", margin: "5px 0", display: "flex", justifyContent: "space-between", alignItems: "center" },
})
const progressBarValue = new Component("div", {
style: { width: `${progression}%`, height: "15px", background: "var(--color-red)", borderRadius: "4px", transitionDuration: "0.3s" },
})
const separator = new Component("div", {
style: { margin: "10px 0" },
classList: ["line", "svelte-182ewru"]
})
message.append(iconElement.element);
message.append(hackLabel.element);
message.append(progressBar.element);
progressBar.element.append(progressBarValue.element);
const alreadyCounterHacking = hacker == player.currentlyHacking;
if (alreadyCounterHacking) {
player.hacksInProgress.push({
hacker: hacker,
counterButton: redButtons[1],
message,
hackLabel: hackLabel.element,
progression,
progressBar: progressBar.element,
progressBarValue: progressBarValue.element,
separator: separator.element,
})
counterHack(player.hacksInProgress[player.hacksInProgress.length - 1])
} else {
const footer = new Component("span", {
innerText: "Click to counter",
style: { fontSize: "0.7rem", color: "var(--color-lightgrey)" }
})
message.append(footer.element);
player.hacksInProgress.push({
hacker: hacker,
counterButton: redButtons[1],
message,
hackLabel: hackLabel.element,
progression,
progressBar: progressBar.element,
progressBarValue: progressBarValue.element,
separator: separator.element,
footer: footer.element
})
}
message.parentNode.append(separator.element);
message.style.cursor = "pointer";
message.style.padding = " 5px 5px 5px 0";
message.style.borderRadius = "4px";
message.onclick = async () => {
redButtons[1].click();
await sleep(300);
counterHack(message);
};
message.onmouseenter = () => message.style.backgroundColor = "#ffffff1a";
message.onmouseleave = () => message.style.backgroundColor = "transparent";
}
}
const hasBeenHacked = (window) => {
const username = window.querySelector("#wrapper > div > div > span")?.innerText;
const message = window.querySelector("#message")?.innerText;
const ascii = window.querySelector(".code")?.innerText;
if (!username || !message || !ascii)
return;
window.remove();
document.querySelector(".taskbar-item > img[src='icons/hack.svg']")?.parentNode?.remove();
const hackedWindow = new Component("div", {
id: "hacked-window",
classList: ["window", "svelte-1hjm43z", "window-selected"],
style: { zIndex: "56", top: "60px", right: "10px" },
children: [
new Component("div", {
id: "to-drag",
classList: ["window-title", "svelte-1hjm43z"],
innerText: "Hacked",
children: [
new Component("img", {
prepend: true,
src: "icons/hack-red.svg",
classList: ["icon", "icon-in-text"]
}),
new Component("button", {
onclick: () => document.getElementById("hacked-window")?.remove(),
classList: ["window-close", "svelte-1hjm43z"],
children: [
new Component("img", {
src: "icons/close.svg",
classList: ["icon"]
})
]
})
]
}),
new Component("div", {
classList: ["window-content", "svelte-1hjm43z"],
style: { width: "calc(300px)", height: "calc(350px)", padding: "10px" },
children: [
new Component("div", {
id: "content",
style: { display: "flex", flexDirection: "column", height: "100%", justifyContent: "center" },
children: [
new Component("div", {
innerText: username,
style: { fontSize: "14px", marginBottom: "4px", fontFamily: "var(--font-family-2)", fontWeight: "500" },
}),
new Component("div", {
id: "message",
innerText: message,
classList: ["svelte-w2dcq9"],
style: { fontFamily: "var(--font-family-2)" }
}),
new Component("div", {
id: "monitor",
style: { width: "100%" },
classList: ["svelte-w2dcq9"],
children: [
new Component("div", {
id: "bezel",
style: { position: "relative", height: "100%", width: "100%" },
children: [
new Component("div", {
id: "crt",
classList: ["off", "svelte-w2dcq9"],
style: { height: "100%" },
children: [
new Component("div", {
classList: ["scanline", "svelte-w2dcq9"]
}),
new Component("div", {
classList: ["terminal", "svelte-w2dcq9"],
children: [
new Component("div", {
id: "ascii",
classList: ["svelte-w2dcq9"],
children: [
new Component("pre", {
children: [
new Component("div", {
style: { fontSize: "8px" },
classList: ["code", "svelte-1uaaqnw"],
innerText: ascii
})
]
})
]
})
]
})
]
})
]
})
]
})
]
})
]
}),
new Component("div", {
id: "hacked-progress",
style: { position: "absolute", backgroundColor: "var(--color-terminal)", height: "3px", width: "100%", borderRadius: "4px", transform: "translateY(-1px)", transitionDuration: "0.3s" }
})
]
})
document.querySelector("main").append(hackedWindow.element);
const duration = 5000;
const interval = 50;
let loop;
loop = setInterval(() => {
const progressbar = document.getElementById("hacked-progress");
if (!progressbar) return;
const current = progressbar.style.width.slice(0, -1);
progressbar.style.width = (current - 100 / (duration / interval)).toFixed(1) + "%";
if (progressbar.style.width.slice(0, -1) <= 0) {
hackedWindow.element.remove();
if (loop)
clearInterval(loop);
}
}, interval);
}
const logObserver = new MutationObserver(function(mutations) {
const messages = mutations.filter(e =>
e.target.id == "wrapper"
&& (!e.nextSibling || !e.nextSibling[0])
&& e.addedNodes
&& e.addedNodes[0]?.classList?.contains("message"))
if (!messages.length)
return;
messages.forEach(messageElement => {
const message = messageElement.addedNodes[0];
manageMessagesToDelete(message);
if (message.innerText.includes("being hacked") || message.innerText.includes("been hacked"))
manageBeingHacked(message);
})
});
const windowCloseObserver = new MutationObserver(async function(mutations) {
const windowClosed = mutations.find(e => {
return e.target == document.querySelector("main") &&
e.removedNodes.length == 1 &&
e.removedNodes[0]?.classList?.contains("window", "svelte-1hjm43z")
})
if (!windowClosed)
return;
const isLogWindow = windowClosed.removedNodes[0].querySelector(".window-title > img[src='icons/log.svg']")
if (isLogWindow)
logObserver.disconnect();
const wasHackingSomeone = windowClosed.removedNodes[0].querySelector(".window-title > img[src='icons/terminal.svg']");
if (wasHackingSomeone) {
const currentHackingBy = player.hacksInProgress.find(e => e.hacker == player.currentlyHacking);
if (currentHackingBy) {
const footer = new Component("span", {
innerText: "Click to counter",
style: { fontSize: "0.7rem", color: "var(--color-lightgrey)" }
})
currentHackingBy.counterLabel?.remove();
currentHackingBy.counterProgressBar?.remove();
currentHackingBy.message.append(footer.element);
currentHackingBy.footer = footer.element;
}
player.lastHacked = player.currentlyHacking
player.currentlyHacking = null;
}
})
const firewallEncryption = (hp, rd, regen, ad, ms) => {
rd /= 100;
const cShort = [3.7027,100];
const cMed = [8.2857,ad*3];
const cLong = [13.421,ms*3];
return [1000+hp*3, rd*3, regen*3*.3, (cShort[0]*cShort[1]+cMed[0]*cMed[1]+cLong[0]*cLong[1])/(cShort[1]+cMed[1]+cLong[1])];
}
const penTest = (port, cpu, aTPH) => {
var t = 0;
while (1) {
const damage = cpu[0]*(1+cpu[1]-port[1])+cpu[2];
if (port[0] - damage + port[2]*aTPH <= 0) {
return t + aTPH*(port[0]+port[2]*aTPH)/damage;
} else {
port[0] -= damage;
port[0] += port[2]*aTPH;
t += aTPH;
}
}
}
const netBTCperHour = (idle, barter, crypto) => {
const npcsPerHour = 27.69;
// Based on 1 Hour of Grinding returns
idle *= 3600;
// Maximum bartering benefit is selling uncommons, assuming it is used:
barter /= 100;
barter = ((1+barter)*0.00864000-0.00864000) * npcsPerHour;
// Hack bonus, similar to bartering
crypto /= 100;
crypto = ((1+crypto)*0.00180000-0.00180000) * npcsPerHour;
return idle + barter + crypto;
}
const dPS = (dTI,level,rarity,type) => {
var basePrice = stats.filament_price[rarity];
const value = (level-1)*3*basePrice + basePrice;
if (type != "cpu" && type != "router") basePrice /= 2
console.log(basePrice)
if (rarity < 5) {
if (dTI < 7) return (value).toFixed(4);
else if (dTI < 8) return "~" + (value + (dTI-7)*basePrice/3).toFixed(4);
else if (dTI < 9) return "~" + (value + (dTI-8)*basePrice/3*2 + basePrice/3).toFixed(4);
else if (dTI < 9.9) return "~" + (value + (dTI-9)*basePrice + basePrice).toFixed(4);
} else if (rarity < 6) {
if (dTI < 5) return (value).toFixed(4);
else if (dTI < 6) return "~" + (value + (dTI-5)*basePrice/3).toFixed(4);
else if (dTI < 7) return "~" + (value + (dTI-6)*basePrice/3*2 + basePrice/3).toFixed(4);
else if (dTI < 8) return "~" + (value + (dTI-7)*basePrice + basePrice).toFixed(4);
else if (dTI < 9) return "~" + (value + (dTI-7)*basePrice*5/3 + basePrice*2).toFixed(4);
else if (dTI < 9.7) return "~" + (value + (dTI-7)*basePrice*10/3 + basePrice*11/3).toFixed(4);
} else {
if (dTI < 5) return (value).toFixed(4);
//else if (dTI < 5) return "~" + (value + (dTI-4)*basePrice/6).toFixed(4);
else if (dTI < 6) return "~" + (value + (dTI-5)*basePrice/3).toFixed(4);
else if (dTI < 7) return "~" + (value + (dTI-6)*basePrice/2 + basePrice/3).toFixed(4);
else if (dTI < 8) return "~" + (value + (dTI-7)*basePrice + basePrice*5/6).toFixed(4);
else if (dTI < 9) return "~" + (value + (dTI-8)*basePrice*2 + basePrice*11/6).toFixed(4);
else if (dTI < 9.5) return "~" + (value + (dTI-8)*basePrice*5 + basePrice*23/6).toFixed(4);
}
// If there's no estimated price for it, chances are it's worth a lot
return "Invaluable";
}
const dGI = (idle,barter,crypto,level,rarity) => {
const item = stats.gpu[rarity];
const bestGPU = netBTCperHour(item.idle[1]+stats.gpu_term[rarity]*level,item.bart[1],item.crip[1]);
const worstGPU = netBTCperHour(item.idle[0]+stats.gpu_term[rarity]*level,item.bart[0],item.crip[0]);
const actualGPU = netBTCperHour(idle,barter,crypto);
const qualityRange = bestGPU - worstGPU;
const actualRange = actualGPU - worstGPU;
var gpuRank = 1+((actualRange/qualityRange)*9);
if (gpuRank < 1) gpuRank = 1;
return gpuRank;
}
const boostBTCperHour = (boost,rarity) => {
var idle = stats.gpu[rarity].idle[1]+stats.gpu_term[rarity]
idle *= 3600
boost /= 100
return idle*(1+boost) - idle
}
const dPI = (boost,level,rarity) => {
const item = stats.psu[rarity];
const bestPSU = boostBTCperHour(item.boost[1]+stats.psu_term[rarity]*level,rarity)
const worstPSU = boostBTCperHour(item.boost[0]+stats.psu_term[rarity]*level,rarity)
const actualPSU = boostBTCperHour(boost,rarity)
const qualityRange = bestPSU - worstPSU
const actualRange = actualPSU - worstPSU
var psuRank = 1+((actualRange/qualityRange)*9)
if (psuRank < 1) psuRank = 1
return psuRank
}
const dFI = (hp, rd, rg, enc, level, rarity) => {
const item = stats.firewall[rarity];
const cpu = stats.cpu[rarity];
const cpuV = hackPower(cpu.hack[1]+stats.cputerm[rarity]*(level-1), cpu.trueDam[1], cpu.pen[1], cpu.chance[1], cpu.dam[1]);
const cpsAverage = 5;
const bestPort = firewallEncryption(item.hp[1]+stats.fireterm[rarity]*(level-1),item.rd[1],item.regen[1],item.medium[1],item.long[1]);
const worstPort = firewallEncryption(item.hp[0]+stats.fireterm[rarity]*(level-1),item.rd[0],item.regen[0],item.medium[0],item.long[0]);
const bestHoldout = penTest(bestPort, cpuV, bestPort[3]/cpsAverage+.3);
const worstHoldout = penTest(worstPort, cpuV, worstPort[3]/cpsAverage+.3);
const actualHoldout = penTest([hp,rd,rg],cpuV,enc/cpsAverage+.3);
const qualityRange = worstHoldout - bestHoldout;
const qualityActually = worstHoldout - actualHoldout;
var fireRank = 1+(qualityActually/qualityRange*9);
if (fireRank < 1) fireRank = 1;
return fireRank;
}
const hackPower = (hack, trueDam, pen, chance, dam) => {
pen /= 100;
chance /= 100;
dam /= 100;
return [(100+hack)+(0.05+chance)*(100+hack)*(0.3+dam), pen, trueDam]
}
const dCI = (raw, pen, trueDam, level, rarity) => {
const item = stats.cpu[rarity];
const port = stats.port[rarity];
const bestHackPower = hackPower(item.hack[1]+stats.cputerm[rarity]*(level-1), item.trueDam[1], item.pen[1], item.chance[1], item.dam[1]);
const worstHackPower = hackPower(item.hack[0]+stats.cputerm[rarity]*(level-1), item.trueDam[0], item.pen[0], item.chance[0], item.dam[0]);
const best = port.hp/(bestHackPower[0]*(1+bestHackPower[1]-port.rd)+bestHackPower[2])
const worst = port.hp/(worstHackPower[0]*(1+worstHackPower[1]-port.rd)+worstHackPower[2])
const actual = port.hp/(raw*(1+pen-port.rd) + trueDam)
const qualityRange = worst - best;
const qualityActually = worst - actual;
var cpuRank = 1+((qualityActually/qualityRange)*9);
if (cpuRank < 1) cpuRank = 1;
return cpuRank;
}
// hack = Hack Damage
// trueDam = True Damage
// pen = Hack Armor Penetration
// chance = Hack Critical Damage Chance
// dam = Hack Critical Damage Bonus
const getItemGrade = (type, level, index, effects) => {
switch(type) {
case "cpu":
const hack = effects["Hack Damage"];
const trueDam = effects["True Damage"] || 0;
const pen = effects["Hack Armor Penetration"] || 0;
const chance = effects["Hack Critical Damage Chance"] || 0;
const dam = effects["Hack Critical Damage Bonus"] || 0;
const [raw, penV, trueDamV] = hackPower(hack, trueDam, pen, chance, dam);
return dCI(raw, penV, trueDamV, level, index).toFixed(4);
case "gpu":
const idle = effects["Idle Crypto Mining"]
const bart = effects["More Crypto Reward"] || 0
const crip = effects["Better Barter"] || 0
return dGI(idle, bart, crip, level, index).toFixed(4);
case "psu":
const boost = effects["Crypto Mining Power"]
return dPI(boost, level, index).toFixed(4)
case "router":
const hp = effects["Firewall Health"];
const rd = effects["Firewall Damage Reduction"] || 0;
const rg = effects["Firewall Regeneration"] || 0;
const ad = effects["Firewall Advanced Encryption"] || 0;
const ms = effects["Firewall Master Encryption"] || 0;
const [hpP, rdP, rgP, encryption] = firewallEncryption(hp,rd,rg,ad,ms);
return dFI(hpP, rdP, rgP, encryption, level, index).toFixed(4);
default:
return -1;
}
}
const rarities = ["common", "uncommon", "rare", "epic", "legendary", "mythic", "ethereal"];
const itemHoverObserver = new MutationObserver(function(mutations) {
const description = mutations.find(e => {
return e.addedNodes.length == 1 && e.addedNodes[0].id == "desc"
&& e.addedNodes[0].classList?.contains("svelte-181npts")
})?.addedNodes[0]
if (!description)
return;
const type = (description.querySelector("img")?.src?.match(/[^\/]+\.webp/) || [])[0]?.slice(0, -5);
const rarity = description.querySelector(".rarity")?.innerText;
const level = (description.querySelector(".level")?.innerText.match(/\d+/) || [])[0];
const effects = {};
Array.from(description.querySelectorAll(".effect")).forEach(effect => {
effect.style.width = "100%";
const name = effect.querySelector("div > div")?.innerText.split(" ")[1].trim();
const value = effect.querySelector("div > span > span")?.innerText;
effects[name] = Number(value);
});
if (!type || !level || effects.length == 0)
return;
const index = rarities.indexOf(rarity.toLowerCase());
const grade = getItemGrade(type, level, index, effects);
if (grade == -1)
return
const unitiesByType = {
"cpu": "dCI",
"gpu": "dGI",
"psu": "dPI",
"router": "dFI",
}
const gradeComponent = new Component("div", {
id: "grade",
classList: ["attribute", "svelte-181npts"],
innerText: `${grade} / 10 ${unitiesByType[type]}`,
style: { paddingBlock: "4px", paddingInline: "9px", borderRadius: "2px", backgroundColor: "black" }
})
description.querySelector(".level")?.parentNode.insertBefore(gradeComponent.element, description.querySelector(".effect"));
description.style.width = "300px";
const price = dPS(grade,level,index,type)
description.querySelector(".level")?.parentNode.insertBefore(gradeComponent.element, description.querySelector(".effect"));
description.style.width = "300px";
var priceStandard = new Component("div", {
id: "price",
classList: ["attribute", "svelte-181npts"],
innerHTML: `<img class="icon icon-in-text" src="icons/btc.svg" alt="Bitcoin Icon">${price}`,
style: { paddingBlock: "4px", paddingInline: "9px", borderRadius: "2px", background: "linear-gradient(112deg, #edca3d 4%, #ffdf81 34%, #edca3d 66%, #ffdf81 100%)" }
})
description.querySelector(".level")?.parentNode.insertBefore(priceStandard.element, description.querySelector(".effect"));
description.style.width = "300px";
});
let manageLoot = async () => {
let item = document.querySelector(".window-loot > div > div > div > div > div > .item")
if (item) {
let background = item.style.background
let rarity = raritiesVariables[background];
if (!rarity) rarity = raritiesVariables[background + ")"];
let color = getComputedStyle(item).getPropertyValue(background.toString().slice(4, background.endsWith(")") ? -1 : background.length))
if (rarity){
await sleep(200);
if (player.autoloot[rarity] === "nothing")
return;
if (player.autoloot[rarity] === "take")
await openWindow("Inventory", true);
const button = document.querySelector(lootButtons[player.autoloot[rarity]])
button?.click();
sendLog(`
<img class="icon" src="icons/check.svg"/>
Successfully ${player.autoloot[rarity]} a
<span style='background: ${color}; border-radius: 5px; padding: 2px 5px 2px 5px;'>${rarity}</span>
item
`);
await sleep(100);
closeWindow("Inventory", true);
await sleep(500);
}
}
}
const windowOpenObserver = new MutationObserver(async function(mutations) {
const newWindow = mutations.find(e => {
return e.target == document.querySelector("main") &&
e.addedNodes.length == 1 &&
e.addedNodes[0]?.classList?.contains("window", "svelte-1hjm43z")
})
if (!newWindow)
return;
const src = newWindow.addedNodes[0].querySelector(".window-title > img").src
const name = src.split("/")[src.split("/").length - 1].slice(0, -4);
if (player.configuration.openInSilent.includes(name)) {
newWindow.addedNodes[0].style.display = "none";
newWindow.addedNodes[0].classList.add("openInSilent");
}
const isItem = newWindow.addedNodes[0].querySelector(".window-title > img[src='icons/loot.svg']")
if (isItem)
await manageLoot();
const isFilamentWindow = newWindow.addedNodes[0].querySelector(".window-title > img[src='icons/filament.svg']")?.parentNode?.parentNode;
if (isFilamentWindow) {
const upgrader = isFilamentWindow.querySelectorAll("h3")[1];
if (!upgrader)