-
Notifications
You must be signed in to change notification settings - Fork 0
/
KrunkFarmClient.js
1840 lines (1750 loc) · 98.5 KB
/
KrunkFarmClient.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 Krunker Aimbot and ESP: KrunkFarm Client V1 - Wireframe & More
// @description Fed up of dysfunctional scripts with 5 minutes of ads and trackers?
// @author onlypuppy7, StateFarm Network
// @namespace http://github.com/onlypuppy7/KrunkFarmClient/
// @supportURL http://github.com/onlypuppy7/KrunkFarmClient/issues/
// @license GPL-3.0
// @run-at document-start
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_listValues
// @grant GM_info
// @grant GM_setClipboard
// @grant GM_openInTab
// @icon https://raw.githubusercontent.com/onlypuppy7/KrunkFarmClient/main/krunkfarm-icon-384px.png
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/tweakpane.min.js
// @require https://unpkg.com/[email protected]/build/three.min.js
// version naming:
//1.#.#-pre[number] for development versions, increment for every commit (not full release) note: please increment it
//1.#.#-release for release (in the unlikely event that happens)
// this ensures that each version of the script is counted as different
// @version 1.0.0
// @match *://krunker.io/*
// @match *://browserfps.com/*
// @downloadURL https://update.greasyfork.org/scripts/482982/StateFarm%20Client%20V3%20-%20Combat%2C%20Bloom%2C%20ESP%2C%20Rendering%2C%20Chat%2C%20Automation%2C%20Botting%2C%20Unbanning%20and%20more.user.js
// @updateURL https://update.greasyfork.org/scripts/482982/StateFarm%20Client%20V3%20-%20Combat%2C%20Bloom%2C%20ESP%2C%20Rendering%2C%20Chat%2C%20Automation%2C%20Botting%2C%20Unbanning%20and%20more.meta.js
// ==/UserScript==
// {{CRACKEDSHELL}}
// require:"https://cdn.jsdelivr.net/npm/[email protected]/dist/tweakpane.min.js"
// require:"https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"
// require:"https://cdnjs.cloudflare.com/ajax/libs/jszip/3.7.1/jszip.min.js"
// {{!CRACKEDSHELL}}
let attemptedInjection = false;
console.log("StateFarm: running (before function)");
(function () {
console.log("KrunkFarm: running (after function)");
//script info
const name = "KrunkFarm Client";
const version = typeof (GM_info) !== 'undefined' ? GM_info.script.version : "3";
const menuTitle = name + " v" + version;
//INIT WEBSITE LINKS: store them here so they are easy to maintain and update!
const discordURL = "https://dsc.gg/sfnetwork";
const githubURL = "https://github.com/onlypuppy7/KrunkFarmClient";
const featuresGuideURL = "https://github.com/onlypuppy7/KrunkFarmClient/tree/main?tab=readme-ov-file#-features";
const violentmonkeyURL = "https://violentmonkey.github.io/get-it/";
const sfChatURL = "https://raw.githack.com/OakSwingZZZ/StateFarmChatFiles/main/index.html";
//startup sequence
const startUp = function () {
F.log("StateFarm: mainLoop()");
mainLoop();
document.addEventListener("DOMContentLoaded", function () {
onContentLoaded();
F.log("StateFarm: DOMContentLoaded, ran onContentLoaded");
});
};
//INIT VARS
let ss = {}; //game vars
let L = {}; //libraries
L.THREE = THREE;
delete unsafeWindow.THREE; //hide from global scope, idk if it even was but eh
const tp = {}; // <-- tp = tweakpane
const F = { //stuff that gets deleted for some reason
log: console.log,
window: window,
push: Array.prototype.push,
requestAnimationFrame: window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) { return setTimeout(callback, 1000 / 60); },
mod: (e,t) => {var i=e%t;return i>=0?i:i+t},
};
const inbuiltPresets = {
};
const presetStorageLocation = "KrunkFarmUserPresets";
let hudElementPositions = {};
let sfChatIframe;
let sfChatContainer;
let sfChatUsername;
let presetIgnore = ['sfChatUsername', 'otherSettingYouMightWantNotToBeExported'];
const storageKey = "KrunkFarm_" + (unsafeWindow.document.location.host.replaceAll(".", "")) + "_";
F.log("Save key:", storageKey);
let binding = false;
let targetingComplete = false;
const allModules = [];
const allFolders = [];
const isKeyToggled = {};
let ESPArray = [];
let bindsArray = {};
// blank variables
let msgElement, menuInitiated, resetModules, startUpComplete, coordElement, playerstatsElement, crosshairsPosition;
let scrambledMsgEl, newGame, playerLookingAt, ranEverySecond, currentlyTargeting, ranOneTime, configMain;
let isLeftButtonDown = false;
let isRightButtonDown = false;
const monitorObjects = {};
const getScrambled = () => Array.from({ length: 10 }, () => String.fromCharCode(97 + Math.floor(Math.random() * 26))).join('');
//menu interaction functions
//menu extraction
const extract = function (variable, shouldUpdate) {
if (shouldUpdate) { updateConfig() };
return configMain[variable];
};
const extractDropdownList = function (variable) {
return tp[variable + "Button"].controller_.binding.value.constraint_.constraints[0].options;
};
const extractAsDropdownInt = function (variable) {
const options = extractDropdownList(variable);
const state = extract(variable);
for (let i = 0; i < options.length; i++) {
if (options[i].value === state) {
return i;
};
};
};
const beginBinding = function (value) {
if (binding == false) {
binding = value;
tp[binding + "BindButton"].title = "PRESS KEY";
};
};
//one day i should make this unshit. dom is not the correct way to go about this.
//unfortunately tweakpane is a pain in the ass and has barely anything for actually extracting/changing vars
//a way it could be done is export preset => change value => import preset
//but doesnt account for it being a button... and dropdowns wouldnt switch properly too. laziness. the problem is that this works fine.
//suppose i could always just log the type of module and refer to it later. you can also get the parent object from the tp object, that would save iterating over everything.
const change = function (module, newValue) { //its important to note that every module must have a unique name (the title of the module, NOT the storeAs)
const labels = document.querySelectorAll('.tp-lblv_l');
const moduleButton = module + "Button";
const moduleLabel = tp[moduleButton].label;
for (const label of labels) {
if (label.textContent.includes(moduleLabel)) {
const inputContainer = label.nextElementSibling;
const currentValue = extract(module);
// check for checkbox
const checkbox = inputContainer.querySelector('.tp-ckbv_i');
if (checkbox) {
if (newValue == undefined) {
newValue = (!currentValue);
};
if (newValue !== (!!currentValue)) {
checkbox.click(); // Toggle checkbox
};
F.log(module, "checkbox", currentValue, newValue);
return extract(module, true);
};
// check for button
const button = inputContainer.querySelector('.tp-btnv_b');
if (button) {
button.click(); // Trigger button click
F.log(module, "button", currentValue, newValue);
return ("NOMSG"); //no change of state, dont show pop up message
};
// check for dropdown
const dropdown = inputContainer.querySelector('.tp-lstv_s');
if (dropdown) {
if (newValue == undefined) { //if youre going to set a list to a certain value, use the int value of the list item
newValue = (dropdown.selectedIndex + 1) % dropdown.options.length;
};
dropdown.selectedIndex = newValue;
dropdown.dispatchEvent(new Event('change')); // trigger change event for dropdown
F.log(module, "dropdown", currentValue, newValue);
return extract(module, true);
};
// check for text input
const textInput = inputContainer.querySelector('.tp-txtv_i');
if (textInput) {
textInput.value = newValue;
textInput.dispatchEvent(new Event('change')); // trigger change event for dropdown
return extract(module, true);
};
};
};
};
document.addEventListener('pointerdown', function (event) {
F.log(isRightButtonDown, event.button, event);
if (event.button === 2) {
isRightButtonDown = true; F.log(1);
} else if (event.button === 0) {
isLeftButtonDown = true;
};
});
document.addEventListener('pointerup', function (event) {
F.log(event.button, event);
if (isRightButtonDown, event.button === 2) {
isRightButtonDown = false; F.log(2);
} else if (event.button === 0) {
isLeftButtonDown = false;
};
});
//menu
document.addEventListener("keydown", function (event) {
event = (event.code.replace("Key", ""));
isKeyToggled[event] = true;
if (event == "Escape") { noPointerPause = false; unsafeWindow.document.onpointerlockchange() };
});
document.addEventListener("keyup", function (event) {
event = (event.code.replace("Key", ""));
isKeyToggled[event] = false;
if (document.activeElement && document.activeElement.tagName === 'INPUT') {
return;
} else if (binding != false) {
if (event == "Delete") { event = "Set Bind" };
tp[binding + "BindButton"].title = event;
bindsArray[binding] = event;
save(binding + "Bind", event);
createPopup("Binded " + tp[binding + "Button"].label + " to key: " + event);
binding = false;
} else {
Object.keys(bindsArray).forEach(function (module) {
if ((bindsArray[module] == event) && module != "zoom") {
let state = change(module)
let popupText = state
if (state != "NOMSG") {
if (state === true || state === false || state === undefined) { state = (state ? "ON" : "OFF") };
popupText = "Set " + module + " to: " + state;
if (extract("announcer")) {
sendChatMessage("I just set " + module + " to " + state + "!");
};
} else {
switch (module) {
case ("hide"):
popupText = "Toggled StateFarm Panel"; break;
case ("sfChatShowHide"):
popupText = "Toggled SFC Chat"; break;
case ("panic"):
popupText = "Exiting to set URL..."; break;
};
};
createPopup(popupText);
};
});
};
});
const initTabs = function (tab, guideData) {
tp[tab.storeAs] = tab.location.addTab({
pages: [
{ title: 'Modules' },
{ title: 'Binds' },
{ title: 'Guide' },
],
});
if (guideData) {
const thePages = [];
guideData.forEach(aPage => {
thePages.push({ title: aPage.title });
});
tp[tab.storeAs + "Guide"] = tp[tab.storeAs].pages[2].addTab({ pages: thePages }); //is there a one liner for this? uhhh probabyl
//tp[tab.storeAs + "Guide"] = tab.location.addTab({ thePages: guideData.map(page => ({ title: page.title })) });
for (let i = 0; i < guideData.length; i++) {
const storeAs = tab.storeAs + "Guide" + i;
const text = (guideData[i].content || "Not set up correctly lmao");
initModule({ location: tp[tab.storeAs + "Guide"].pages[i], storeAs: storeAs, monitor: (text.split('\n').length + 0.25), });
monitorObjects[storeAs] = text;
const infoElement = tp[storeAs + "Button"].controller_.view.element.children[1].children[0];
infoElement.style.width = "270px";
infoElement.style.setProperty("margin-left", "-110px", "important");
};
};
};
const initFolder = function (folder) {
tp[folder.storeAs] = folder.location.addFolder({
title: folder.title,
expanded: load(folder.storeAs) !== null ? load(folder.storeAs) : false
});
allFolders.push(folder.storeAs);
};
const initModule = function (module) {
if (module.requirements) {
};
const value = {};
value[module.storeAs] = (module.defaultValue !== undefined ? module.defaultValue : false);
tp[module.storeAs + "TiedModules"] = {
showConditions: (module.showConditions || false),
hideConditions: (module.hideConditions || false),
enableConditions: (module.enableConditions || false),
disableConditions: (module.disableConditions || false), //why have disable when there is already enable? enable acts like an AND operator, whereas having conditions for the opposite allows for an OR operation. it is messy, but hey it works lmao?
};
if (!(module.slider && module.slider.step)) { module.slider = {} };
const config = {
label: module.title,
options: module.dropdown,
min: module.slider.min,
max: module.slider.max,
step: module.slider.step,
title: module.button,
};
if (module.button) {
tp[(module.storeAs + "Button")] = module.location.addButton({
label: module.title,
title: module.button,
}).on("click", (value) => {
if (module.clickFunction !== undefined) { module.clickFunction(value) };
});
} else if (module.monitor) {
monitorObjects[module.storeAs] = "Text Goes Here";
tp[(module.storeAs + "Button")] = module.location.addMonitor(monitorObjects, module.storeAs, {
label: '',
expanded: true,
multiline: true,
lineCount: module.monitor,
});
setInterval(() => {
tp[(module.storeAs + "Button")].refresh();
}, 1000);
} else {
tp[module.storeAs + "Button"] = module.location.addInput(value, module.storeAs, config
).on("change", (value) => {
if (module.changeFunction !== undefined) { module.changeFunction(value) };
setTimeout(() => {
if (startUpComplete) {
};
updateHiddenAndDisabled();
saveConfig();
}, 150);
});
};
allModules.push(module.storeAs);
if (module.bindLocation) { initBind(module) };
};
const initBind = function (module) {
if (resetModules) { remove(module.storeAs + "Bind") };
const theBind = (load(module.storeAs + "Bind") || module.defaultBind || "Set Bind");
tp[(module.storeAs + "BindButton")] = module.bindLocation.addButton({
label: module.title,
title: theBind,
}).on("click", (value) => {
beginBinding(module.storeAs);
});
bindsArray[module.storeAs] = theBind;
};
const initMenu = function (reset) {
//INIT MENU
//init tp.mainPanel
resetModules = reset;
menuInitiated = false;
if (tp.mainPanel) { tp.mainPanel.dispose() };
tp.mainPanel = new Tweakpane.Pane(); // eslint-disable-line
tp.mainPanel.title = menuTitle;
//SFC CHAT
initFolder({ location: tp.mainPanel, title: "StateFarm Chat", storeAs: "sfChatFolder", });
initTabs({ location: tp.sfChatFolder, storeAs: "sfChatTab" }, [
{
title: "WIP", content:
`Sorry! No guide yet!`},
]);
initModule({ location: tp.sfChatTab.pages[0], title: "Username", storeAs: "sfChatUsername", defaultValue: ("Guest" + (Math.floor(Math.random() * 8999) + 1000)), });
tp.sfChatTab.pages[0].addSeparator();
initModule({
location: tp.sfChatTab.pages[0], title: "Show/Hide", storeAs: "sfChatShowHide", button: "Show/Hide", bindLocation: tp.sfChatTab.pages[1], defaultBind: "K", clickFunction: function () {
if (sfChatContainer != undefined) {
if (sfChatContainer.style.display == "none") {
sfChatContainer.style.display = "block";
} else {
sfChatContainer.style.display = "none";
};
} else {
startStateFarmChat(); //its just easier this way imo
};
},
});
tp.sfChatTab.pages[0].addSeparator();
initModule({ location: tp.sfChatTab.pages[0], title: "Notifications", storeAs: "sfChatNotifications", bindLocation: tp.sfChatTab.pages[1], });
initModule({ location: tp.sfChatTab.pages[0], title: "Auto Start Chat", storeAs: "sfChatAutoStart", bindLocation: tp.sfChatTab.pages[1], });
//COMBAT MODULES
initFolder({ location: tp.mainPanel, title: "Combat", storeAs: "combatFolder", });
initTabs({ location: tp.combatFolder, storeAs: "combatTab" }, [
{
title: "WIP", content:
`Sorry! No guide yet!`},
]);
initModule({ location: tp.combatTab.pages[0], title: "Aimbot", storeAs: "aimbot", bindLocation: tp.combatTab.pages[1], defaultBind: "V", });
initFolder({ location: tp.combatTab.pages[0], title: "Aimbot Options", storeAs: "aimbotFolder", });
initModule({ location: tp.aimbotFolder, title: "TargetMode", storeAs: "aimbotTargetMode", bindLocation: tp.combatTab.pages[1], defaultBind: "T", dropdown: [{ text: "Pointing At", value: "pointingat" }, { text: "Nearest", value: "nearest" }], defaultValue: "pointingat", enableConditions: [["aimbot", true]], });
tp.aimbotFolder.addSeparator();
initModule({ location: tp.aimbotFolder, title: "ToggleRM", storeAs: "aimbotRightClick", bindLocation: tp.combatTab.pages[1], enableConditions: [["aimbot", true]], });
tp.aimbotFolder.addSeparator();
initModule({ location: tp.aimbotFolder, title: "AntiSwitch", storeAs: "antiSwitch", bindLocation: tp.combatTab.pages[1], enableConditions: [["aimbot", true]], });
initModule({ location: tp.aimbotFolder, title: "1 Kill", storeAs: "oneKill", bindLocation: tp.combatTab.pages[1], enableConditions: [["aimbot", true]], });
tp.aimbotFolder.addSeparator();
initModule({ location: tp.aimbotFolder, title: "MinAngle", storeAs: "aimbotMinAngle", slider: { min: 0.05, max: 360, step: 1 }, defaultValue: 360, enableConditions: [["aimbot", true]], });
initModule({ location: tp.aimbotFolder, title: "AntiSnap", storeAs: "aimbotAntiSnap", slider: { min: 0, max: 0.99, step: 0.01 }, defaultValue: 0, enableConditions: [["aimbot", true]], });
tp.aimbotFolder.addSeparator();
initModule({ location: tp.aimbotFolder, title: "ESPColor", storeAs: "aimbotColor", defaultValue: "#0000ff", enableConditions: [["aimbot", true]] });
//RENDER MODULES
initFolder({ location: tp.mainPanel, title: "Render", storeAs: "renderFolder", });
initTabs({ location: tp.renderFolder, storeAs: "renderTab" }, [
{
title: "WIP", content:
`Sorry! No guide yet!`},
]);
initModule({ location: tp.renderTab.pages[0], title: "PlayerESP", storeAs: "playerESP", bindLocation: tp.renderTab.pages[1], });
initModule({ location: tp.renderTab.pages[0], title: "Tracers", storeAs: "tracers", bindLocation: tp.renderTab.pages[1], });
tp.renderTab.pages[0].addSeparator();
initFolder({ location: tp.renderTab.pages[0], title: "Player ESP/Tracers Options", storeAs: "tracersFolder", });
initModule({ location: tp.tracersFolder, title: "Type", storeAs: "tracersType", bindLocation: tp.renderTab.pages[1], dropdown: [{ text: "Static", value: "static" }, { text: "Proximity", value: "proximity" }], defaultValue: "static", disableConditions: [["tracers", false], ["playerESP", false]], });
initModule({ location: tp.tracersFolder, title: "Color 1", storeAs: "tracersColor1", defaultValue: "#ff0000", disableConditions: [["tracers", false], ["playerESP", false]], });
initModule({ location: tp.tracersFolder, title: "Color 2", storeAs: "tracersColor2", defaultValue: "#00ff00", disableConditions: [["tracers", false], ["playerESP", false]], hideConditions: [["tracersType", "static"]], });
initModule({ location: tp.tracersFolder, title: "Color 3", storeAs: "tracersColor3", defaultValue: "#ffffff", disableConditions: [["tracers", false], ["playerESP", false]], showConditions: [["tracersType", "proximity"]], });
initModule({ location: tp.tracersFolder, title: "Dist 1->2", storeAs: "tracersColor1to2", slider: { min: 0, max: 30, step: 0.25 }, defaultValue: 5, showConditions: [["tracersType", "proximity"]], disableConditions: [["tracers", false], ["playerESP", false]], });
initModule({ location: tp.tracersFolder, title: "Dist 2->3", storeAs: "tracersColor2to3", slider: { min: 0, max: 30, step: 0.25 }, defaultValue: 15, showConditions: [["tracersType", "proximity"]], disableConditions: [["tracers", false], ["playerESP", false]], });
tp.renderTab.pages[0].addSeparator();
initModule({ location: tp.renderTab.pages[0], title: "Wireframe", storeAs: "wireframe", bindLocation: tp.renderTab.pages[1], });
//HUD MODULES
initFolder({ location: tp.mainPanel, title: "HUD", storeAs: "hudFolder", });
initTabs({ location: tp.hudFolder, storeAs: "hudTab" }, [
{
title: "WIP", content:
`Sorry! No guide yet!`},
]);
initModule({ location: tp.hudTab.pages[0], title: "Co-ords", storeAs: "showCoordinates", bindLocation: tp.hudTab.pages[1], });
initModule({ location: tp.hudTab.pages[0], title: "HP Display", storeAs: "playerStats", bindLocation: tp.hudTab.pages[1], });
// initModule({ location: tp.hudTab.pages[0], title: "PlayerInfo", storeAs: "playerInfo", bindLocation: tp.hudTab.pages[1], });
// initModule({ location: tp.hudTab.pages[0], title: "GameInfo", storeAs: "gameInfo", bindLocation: tp.hudTab.pages[1], });
//THEMING MODULES
initFolder({ location: tp.mainPanel, title: "Theming", storeAs: "themingFolder", });
initTabs({ location: tp.themingFolder, storeAs: "themingTab" }, [
{
title: "WIP", content:
`Sorry! No guide yet!`},
]);
initModule({ location: tp.themingTab.pages[0], title: "Client Theme", storeAs: "themeType", bindLocation: tp.themingTab.pages[1], dropdown: [
{text: "Default", value: "defaultTheme"},
{text: "Iceberg", value: "icebergTheme"},
{text: "Jet Black", value: "jetblackTheme"},
{text: "Light", value: "lightTheme"},
{text: "Retro", value: "retroTheme"},
{text: "Translucent", value: "translucentTheme"},
{text: "StateFarmer", value: "statefarmerTheme"},
{text: "Blurple", value: "blurpleTheme"},
{text: "ShellFarm", value: "shellFarmTheme"},
], defaultValue: "defaultTheme", changeFunction: function(value) {
applyTheme(value.value);
}});
//MISC MODULES
initFolder({ location: tp.mainPanel, title: "Misc", storeAs: "miscFolder", });
initTabs({ location: tp.miscFolder, storeAs: "miscTab" }, [
{
title: "WIP", content:
`Sorry! No guide yet!`},
]);
initModule({ location: tp.miscTab.pages[0], title: "Custom Macro", storeAs: "customMacro", defaultValue: "F.log('cool');" });
initModule({ location: tp.miscTab.pages[0], title: "Execute Macro", storeAs: "executeMacro", bindLocation: tp.miscTab.pages[1], button: "EXECUTE", clickFunction: function(){
//use at your own risk, i guess. but is this really any more dangerous than pasting something into console? not really.
(async () => {
try {
F.log(extract("customMacro"));
// stay safe out there. this runs in the **userscript** environment. make sure to use unsafeWindow for whatever reason you may need the window object.
await eval(extract("customMacro")); // eslint-disable-line
} catch (error) {
console.error("Error executing code:", error);
}
})();
},}); //but yes, as you can see "macros" are just scripts you can execute for whatever purposes you need. reminds me of userscripts...
initModule({ location: tp.miscTab.pages[0], title: "Do At Startup", storeAs: "autoMacro", bindLocation: tp.miscTab.pages[1],});
tp.miscTab.pages[0].addSeparator();
initFolder({ location: tp.miscTab.pages[0], title: "Seizure Options", storeAs: "seizureFolder", });
initModule({ location: tp.seizureFolder, title: "SeizureX", storeAs: "enableSeizureX", bindLocation: tp.miscTab.pages[1], });
initModule({ location: tp.seizureFolder, title: "X Amount", storeAs: "amountSeizureX", slider: { min: -6.283185307179586, max: 6.283185307179586, step: Math.PI / 280 }, defaultValue: 2, });
initModule({ location: tp.seizureFolder, title: "SeizureY", storeAs: "enableSeizureY", bindLocation: tp.miscTab.pages[1], });
initModule({ location: tp.seizureFolder, title: "Y Amount", storeAs: "amountSeizureY", slider: { min: -6.283185307179586, max: 6.283185307179586, step: Math.PI / 280 }, defaultValue: 2, });
//CLIENT MODULES
initFolder({ location: tp.mainPanel, title: "Client & About", storeAs: "clientFolder", });
initTabs({ location: tp.clientFolder, storeAs: "clientTab" }, [
{
title: "WIP", content:
`Sorry! No guide yet!`},
]);
initModule({ location: tp.clientTab.pages[0], title: "Hide GUI", storeAs: "hide", bindLocation: tp.clientTab.pages[1], button: "Hide!", clickFunction: function () { tp.mainPanel.hidden = !tp.mainPanel.hidden }, defaultBind: "H", });
initModule({ location: tp.clientTab.pages[0], title: "Hide at Startup", storeAs: "hideAtStartup", bindLocation: tp.clientTab.pages[1], defaultValue: false,});
initModule({ location: tp.clientTab.pages[0], title: "Pop-ups", storeAs: "popups", bindLocation: tp.clientTab.pages[1], defaultValue: true, });
tp.clientTab.pages[0].addSeparator();
initModule({ location: tp.clientTab.pages[0], title: "Panic", storeAs: "panic", bindLocation: tp.clientTab.pages[1], button: "EXIT!", clickFunction: function () { if (extract("enablePanic")) { unsafeWindow.location.replace(extract("panicURL")) } }, defaultBind: "X", enableConditions: [["enablePanic", true]], });
initFolder({ location: tp.clientTab.pages[0], title: "Panic Options", storeAs: "panicFolder", });
initModule({ location: tp.panicFolder, title: "Enable", storeAs: "enablePanic", bindLocation: tp.clientTab.pages[1], defaultValue: true, });
initModule({ location: tp.panicFolder, title: "Set URL", storeAs: "panicURL", defaultValue: "https://classroom.google.com/", enableConditions: [["enablePanic", true]], });
tp.clientTab.pages[0].addSeparator();
let presetList = [];
Object.entries(inbuiltPresets).forEach(([key, value]) => {//Get all presets from inbuilt presets var
let options = {};
options.text = key;//not the best way to add things to a dictionary, but the only way i could get to work
options.value = key; // idiot could've not violated eslint smfh
presetList.push(options);
});
//PRESETS: OakSwingZZZ 😎
initFolder({ location: tp.clientTab.pages[0], title: "Presets", storeAs: "presetFolder",});
initModule({ location: tp.presetFolder, title: "Preset List", storeAs: "selectedPreset", defaultValue: "onlypuppy7's Config", bindLocation: tp.clientTab.pages[1], dropdown: presetList, });
initModule({ location: tp.presetFolder, title: "Apply", storeAs: "applyPreset", button: "Apply Preset", clickFunction: function () {
const userConfirmed = confirm( "Are you sure you want to continue? This will replace most of your current config." );
if (userConfirmed) { applySettings(inbuiltPresets[extract("selectedPreset")], true); };
},
});
tp.presetFolder.addSeparator();
initModule({ location: tp.presetFolder, title: "Save", storeAs: "savePreset", button: "Save As Preset", clickFunction: function () {
// F.log("Config Main: ", configMain);
let saveString = '';
const addParam = function(module,setTo) {saveString=saveString+module+">"+JSON.stringify(setTo)+"<"};
Object.entries(configMain).forEach(([key, value]) => {
F.log(key, value);
if (typeof(value) == 'string') {
try {
let dropdown = extractAsDropdownInt(key)
value = dropdown;
} catch (error) {
//dont care lmaoooo
};
};
if (!presetIgnore.includes(key)){
addParam(key, value);
}
});
saveString = saveString.substring(0, saveString.length - 1);
let presetName = prompt("Name of preset:"); // asks user for name of preset
if (presetName == "" || presetName == null) {
F.log("User cancelled save");
} else {
let result = saveUserPreset(presetName, saveString);//saves user preset
addUserPresets(loadUserPresets()); //updates inbuiltPresets to include
F.log("Saved Preset: ", saveString);
F.log("User Preset Result: ", result);
};
F.log("InbuiltPrests:");
F.log(inbuiltPresets);
initMenu(false); //Reloads menu to add to dropdown list
},});
initModule({ location: tp.presetFolder, title: "Delete", storeAs: "deletePreset", button: "Remove Preset", clickFunction: function () { // Function won't do anything if they select a preset that was loaded in the gamecode
let currUserPresets = loadUserPresets(); //gets current presets from storage
delete currUserPresets[extract("selectedPreset")];//deletes
delete inbuiltPresets[extract("selectedPreset")];//deletes
save(presetStorageLocation, currUserPresets); // saves cnages to file.
F.log("Current User Presets: ",currUserPresets);
initMenu(false); //reloads menu
},});
tp.presetFolder.addSeparator();
initModule({ location: tp.presetFolder, title: "Import", storeAs: "importPreset", button: "Import Preset", clickFunction: function () {
let preset = prompt("Paste preset here:"); // asks user to paste preset
if (preset == "" || preset == null) {
F.log("User cancelled save");
} else {
const pattern = /([a-zA-Z]*>[^<]*<)+[a-zA-Z]*>[^<]*/;
if (pattern.test(preset)){
let presetName = prompt("Name of preset:"); // asks user for name of preset
if (presetName == "" || presetName == null) {
F.log("User cancelled save");
} else {
let result = saveUserPreset(presetName, preset);//saves user preset
addUserPresets(loadUserPresets()); //updates inbuiltPresets to include
F.log("Saved Preset: ", preset);
F.log("User Preset Result: ", result);
}
} else {
alert("Not A Valid Preset!");
F.log("Preset Not Valid");
};
initMenu(false);
};
},});
initModule({ location: tp.presetFolder, title: "Export", storeAs: "exportPreset", button: "Copy To Clipboard", clickFunction: function () {
let saveString = '';
const addParam = function(module,setTo) {saveString=saveString+module+">"+JSON.stringify(setTo)+"<"};
Object.entries(configMain).forEach(([key, value]) => {
F.log(key, value);
if (typeof(value) == 'string') {
try {
let dropdown = extractAsDropdownInt(key)
value = dropdown;
} catch (error) {
//dont care lmaoooo
};
};
if (!presetIgnore.includes(key)){
addParam(key, value);
}
});
saveString = saveString.substring(0, saveString.length - 1);
GM_setClipboard(saveString, "text", () => F.log("Clipboard set!"));
createPopup("Preset copied to clipboard...");
},});
tp.clientTab.pages[0].addSeparator();
initFolder({ location: tp.clientTab.pages[0], title: "Creator's Links", storeAs: "linksFolder",});
initModule({ location: tp.linksFolder, title: "Discord", storeAs: "discord", button: "Link", clickFunction: () => GM_openInTab(discordURL, { active: true }) });
initModule({ location: tp.linksFolder, title: "GitHub", storeAs: "github", button: "Link", clickFunction: () => GM_openInTab(githubURL, { active: true }) });
tp.clientTab.pages[0].addSeparator();
initModule({ location: tp.clientTab.pages[0], title: "Reset", storeAs: "clear", button: "DELETE", clickFunction: function(){
const userConfirmed=confirm("Are you sure you want to continue? This will clear all stored module states and keybinds.");
if (userConfirmed) {
initMenu(true);
alert("Reset to defaults.");
};
},});
initModule({ location: tp.clientTab.pages[0], title: "Debug", storeAs: "debug", bindLocation: tp.clientTab.pages[1], });
tp.mainPanel.addSeparator();
initModule({ location: tp.mainPanel, title: "Guide", storeAs: "documentation", button: "Link", clickFunction: () => GM_openInTab(featuresGuideURL, { active: true }) });
if (!load("KrunkFarmConfigMainPanel") || reset) {
saveConfig();
} else {
F.log("##############################################")
tp.mainPanel.importPreset(load("KrunkFarmConfigMainPanel"));
};
updateConfig();
menuInitiated = true;
makeDraggable(tp.mainPanel.containerElem_);
};
const onContentLoaded = function () {
F.log("StateFarm: initMenu()");
initMenu();
F.log("StateFarm: applyStylesAddElements()");
applyStylesAddElements(); //set font and change menu cass, and other stuff to do with the page
const intervalId1 = setInterval(everySecond, 1000);
const intervalId2 = setInterval(everyDecisecond, 100);
};
//visual functions
const createPopup = function (text, type) {
F.log("Creating Popup Type:", type, "With Text:", text);
try {
if (extract("popups")) {
const messageContainer = document.getElementById('message-container');
const messages = messageContainer.getElementsByClassName(scrambledMsgEl);
if (messages.length > 5) {
messageContainer.removeChild(messages[0]);
};
const clonedMsgElement = msgElement.cloneNode(true);
clonedMsgElement.innerText = text;
switch (type) {
case ("success"):
clonedMsgElement.style.border = '2px solid rgba(0, 255, 0, 0.5)'; break;
case ("error"):
clonedMsgElement.style.border = '2px solid rgba(255, 0, 0, 0.5)'; break;
};
clonedMsgElement.style.display = 'none';
const messageOffset = (messages.length + 1) * 50;
clonedMsgElement.style.bottom = messageOffset + "px";
void clonedMsgElement.offsetWidth;
clonedMsgElement.style.display = '';
messageContainer.appendChild(clonedMsgElement);
//reorder such that newest is lowest
for (let i = messages.length - 1; i >= 0; i--) {
messages[i].style.bottom = (((messages.length - i) * 50) - 40) + "px";
};
};
} catch (error) {
// Handle the error and display an error message onscreen
console.error("An error occurred:", error);
alert("Bollocks! If you're getting this message, injection probably failed. To solve this, perform CTRL+F5 - this performs a hard reload. If this does not work, contact the developers.");
};
};
//StateFarmChat functions
const sfChatUsernameSet = function () {
let tagAdded = `[Krunker] ${extract("sfChatUsername")}`;
if (sfChatUsername != tagAdded && sfChatIframe != undefined) {
sfChatUsername = tagAdded; F.log(sfChatUsername);
sfChatIframe.contentWindow.postMessage("SFCHAT-UPDATE" + JSON.stringify({ name: sfChatUsername }), "*");
};
};
const startStateFarmChat = function (startHidden) {
//UnsafewindowVars
const makeChatDragable = function (element) {
if (element.getAttribute("drag-true") != "true") {
element.addEventListener("mousedown", function (e) {
let offsetX = e.clientX - parseInt(window.getComputedStyle(this).left);
let offsetY = e.clientY - parseInt(window.getComputedStyle(this).top);
function mouseMoveHandler(e) {
let newX = e.clientX - offsetX;
let newY = e.clientY - offsetY;
if (newX >= 0 && newX + element.getBoundingClientRect().width <= window.innerWidth) {
element.style.left = newX + "px";
}
if (newY >= 0 && newY + element.getBoundingClientRect().height <= window.innerHeight) {
element.style.top = newY + "px";
}
}
function reset() {
window.removeEventListener("mousemove", mouseMoveHandler);
window.removeEventListener("mouseup", reset);
}
window.addEventListener("mousemove", mouseMoveHandler);
window.addEventListener("mouseup", reset);
});
element.setAttribute("drag-true", "true");
};
};
sfChatContainer = document.createElement("div");
sfChatContainer.style.padding = "1px";
let title = document.createElement("p");
title.style.fontSize = "medium";
title.style.color = "#D6D6D6";
title.innerHTML = "StateFarm Chat";
sfChatContainer.appendChild(title);
sfChatContainer.style.backgroundColor = "#555";
sfChatContainer.style.position = "absolute";
sfChatContainer.style.borderRadius = "10px";
sfChatContainer.style.textAlign = "center";
sfChatContainer.style.top = "20px";
sfChatContainer.style.left = "20px";
sfChatContainer.style.zIndex = 100000000;
if (startHidden){
sfChatContainer.style.display = 'none';
}
const sendSettings = function () {
let settings = GM_getValue("SFCHAT-SETTINGS");
if (settings) {
sfChatIframe.contentWindow.postMessage("SFCHAT-SETTINGS" + settings, "*");
} else {
sfChatIframe.contentWindow.postMessage("SFCHAT-SETTINGS", "*");
};
};
makeChatDragable(sfChatContainer);
sfChatIframe = document.createElement("iframe");
sfChatIframe.setAttribute(
"src", sfChatURL
);
sfChatIframe.id = "sfChat-iframe";
sfChatIframe.setAttribute("style", "width: 600px; height:700px; z-index: 10000;");
sfChatContainer.appendChild(sfChatIframe);
document.getElementsByTagName("body")[0].appendChild(sfChatContainer);
const startTimeout = setTimeout(function () {
F.log("settings");
sendSettings();
let nameChange = setTimeout(function () {
sfChatUsername = `[Krunker] ${extract("sfChatUsername")}`;
sfChatIframe.contentWindow.postMessage("SFCHAT-UPDATE" + JSON.stringify({ name: sfChatUsername }), "*");
}, 500);
}, 1000);
unsafeWindow.addEventListener("message", (e) => {
if (typeof e.data == "string"){
if (e.data.startsWith("SFCHAT-UPDATE")) {
GM_setValue("SFCHAT-SETTINGS", e.data.replace(/SFCHAT-UPDATE/gm, ""));
}
if (e.data.startsWith("SFCHAT-REQUEST")) {
sendSettings();
};
if (e.data.startsWith("SFCHAT-MESSAGE")) {
let stringMessage = e.data.replace(/SFCHAT-MESSAGE/gm, "");
let message = JSON.parse(stringMessage);
if (extract("sfChatNotifications") && message.user && message.message && (sfChatContainer.style.display == "none")){
if (message.message.length <= 50){
createPopup(message.user.name + ": " + message.message);
}else{
createPopup(message.user.name + ": " + message.message.substring(0, 50) + "...");
}
}
}
}
});
};
const applyStylesAddElements = function (themeToApply = "null") {
//menu customisation (apply font, button widths, adjust checkbox right slightly, make menu appear on top, add anim to message)
const styleElement = document.createElement('style');
styleElement.textContent = `
@font-face {
font-family: "Bahnschrift";
src: url("https://db.onlinewebfonts.com/t/0a6ee448d1bd65c56f6cf256a7c6f20a.eot");
src: url("https://db.onlinewebfonts.com/t/0a6ee448d1bd65c56f6cf256a7c6f20a.eot?#iefix")format("embedded-opentype"),
url("https://db.onlinewebfonts.com/t/0a6ee448d1bd65c56f6cf256a7c6f20a.woff2")format("woff2"),
url("https://db.onlinewebfonts.com/t/0a6ee448d1bd65c56f6cf256a7c6f20a.woff")format("woff"),
url("https://db.onlinewebfonts.com/t/0a6ee448d1bd65c56f6cf256a7c6f20a.ttf")format("truetype"),
url("https://db.onlinewebfonts.com/t/0a6ee448d1bd65c56f6cf256a7c6f20a.svg#Bahnschrift")format("svg");
}
.tp-dfwv, .tp-sglv_i, .tp-rotv_t, .tp-fldv_t, .tp-ckbv_l, .tp-txtv_i, .tp-lblv_l, .tp-tbiv_t, .coords, .playerstats {
font-family: 'Bahnschrift', sans-serif !important;
font-size: 16px;
z-index: 9999 !important;
}
.tp-rotv_m, .tp-fldv_m {
display: none;
}
.tp-dfwv {
min-width: 300px;
}
.tp-rotv_t {
cursor: move;
user-select: none;
color: #FFFFFF;
}
.tp-fldv_t {
color: #FFFFFF;
}
.tp-tbiv_t {
font-family: 'Bahnschrift';
font-size: 13px;
}
.tp-lblv_v, .tp-lstv, .tp-btnv_b, .tp-btnv_t {
font-family: 'Bahnschrift';
font-size: 12px;
}
.tp-mllv {
font-family: 'Bahnschrift';
font-size: 12px;
letter-spacing: -1px;
width: 290px;
margin-left: -130px !important;
}
.tp-mllv_i::-webkit-scrollbar-thumb {
background-color: #888; /* Adjust the color as needed */
border: 2px solid #555; /* Change the color of the border and adjust the width as needed */
}
.tp-mllv_i::-webkit-scrollbar-track {
background-color: #000; /* Change the color as needed */
}
.tp-lblv_l {
font-size: 14px;
letter-spacing: -1px;
}
.tp-btnv {
width: 100px;
margin-left: 60px !important;
}
.tp-ckbv_w {
margin-left: 4px !important;
}
.tp-dfwv, .tp-rotv, .tp-rotv_c, .tp-fldv, .tp-fldv_c, .tp-lblv, .tp-lstv, .tp-btnv, .tp-sldv {
z-index: 99999 !important;
white-space: nowrap !important;
}
@keyframes msg {
from {
transform: translate(-120%, 0);
opacity: 0;
}
to {
transform: none;
opacity: 1;
}
}
`;
document.head.appendChild(styleElement);
applyTheme();
//initiate message div and css and shit
msgElement = document.createElement('div'); // create the element directly
scrambledMsgEl = getScrambled();
msgElement.classList.add(scrambledMsgEl);
msgElement.setAttribute('style', `
position: absolute;
left: 10px;
color: #fff;
background: rgba(0, 0, 0, 0.7);
font-weight: normal;
padding: 10px;
border-radius: 5px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
border: 2px solid rgba(255, 255, 255, 0.5);
animation: msg 0.5s forwards, msg 0.5s reverse forwards 3s;
pointer-events: none;
opacity: 0;
transition: opacity 0.3s ease-in-out;
font-family: 'Bahnschrift', sans-serif !important;
font-size: 16px;
z-index: 9999 !important;
`);
document.body.appendChild(msgElement);
msgElement.style.display = 'none';
const messageContainer = document.createElement('div'); //so it can be cloned. i think.
messageContainer.id = 'message-container';
document.body.appendChild(messageContainer);
//initiate coord div and css and shit
coordElement = document.createElement('div'); // create the element directly
coordElement.classList.add('coords');
coordElement.setAttribute('style', `
position: fixed;
top: 0px;
left: 0px;
height: auto;
max-height: 30px;
min-height: 30px;
text-wrap: nowrap;
color: #fff;
background: rgba(0, 0, 0, 0.6);
font-weight: bolder;
padding: 2px;
border-radius: 5px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
border: 2px solid rgba(255, 255, 255, 0.5);
z-index: 999999;
`);
document.body.appendChild(coordElement);
coordElement.style.display = 'none';
//initiate hp div and css and shit
playerstatsElement = document.createElement('div'); // create the element directly
playerstatsElement.classList.add('playerstats');
playerstatsElement.setAttribute('style', `
position: absolute;
top: 20px;
left: 280px;
height: auto;
min-height: 30px;
text-wrap: nowrap;
color: #fff;
background: rgba(0, 0, 0, 0.6);
font-weight: bolder;
padding: 10px;
border-radius: 5px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
border: 2px solid rgba(255, 255, 255, 0.5);
z-index: 999999;
`);
document.body.appendChild(playerstatsElement);
playerstatsElement.style.display = 'none';
if (load("HUD-Positions") == null) {
hudElementPositions.coordElement = { top: coordElement.getBoundingClientRect().top, left: coordElement.getBoundingClientRect().left };
hudElementPositions.playerstatsElement = { top: playerstatsElement.getBoundingClientRect().top, left: playerstatsElement.getBoundingClientRect().left };
save("HUD-Positions", hudElementPositions);
} else {
hudElementPositions = load("HUD-Positions");
coordElement.style.top = hudElementPositions.coordElement.top + "px";
playerstatsElement.style.top = hudElementPositions.playerstatsElement.top + "px";
coordElement.style.left = hudElementPositions.coordElement.left + "px";
playerstatsElement.style.left = hudElementPositions.playerstatsElement.left + "px";
};
};
const makeDraggable = function (element, notMenu) {
if (element) {
let offsetX, offsetY;
element.addEventListener('mousedown', function (e) {
const dragElement = function (e) {
const x = (e.clientX - offsetX) / unsafeWindow.innerWidth * 100;
const y = (e.clientY - offsetY) / unsafeWindow.innerHeight * 100;
const maxX = 100 - (element.offsetWidth / unsafeWindow.innerWidth * 100);
const maxY = 100 - (element.offsetHeight / unsafeWindow.innerHeight * 100);
element.style.left = `${Math.max(0, Math.min(x, maxX))}%`;
element.style.top = `${Math.max(0, Math.min(y, maxY))}%`;
};
if (notMenu || e.target.classList.contains('tp-rotv_t')) {
offsetX = e.clientX - element.getBoundingClientRect().left;
offsetY = e.clientY - element.getBoundingClientRect().top;
document.addEventListener('mousemove', dragElement);
document.addEventListener('mouseup', function () {
document.removeEventListener('mousemove', dragElement);
});
e.preventDefault(); // Prevent text selection during drag
};
});
};
};
const makeHudElementDragable = function (element) {
if (element.getAttribute("drag-true") != "true") {
element.addEventListener("mousedown", function (e) {
let offsetX = e.clientX - parseInt(window.getComputedStyle(this).left);
let offsetY = e.clientY - parseInt(window.getComputedStyle(this).top);
function mouseMoveHandler(e) {
let newX = e.clientX - offsetX;
let newY = e.clientY - offsetY;
if (newX >= 0 && newX + element.getBoundingClientRect().width <= window.innerWidth) {
element.style.left = newX + "px";
};
if (newY >= 0 && newY + element.getBoundingClientRect().height <= window.innerHeight) {
element.style.top = newY + "px";
};
};
function reset() {
window.removeEventListener("mousemove", mouseMoveHandler);
window.removeEventListener("mouseup", reset);
//saves new positions
hudElementPositions.coordElement = { "top": coordElement.getBoundingClientRect().top, "left": coordElement.getBoundingClientRect().left };
hudElementPositions.playerstatsElement = { "top": playerstatsElement.getBoundingClientRect().top, "left": playerstatsElement.getBoundingClientRect().left };
save("HUD-Positions", hudElementPositions);
};
window.addEventListener("mousemove", mouseMoveHandler);
window.addEventListener("mouseup", reset);