-
Notifications
You must be signed in to change notification settings - Fork 11
/
modtools.user.js
1407 lines (1258 loc) · 55.9 KB
/
modtools.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name Mod Tools Helper
// @namespace http://www.reddit.com/u/bizkut
// @updateURL https://github.com/mcgrogan91/TagProScripts/raw/master/modtools.user.js
// @version 1.7.3
// @description It does a lot. And then some. I'm not even joking. It does too much.
// @author Bizkut
// @contributor OmicroN
// @contributor Carbon
// @include http://tagpro-*.koalabeast.com/moderate/*
// @include https://tagpro.koalabeast.com/moderate/*
// @include http://tangent.jukejuice.com/moderate/*
// @require https://cdnjs.cloudflare.com/ajax/libs/crosstab/0.2.12/crosstab.min.js
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_xmlhttpRequest
// @grant GM_addValueChangeListener
// ==/UserScript==
var bizAPI = "https://kylemcgrogan.com/api/";
var commentAPI = bizAPI + "comments/";
var evasionAPI = bizAPI + "evasion/";
var getActionURL = function(id, type, actionType) {
return document.location.origin + '/moderate/' + type + '/' + id + '/' + actionType;
}
var banAction = function(id, type, count, reason, callback) {
$.post(getActionURL(id, type, 'ban'), {
reason: reason,
banCount: count
}, callback);
}
var unbanAction = function(id, type, callback) {
$.post(getActionURL(id, type, 'unban'), callback);
}
var muteAction = function(id, type, callback) {
$.post(getActionURL(id, type, 'mute'), callback);
}
var unmuteAction = function(id, type, callback) {
$.post(getActionURL(id, type, 'unmute'), callback);
}
var setEvasionProfileHeader = function(total, remaining, action) {
var percentRemaining = (total-remaining)/total*100;
document.getElementById("evasionProfileHeader").innerText = "Evasion Profile - "+action+" - "+percentRemaining.toFixed(1)+"% complete";
document.title = "Action In Progress";
}
var evasionSection = function() {
var isProfile = window.location.href.indexOf("users/") > 0;
var isIP = window.location.href.indexOf("ips/") > 0;
if (!(isProfile || isIP)) return;
var pageId = window.location.href.substring(window.location.href.lastIndexOf("/") + 1);
var route = 'evasion_profile';
if (isIP) {
route = 'evasion_ips';
/////////////// GRAB SPECTATOR LINK FOR UNREGISTERED USERS
// start with getting the ip
var ip = $('label:contains("IP Address")').next().text();
// search the last 15 min of activity to see if still possibly playing
$.getJSON(document.location.origin + '/moderate/chat?hours=0.25&ip=' + ip, function(data) {
if (Object.keys(data).length) {
// user the latest activity to calculate last activity
var lastActivity = (((new Date()).getTime() - (new Date(data[0].when)).getTime()) / 1000 / 60 * 0.0166).toFixed(1);
$('label:contains("IP Address")').parent().after('<div><label class="inline">Recent Activity</label><span class="ipchecked">' + lastActivity + ' hours ago</span></div>');
var users = {};
// loop through last 15 min of activity and find any
Object.keys(data).forEach(function(item, index) {
if (typeof users[data[index].displayName] === 'undefined') {
users[data[index].displayName] = data[index].gameId;
}
});
// search found active users in last 15 minutes
if (Object.keys(users).length) {
// search active games list
$.getJSON(document.location.origin + '/moderate/games', function(data4) {
// search through last active users/games
Object.keys(users).forEach(function(name, index) {
var gameId = users[name];
var someName = name;
// if last active users game is found in the current active games list then appaend spectator link to page
Object.keys(data4).forEach(function(item, index) {
if (data4[index].gameId == gameId) {
if (data4[index].spectateUrl) {
$('form:first').after('<a href="' + data4[index].spectateUrl + '&target=' + someName + '" target="_blank" class="button tiny ipchecked">Spectate ' + someName + '</a>');
}
return;
}
});
});
});
}
}
});
//////////////////////////
} else {
var speclink = $('a:contains("Spectate")');
speclink.attr('href', speclink.attr('href') + '&target=' + encodeURIComponent($('label:contains("Display Name")').next().text()));
}
$.get(evasionAPI + "find_evader/" + pageId, {}, function(response) {
$('head').append('<style> .evasionSection { float:right; width:60%; border-left: 1px solid #fff; padding-left:20px;} .pad {padding: 10px;} .indent {padding-left:10px;}</style>');
var evasionSection = $("<div class='evasionSection'/>"),
addAccount,
addIP;
if (response.length == 0) {
var newEvasionProfile = $('<button id="newProfile" class="small">Make new Ban Evasion Profile</button>');
newEvasionProfile.on('click', function() {
$.post(evasionAPI + route, {account_id:pageId}, function(res) {
location.reload();
});
});
evasionSection.append(newEvasionProfile);
}
if ((response.length == 0 && isProfile) || isIP) {
var existingEvasionProfile = $('<button id="existingProfile" class="small">Add to existing Ban Evasion Profile</button>');
existingEvasionProfile.on('click', function() {
var evasionId = prompt("Enter profile ID of evader", "");
if (evasionId != "" && evasionId != null) {
$.post(evasionAPI + route, {account_id:pageId, existing_id:evasionId}, function(res) {
location.reload();
});
}
});
evasionSection.append(existingEvasionProfile);
}
var evasionAccounts = $("<div/>");
response.forEach(function(banProfile, index, array) {
var evasionAccount = $("<div class='pad'/>");
evasionAccount.append("<h2 id='evasionProfileHeader'>Evasion Profile</h2>");
var evasionButtonToolTips = {
ban: "Accounts and IPs linked to the evasion profile have their ban count increased by 1.\nThe ban reason is \"ban evasion\".",
unban: "Accounts and IPs linked to the evasion profile have their ban count decreased by 1.",
mute: "Accounts linked to the evasion profile have their mute count increased by 1.\nIPs linked to the evasion profile have their ban count increased by 1.",
unmute: "Accounts linked to the evasion profile have their mute count decreased by 1.\nIPs linked to the evasion profile have their ban count decreased by 1."
};
var evasionBanButton = $("<button class='small' title='"+evasionButtonToolTips['ban']+"'>Ban</button>");
var evasionUnbanButton = $("<button class='small' title='"+evasionButtonToolTips['unban']+"'>Unban</button>");
var evasionMuteButton = $("<button class='small' title='"+evasionButtonToolTips['mute']+"'>Mute</button>");
var evasionUnmuteButton = $("<button class='small' title='"+evasionButtonToolTips['unmute']+"'>Unmute</button>");
var banEvasionReason = 7; //This is hacky as shit. I should probably search the ban reason list for the id but i'm drunk coding.
var accountBanListTotal; //Set at the end of the forEach, accountBanList needs to be populated
var userMuteListTotal; //Set at the end of the forEach, usersOnlyList needs to be populated
var addAction = false; //If you can get the callback w/parameter working, please change this so addAction isn't used.
var evasionBanAction = function() {
if (accountBanList.length != 0) {
setEvasionProfileHeader(accountBanListTotal, accountBanList.length, (addAction ? "Ban" : "Unban"));
var profile = accountBanList.pop();
if(addAction) {
var banCount = parseInt(profile.el.attr('data-bancount'));
banAction(profile.id, profile.type, banCount + 1, banEvasionReason, evasionBanAction);
} else {
unbanAction(profile.id, profile.type, evasionBanAction);
}
} else {
document.getElementById("evasionProfileHeader").innerText = "Evasion Profile - Complete, refreshing";
location.reload();
}
};
var evasionMuteAction = function() {
if (usersOnlyList.length != 0) {
setEvasionProfileHeader(userMuteListTotal, usersOnlyList.length, (addAction ? "Mute" : "Unmute"));
var profile = usersOnlyList.pop();
if(addAction) {
muteAction(profile.id, "users", evasionMuteAction);
} else {
document.getElementById("evasionProfileHeader").innerText = "Evasion Profile - Complete, refreshing";
unmuteAction(profile.id, "users", evasionMuteAction);
}
} else {
location.reload();
}
};
var accountBanList = [];
evasionAccount.append(evasionBanButton);
evasionAccount.append(evasionUnbanButton);
evasionAccount.append(evasionMuteButton);
evasionAccount.append(evasionUnmuteButton);
if (banProfile.profiles.length > 0) {
var accounts = $("<p class='evasion_accounts' class=''></p>");
accounts.append("<h2 class='indent'>Accounts</h2>");
var accountList = $("<ul class='indent'/>");
banProfile.profiles.forEach(function(profile, i, a) {
var link = $("<a class='ban_profile_account' href='//" + window.location.hostname + "/moderate/users/" + profile.profile_id +"'>" + profile.profile_id +"</a>");
var removeAccount = $("<span class='removeAccount' data-id='"+profile.id+"'> ✗</span>");
accountBanList.push({
id: profile.profile_id,
type: 'users',
el: link
});
var list = $("<li class='indent'></li>");
list.append(link);
list.append(removeAccount);
accountList.append(list);
});
accounts.append(accountList);
evasionAccount.append(accounts);
}
if (banProfile.ranges.length > 0) {
var ips = $("<p class='evasion_ips' class='pad'></p>");
ips.append("<h2 class='indent'>IPs</h2>");
var ipList = $("<ul class='indent'/>");
banProfile.ranges.forEach(function(ip, i, a) {
var link = $("<a class='ban_profile_ip' href='//" + window.location.hostname + "/moderate/ips/" + ip.tagpro +"'>" + ip.tagpro +"</a>");
var removeIP = $("<span class='removeIP' data-id='"+ip.id+"'> ✗</span>");
accountBanList.push({
id: ip.tagpro,
type: 'ips',
el: link
});
var list = $("<li class='indent'></li>");
list.append(link);
list.append(removeIP);
ipList.append(list);
});
ips.append(ipList);
evasionAccount.append(ips);
}
evasionBanButton.on('click', function() {
if (dinkProtect(true)) {
addAction = true;
evasionBanAction();
}
});
evasionUnbanButton.on('click', function() {
if (dinkProtect(true)) {
addAction = false;
evasionBanAction();
}
});
evasionMuteButton.on('click', function() {
evasionProfileButton(true);
});
evasionUnmuteButton.on('click', function() {
evasionProfileButton(false);
});
var evasionProfileButton = function(addditive) {
usersOnlyList = accountBanList.filter(function(e) {
return e.type === 'users'; //only users can be muted
});
accountBanList = accountBanList.filter(function(e) {
return e.type === 'ips'; //only ips should be banned
});
userMuteListTotal = usersOnlyList.length;
accountBanListTotal = accountBanList.length;
if (dinkProtect(true)) {
addAction = addditive;
evasionMuteAction();
evasionBanAction();
}
};
accountBanListTotal = accountBanList.length;
evasionAccounts.append(evasionAccount);
});
evasionSection.append(evasionAccounts);
$('form').before(evasionSection);
if (isProfile) {
lastIP = $('label:contains("Last IP")').next().text();
} else {
lastIP = pageId;
}
$.get(evasionAPI + "suspicious/" + lastIP, {}, function(response) {
if (response[2] || response[3]) {
var suspiciousSection = $("<div class='pad' />");
suspiciousSection.append('<h2>Similar Flagged IPs</h2>');
if (response[3]) {
var ipList = $("<ul class='indent' />");
response[3].forEach(function(item) {
ipList.append("<li class='indent'><a href='//" + window.location.hostname + "/moderate/ips/" + item +"'>" + item +"</a></li>" );
});
ipList.prepend("<h2>Very Similar</h2>");
suspiciousSection.append(ipList);
}
if (response[2]) {
var ipList = $("<ul class='indent' />");
response[2].forEach(function(item) {
ipList.append("<li class='indent'><a href='//" + window.location.hostname + "/moderate/ips/" + item +"'>" + item +"</a></li>" );
});
ipList.prepend("<h2>Somewhat Similar</h2>");
suspiciousSection.append(ipList);
}
}
$(".evasionSection").append(suspiciousSection);
});
$("a.ban_profile_account").each(function(index, element) {
var el = $(element);
colorAccountInfo(el);
});
$("a.ban_profile_ip").each(function(index, element) {
var el = $(element);
colorAccountInfo(el, false);
});
$('.removeAccount').on('click', function(el) {
var accountId = $(this).data('id');
$.ajax({
url: evasionAPI + "evasion_profile/" + accountId,
type: 'DELETE',
success: function(){
var id = this.url.substring(this.url.lastIndexOf("/")+1);
$(".removeAccount[data-id='"+id+"']").parent().remove();
}
});
});
$('.removeIP').on('click', function(el) {
var ipId = $(this).data('id');
$.ajax({
url: evasionAPI + "evasion_ips/" + ipId,
type: 'DELETE',
success: function(){
var id = this.url.substring(this.url.lastIndexOf("/")+1);
$(".removeIP[data-id='"+id+"']").parent().remove();
}
});
});
});
};
if (("Notification" in window)) {
if (Notification.permission !== "granted" && Notification.permission !== 'denied') {
Notification.requestPermission();
}
}
var optionsLink = $('<a href="#" id="options">Options</a>');
var optionsPage = $("<div/>");
$("a[href='/moderate/modactions']").after(optionsLink);
optionsPage.append("SETTINGS!<br/><br/>");
optionsPage.append("<div><input type='checkbox' id='longTime' /><label for='longTime'>Full time on Chat Page (Adds seconds to times)</label></div><br/>");
optionsPage.append("<div><input type='checkbox' id='dinkProtect' /><label for='dinkProtect'>Enable dink protections (Requires verification to ban/unban)</label></div><br/>");
optionsPage.append("<div><input type='checkbox' id='communityAlert' /><label for='communityAlert'>Community Alerts (Triggers notifications on Community Ban Appeals)</label></div><br/>");
optionsPage.append("<div><input type='checkbox' id='reportCounter' /><label for='reportCounter'>Disable active reports counter in the Recent Reports header</label></div><br/>");
var countSelect = "<select id='commonCount'>";
for(var amount = 0; amount < 10; amount++) {
if (amount+1 == GM_getValue("common_count", 5)) {
countSelect += "<option value='"+(amount+1)+"' selected>"+(amount+1)+"</option>";
} else {
countSelect += "<option value='"+(amount+1)+"'>"+(amount+1)+"</option>";
}
}
countSelect += "</select> (Number of common accounts to find)<br/><br/>";
optionsPage.append(countSelect);
optionsPage.append("<p>Script brought to you by bizkut in collaboration with OmicroN.</p><p>If you have any suggestions for more features or bugs, "
+"send a message to bizkut on <a href='https://www.reddit.com/message/compose/?to=bizkut'>reddit</a> or OmicroN on <a href='https://www.reddit.com/message/compose/?to=-OmicroN-'>reddit</a>.</p>");
function prepToggle(id, gm_val) {
if(GM_getValue(gm_val)===true){
$(id).prop('checked', true);
}
$(id).on('change', function() {
if($(this).is(":checked")) {
GM_setValue(gm_val, true)
} else {
GM_setValue(gm_val, false)
}
});
}
optionsLink.on('click',function() {
$("#filters").remove();
var contentSection = $("#content").addClass('noFilters pad');
contentSection.empty();
contentSection.append(optionsPage);
prepToggle("#longTime", "longTime");
prepToggle("#dinkProtect", "dink_protect");
prepToggle("#communityAlert", "alert_community");
prepToggle("#reportCounter", "report_counter");
$("#commonCount").on('change', function() {
GM_setValue("common_count", $(this).val());
});
});
var supportLink = $('<a href="#" id="support">Support</a>');
optionsLink.after(supportLink);
supportLink.on('click', displaySupport);
function displaySupport() {
$("#filters").remove();
var contentSection = $("#content").addClass('noFilters pad');
contentSection.empty();
contentSection.append(buildSupport());
}
function buildSupport() {
var supportPage = $("<div id='supportPage'/>");
var knownTickets = JSON.parse(GM_getValue('known_tickets',"{}"));
var waitingCount = 0;
var ticket = null;
var style = "";
for (key in knownTickets) {
ticket = knownTickets[key];
var ticketRow = $("<div id='" + ticket.ticket.id + "'/>");
if (ticket.waiting) {
style=" style='color:red' ";
waitingCount++;
} else {
style = "";
}
ticketRow.html('<a href="http://support.koalabeast.com/#/ticket/'+ ticket.ticket.id
+'" '+ style + 'target="_blank">Appeal ' + ticket.ticket.id + ' (Banned by '
+ (ticket.ticket.bannedBy == GM_getValue('mod_username')? "you":ticket.ticket.bannedBy) + ') - '+ ticket.ticket.comments.length
+ ' comment'+(ticket.ticket.comments.length!=1?'s':'')+'</a><br/>');
supportPage.append(ticketRow);
}
var title = $("a#support");
if (waitingCount > 0) {
title.text('('+waitingCount+') Support');
} else {
title.text('Support');
}
if ($("#supportPage").length > 0) {
var contentSection = $("#content");
contentSection.empty();
contentSection.append(buildSupport());
}
return supportPage;
}
function setMod() {
if (GM_getValue('mod_username') === undefined) {
$.get(window.location.origin, function (data) {
var hrf = $(data).find("a:contains('Profile')")[0].href;
$.get(hrf, function (data2) {
GM_setValue('mod_username', $(data2).find("#reservedName").val());
});
});
}
}
setMod();
/*
* For some reason, crosstab.util.tabs is coming up as empty sometimes, so wrap this.
* It means we don't get the API calls sometimes though.
*/
function isMasterTab() {
return crosstab.util.tabs[crosstab.util.keys.MASTER_TAB] ?
crosstab.util.tabs[crosstab.util.keys.MASTER_TAB].id === crosstab.id
:false;
}
// Check every second, only poll every 5 though. Tab could become active partway through.
//setInterval(checkTickets, 1000);
function checkTickets() {
if (GM_getValue('mod_username') !== undefined) {
if ((GM_getValue('last_ticket_check') === undefined
|| GM_getValue('last_ticket_check') < ((new Date().getTime() / 1000)) - 5)
&& isMasterTab()) {
GM_xmlhttpRequest({
method: "GET",
headers: {"Accept": "application/json"},
url: "http://support.koalabeast.com/tickets/open",
onload: function(response) {
var knownTickets = JSON.parse(GM_getValue('known_tickets',"{}"));
GM_setValue('last_ticket_check', (new Date().getTime() / 1000));
try {
var warn = $('#support-warning');
if (warn.length > 0) {
warn.remove();
}
knownTickets = JSON.parse(response.responseText);
} catch (err) {
var warned = $('#support-warning').length > 0;
if (!warned) {
$('header > a').append('<a href="http://support.koalabeast.com/#/login" id="support-warning" target="_blank" style="font-weight:bold;color:red;padding-left:40%;">(You are not logged into the support site)</a>');
console.log('Error happened');
console.dir(err);
}
return;
}
knownTickets.forEach(function(ticket, index, array) {
if (appealMatches(ticket.bannedBy)) {
var waiting = ticket.comments.length > 0 ?
ticket.comments[ticket.comments.length - 1].author == "ticket creator"
: true;
// Notify if waiting
if (waiting) {
if (knownTickets[ticket.id]) {
if (!knownTickets[ticket.id].waiting) {
// Refresh it, we got it
attemptNotify(ticket);
}
} else {
// Refresh it, we got it
attemptNotify(ticket);
}
}
knownTickets[ticket.id] = {
ticket: ticket,
waiting: waiting,
live: true
};
}
});
// Clean up tickets that could have been removed
for (key in knownTickets) {
if (knownTickets[key].live) {
knownTickets[key].live = false;
} else {
delete knownTickets[key];
}
}
GM_setValue('known_tickets', JSON.stringify(knownTickets));
}
});
}
}
}
function attemptNotify(ticket) {
if (!("Notification" in window)) {
return;
}
else if (Notification.permission === "granted") {
notifyOfAppeal(ticket);
}
else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
if (permission === "granted") {
notifyOfAppeal(ticket);
}
});
}
}
function notifyOfAppeal(ticket) {
var notification = new Notification("Active Appeal", {
'body': 'You have an appeal waiting for a moderator response!',
'icon': 'http://static.koalabeast.com/images/favicon.ico'
});
notification.onclick = function() {
window.open('http://support.koalabeast.com/#/ticket/' + ticket.id, '_blank');
notification.close();
}
}
function appealMatches(appealName) {
return (appealName.toUpperCase() == GM_getValue('mod_username').toUpperCase()) ||
(GM_getValue('alert_community') && appealName.toUpperCase() == 'COMMUNITY');
}
GM_addValueChangeListener('known_tickets', buildSupport);
function bindReason(e) {
var t = moderate.kickReasons["" + e];
return t ? t.text : ""
}
function bindPlayerName(e) {
return e ? e.reservedName : ""
}
function bindSince(e) {
return e ? moment(e).format("MMMM D YYYY h:mm:ss A") : "-"
}
function bindDate(e) {
return moment(e).format("LLL")
}
function bindChatTo(e) {
switch (e) {
case 1:
return "All";
case 2:
return "Team";
case 3:
return "Mod";
default:
return ""
}
}
function bindUserId(e) {
return e ? e : ""
}
function bindGameState(e) {
switch (e) {
case 1:
return "In Progress";
case 2:
return "Completed";
case 3:
return "Starting";
default:
return "I Dunno"
}
}
function bindBool(e) {
return e ? "Yes" : "No"
}
function bindValue(e) {
return e ? e : ""
}
/**
* On any of the moderation tables where we display a bunch of rows
* this function will make it display a row explaining there were no responses
*/
function addNoResponseCheck() {
if (typeof moderate !== 'undefined') {
moderate.oldBind = moderate.smartBind;
moderate.smartBind = function($template, data) {
var rows = moderate.oldBind($template, data);
if (Array.isArray(rows) && rows.length == 0) {
rows.push($("<tr><td></td><td></td><td></td><td style='font-size:5em'>No results</td></tr>"))
}
return rows;
}
}
};
addNoResponseCheck();
function dinkProtect(override = false) {
if (override === true || GM_getValue("dink_protect") === true) {
if (confirm("Are you sure you want to do that, you dink?")) {
if (confirm("Like, absolutely sure?")) {
return true;
}
}
return false;
} else {
return true;
}
}
function isMuteActive(text) {
return text.indexOf("in") >= 0;
}
var newAcntHours = 48;
function colorAccountInfo(accountLink, extraInfo = true) {
$.get(accountLink[0].href, function (data) {
var children = $(data).children("form").children();
var reserved = $(children[0]).find("span").text();
var display = $(children[1]).find("span").text();
accountLink.attr("data-name", reserved?reserved:display);
var hoursAgo = ($(children[2]).children("span").text());
var lastIp = ($(children[3]).children("a").text());
var accountAge = ($(children[4]).children("span").text());
var muteCount = ($(children[8]).children("span").text()); // this gives us some text with the number in parentheses
var banCount = $(data).find("#banCount").val();
if (extraInfo) {
accountLink.append(" - Last Played: " + hoursAgo + " | IP: " + lastIp + " | Age: " + accountAge);
}
accountLink.append(" | Bans: " + banCount + " | Mutes: " + muteCount);
if (muteCount.length) {
muteCount = muteCount.match(/\(([^)]+)\)/)[1]; // Pull that number out
accountLink.append(" | Mutes: " + muteCount);
}
var hours = hoursAgo.split(" ")[0];
var hoursAsFloat = parseFloat(hours);
var hoursAge = accountAge.split(" ")[0];
var hoursAgeAsFloat = parseFloat(hoursAge);
var muteText = $(children[8]).find("span").text();
accountLink.attr('data-bancount', banCount);
// Orange/Cyan added for new accounts by Ballzilla
if (data.indexOf("unbanButton") > -1) {
accountLink.append(" (This user is currently banned)");
if(hoursAgeAsFloat <= newAcntHours) {
accountLink.css({
'color': 'orange'
})
} else {
accountLink.css({
'color': 'red'
})
}
} else if (isMuteActive(muteText)) {
accountLink.css({
'color': 'yellow'
})
} else if(hoursAgeAsFloat <= newAcntHours) {
accountLink.css({
'color': 'cyan'
});
}
else if (hoursAsFloat <= 1) {
accountLink.css({
'color': 'green'
});
}
});
}
if (window.location.pathname.indexOf("fingerprints") > -1) {
$("div a").each(function (index, domObject) {
var obj = $(domObject);
colorAccountInfo(obj);
});
}
if (window.location.pathname.indexOf("reports") > -1) {
$("#filters").append("<div style='margin: 0'><input type='checkbox' id='toggleSys' /><label for='toggleSys'>Hide system reports</label></div>");
if(GM_getValue("hideSystem")===true){
$("#toggleSys").prop('checked', true);
}
$("#toggleSys").on('change', function() {
if($(this).is(":checked")) {
GM_setValue("hideSystem", true)
} else {
GM_setValue("hideSystem", false)
}
});
moderate.smartBind = function smartBind($template, data) {
var games = {};
function bind($template, obj) {
var $result = $template.clone();
return $result.find("[data-bind]").each(function() {
var property = $(this).attr("data-bind"),
format = $(this).attr("data-format"),
filterProperty = $(this).attr("data-filter-bind"),
value = null;
eval("value = obj." + property);
if(property === "gameId") {
games[value] = games[value]? games[value]+1 : 1;
}
if (filterProperty) {
var filterValue = null;
value && eval("filterValue = value." + filterProperty), $(this).attr("data-filter-value", filterValue)
}
if (format) {
var func = null;
eval("func = " + format), value = func(value)
}
if (GM_getValue("hideSystem")===true) {
if (property == "byIP" && value == null) {
$(this.parentNode.parentNode).css("display", "none")
return;
}
}
$(this).text(value)
}), $result.find("button[data-link]").each(function() {
var e = "chat?",
t = $(this),
n = t.parents("tr:first"),
r = $(this).attr("data-params").split(" ").map(function(e) {
var t = n.find("[data-bind=" + e + "]"),
r = t.attr("data-filter-value") ? t.attr("data-filter-value") : t.text();
return e + "=" + r
}).join("&");
t.attr("data-link", e + r)
}), $result.find("a[data-link]").each(function() {
var e = "chat?",
t = $(this),
n = t.parents("tr:first"),
r = $(this).attr("data-params").split(" ").map(function(e) {
var t = n.find("[data-bind=" + e + "]"),
r = t.attr("data-filter-value") ? t.attr("data-filter-value") : t.text();
return e + "=" + r
}).join("&");
t.attr("href", e + r)
}), $result.find("[data-if]").each(function() {
var property = $(this).attr("data-if"),
value = null;
try {
eval("value = obj." + property)
} catch (e) {}
if (!value) return $(this).remove();
$(this).attr("href", $(this).attr("href").replace(/{value}/g, value))
}), $result.find("[data-strike-if]").each(function() {
var property = $(this).attr("data-strike-if"),
value = null;
try {
eval("value = obj." + property)
} catch (e) {}
if (value) return $(this).css("text-decoration", "line-through")
}), $result
}
var rows = Array.isArray(data) ? data.map(function(e) {
return bind($template, e)
}) : bind($template, data);
rows.forEach(function(element) {
var text = $(element).children()[6].innerText;
if(games[text] > 2) {
$($(element).children()[6]).prepend("("+games[text]+") ").css({'color':'red'});
}
});
return rows;
};
}
if(window.location.pathname.indexOf('chat') > -1) {
moderate.smartBind = function smartBind($template, data) {
function bind($template, obj) {
var $result = $template.clone();
return $result.find("[data-bind]").each(function() {
var property = $(this).attr("data-bind"),
format = $(this).attr("data-format"),
filterProperty = $(this).attr("data-filter-bind"),
value = null;
eval("value = obj." + property);
if (filterProperty) {
var filterValue = null;
value && eval("filterValue = value." + filterProperty), $(this).attr("data-filter-value", filterValue)
}
if (format) {
var func = null;
eval("func = " + format), value = func(value)
}
$(this).text(value)
}), $result.find("button[data-link]").each(function() {
var e = "chat?",
t = $(this),
n = t.parents("tr:first"),
r = $(this).attr("data-params").split(" ").map(function(e) {
var t = n.find("[data-bind=" + e + "]"),
r = t.attr("data-filter-value") ? t.attr("data-filter-value") : t.text();
return e + "=" + r
}).join("&");
t.attr("data-link", e + r)
}), $result.find("a[data-link]").each(function() {
var e = "chat?",
t = $(this),
n = t.parents("tr:first"),
r = $(this).attr("data-params").split(" ").map(function(e) {
var t = n.find("[data-bind=" + e + "]"),
r = t.attr("data-filter-value") ? t.attr("data-filter-value") : t.text();
return e + "=" + r
}).join("&");
t.attr("href", e + r)
}), $result.find("[data-if]").each(function() {
var property = $(this).attr("data-if"),
value = null;
try {
eval("value = obj." + property)
} catch (e) {}
if (!value) return $(this).remove();
$(this).attr("href", $(this).attr("href").replace(/{value}/g, value))
}), $result.find("[data-strike-if]").each(function() {
var property = $(this).attr("data-strike-if"),
value = null;
try {
eval("value = obj." + property)
} catch (e) {}
if (value) return $(this).css("text-decoration", "line-through")
}), $result
}
return Array.isArray(data) ? data.map(function(e) {
return bind($template, e)
}) : bind($template, data)
};
function bindDate(e) {
if (GM_getValue('longTime') === true) {
return moment(e).format("MMMM D YYYY h:mm:ss A");
} else {
return moment(e).format("LLL");
}
}
$('#reportRows').on('click', 'th', function() {
var $this = $(this);
if ($this.parent().children()[6] != this) { return; }
if ($this.data('selected')) {
$this.removeData('selected');
} else {
$this.data('selected', true);
}
$this.css('background-color', $this.data('selected')?'#444':'');
});
$('#report .buttons').append($('<button id="copyToClipboard" class="small">Get Selected Text</button>').click(function() {
var copyStr = "";
$('#reportRows tr').find('th:eq(6)').each(function(idx, el) {
var $el = $(el);
if ($el.data('selected')) {
copyStr = $el.prev().text()+ ": " + $el.text() + " \n" + copyStr;
}
});
copyStr = ">"+copyStr;
$('.copybox').remove();
var $text = $('<textarea class="copybox" style="height:1.2em;vertical-align:bottom"></textarea>').text(copyStr);
$('#report .buttons').append($text);
$text.select();
}));
}
if(window.location.pathname.indexOf('users') > -1 || window.location.pathname.indexOf('ips') > -1) {
$("#shadowmuteButton").hide();
setActiveCountOnRecentReports(!GM_getValue('report_counter')); //note the !, enabling the checkbox disables functionality
evasionSection();
var profId = window.location.pathname.substr(window.location.pathname.lastIndexOf('/') + 1);
var section = window.location.pathname.indexOf('users') > -1 ? 'users' : 'ips';
if(window.location.pathname.indexOf('users') > -1) {
var fingerprints = $('a[href*="fingerprints"]').parent();
var par = fingerprints.parent();
var togglePrints = $("<span id='togglePrints'>[-] Collapse</span>");
if(GM_getValue("hideFingerprints")===true) {
togglePrints = $("<span id='togglePrints'>[+] Expand</span>");
fingerprints.hide();
}
togglePrints.on('click', function(e) {
if(fingerprints.is(':visible')) {
fingerprints.hide();
GM_setValue("hideFingerprints", true);
togglePrints.text('[+] Expand');
} else {
fingerprints.show();
GM_setValue("hideFingerprints", false);
togglePrints.text('[-] Collapse');
}
})
$(par.children()[0]).after(togglePrints);
var names = [];
var fingerQueue = [];
var fingerprintList = [];
var totalFingerprints = 0;
$('#togglePrints').next('div').find('a').each(function() {
fingerprintList.push($(this).html());
});
totalFingerprints = fingerprintList.length;
if (fingerprintList.length > 0) {
var calculate = $("<button id='calcFingerprints' class='tiny'>Find Common Accounts (May take some time)</button>");
var sharedAccountDiv = $("<div id='sharedAccounts'/>");
sharedAccountDiv.append(calculate);
fingerprints.parent().after(sharedAccountDiv);
calculate.on('click', function(e) {
e.preventDefault();
for (i = 0; i < (fingerprintList.length < 10 ? fingerprintList.length : 10); i++)
{
fingerQueue[i] = setTimeout(function(i) { setTimeout(checkfingerprint(i), 0) }, 0, i);
}
});
function sortObject(obj) {
var arr = [];
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
arr.push({
'key': prop,
'value': obj[prop]
});
}
}
arr.sort(function(a, b) { return b.value.count - a.value.count; });
return arr;
}
function checkfingerprint(pos) {
var queueId = fingerQueue[pos];
$("#calcFingerprints").prop('disabled', true).css('backgroundColor', '#F4F4F4').html('Checking ' + (totalFingerprints - fingerprintList.length + 1) + ' of ' + totalFingerprints + ' fingerprints...');
var fingerprint = fingerprintList.splice(0, 1);
$.ajax({url: window.location.origin + '/moderate/fingerprints/' + fingerprint}).done(function(data) {