-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSocialTools.user.js
More file actions
799 lines (666 loc) · 30.5 KB
/
SocialTools.user.js
File metadata and controls
799 lines (666 loc) · 30.5 KB
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
// ==UserScript==
// @name SocialTools
// @namespace https://github.com/FriendlyBaron/SocialTools
// @version 1.4
// @description SocialTools
// @author FriendlyBaron
// @match https://socialclub.rockstargames.com/crew/*/manage/hierarchy
// @match http://socialclub.rockstargames.com/crew/*/manage/hierarchy
// @match http://socialclub.rockstargames.com/friends/index
// @match https://socialclub.rockstargames.com/friends/index
// @match http://socialclub.rockstargames.com/friends
// @match https://socialclub.rockstargames.com/friends
// @match https://socialclub.rockstargames.com/member/*
// @match http://socialclub.rockstargames.com/member/*
// @grant none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// ==/UserScript==
//First time doing anything tamper/greasemonkey related. Reading on the web seemed to point to jquery making automated button clicks the easist.
//@match will allow it to run only on the crew management pages.
//todos?
// unban
// tempbans? would need some method for storing. greasemonkey cant write to storage.
//The base Jquery to form the dialog comes from here: http://stackoverflow.com/questions/11668111/how-do-i-pop-up-a-custom-form-dialog-in-a-greasemonkey-script
//--- Use jQuery to add the form in a "popup" dialog.
if (window.location.href == "http://socialclub.rockstargames.com/friends/index" || window.location.href == "https://socialclub.rockstargames.com/friends/index"
|| window.location.href == "https://socialclub.rockstargames.com/friends" || window.location.href == "https://socialclub.rockstargames.com/friends")
{
$("header").append ( ' \
<div id="PopupContainer" style="text-align:center"> \
<hr/> \
<form> <!-- For true form use method="POST" action="YOUR_DESIRED_URL" --> \
<input type="text" id="message" placeholder="Optional Message"> \
<button id="msgAllFriends" type="button"><h4>Message All Friends</h4></button> \
<button id="showRemover" type="button"><h4>Show One-Click Delete Friend</h4></button> <!--not gonna worry about hiding these buttons, the page can just be refreshed--> \
<button id="removeAllChecked" type="button"><h4>Remove All Checked</h4></button> \
<button id="denyAll" type="button"><h4>Deny All Friend Requests</h4></button> \
<h3 style="color:white" id="infoText"> </h3> \
</form> \
</div> \
' );
}
else if (window.location.href.startsWith("https://socialclub.rockstargames.com/member") || window.location.href.startsWith("http://socialclub.rockstargames.com/member"))
{
setTimeout(showDeleteFriendOption, 1250);
}
else
{
$("header").append ( ' \
<div id="PopupContainer" style="text-align:center"> \
<hr/> \
<form> <!-- For true form use method="POST" action="YOUR_DESIRED_URL" --> \
<input type="text" id="name" placeholder="Enter Name"> \
<input type="text" id="message" placeholder="Optional Message"> \
<h3 style="color:white" id="infoText"> </h3> \
<button id="kickButton" type="button"><h4>Kick Player</h4></button> \
<button id="banButton" type="button"><h4>Ban Player</h4></button> \
<button id="messageAll" type="button"><h4>Message All Checked</h4></button> \
<button id="playerPopup" type="button"><h4>Open Player Popup</h4></button> \
<button id="listByActive" type="button"><h4>List All with Different Active Crew</h4></button> \
<button id="listByRank" type="button"><h4>List All by Rank</h4></button> \
<button id="CloseListBtn" style="text-align:center" type="button"><h4>Hide Player List</h4></button> \
<button id="CloseDlgBtn" type="button"><h4>Hide SocialTools</h4></button> \
<br/> \
<br/> \
<button id="denyAllJoin" type="button"><h4>Deny All Join Requests</h4></button> \
<button id="denyAllJoinSpareXbox" type="button"><h4>Deny All Join Requests without a linked Xbox Account</h4></button> \
<button id="denyAllJoinSparePSN" type="button"><h4>Deny All Join Requests without a linked PSN Account</h4></button> \
</form> \
</div> \
' );
setTimeout(setQueryPlayer, 3000);
}
function setQueryPlayer()
{
var name = localStorage.getItem("queryPlayer");
if (name !== null && name.length > 0)
{
$("input[id='nickname']").val(name);
if ($("input[id='nickname']").val() == name)
{
setTimeout(checkQueryPlayer, 1100, name);
localStorage.setItem("queryPlayer","");
}
else
{
setTimeout(setQueryPlayer, 1000);
}
}
}
function checkQueryPlayer(name)
{
$("a[id='searchHierarchy']")[0].click();
if ($("label[for='check_" + name + "']").length)
{
if ($("label[for='check_" + name + "']").parent().attr("title") == "Deselect")
{
setTimeout(checkQueryPlayer, 1000, name);
}
else
{
$("label[for='check_" + name + "']").click();
setTimeout(checkQueryPlayer, 1000, name);
}
}
}
//the whole process for doing the kick/ban and message has to be split up function wise to allow for the pages to load. There might be a way to trigger of a callback instead but this works for now.
function sendMessage(nameStr, messageStr, kickOrBan) {
$("a[title='Message']").click(); //message button
setTimeout(writeMessage, 1500, nameStr, messageStr, kickOrBan);
}
function unfriendMore() {
$("a[title='More Options']")[0].click();
setTimeout(unfriendUnfriend, 500);
}
function unfriendUnfriend() {
$("a[title='Unfriend']")[0].click();
setTimeout(unfriendConfirm, 1000);
}
function unfriendConfirm()
{
$("a:contains('confirm')")[0].click();
setTimeout(wipeBlack, 1000);
}
function wipeBlack()
{
$("div[class='modal-backdrop fade in']").remove(); //The black backgrounds would stay like this: http://i.imgur.com/9Ksroda.png
}
function showDeleteFriendOption() {
$("li[id='btnDeleteFriend'").append ( ' \
<button id="removeFriendNormal" type="button">One Click Delete Friend</button> \
' );
$("div[class='split-button end btnDeleteFriend'").append ( ' \
<button id="removeFriendHiddenProfile" type="button">One Click Delete Friend</button> \
' );
$("#removeFriendNormal").click ( function () {
setTimeout(confirmRemoveFriend, 2000);
} );
$("#removeFriendHiddenProfile").click ( function () {
setTimeout(confirmRemoveFriend, 2000);
} );
setTimeout(showManageOption, 500);
}
function showManageOption() {
$("div[class='crewCard featureCard lightCard']").each(function() {
if ($(this).find(".promoteClass").length < 1)
{
var crewID = $(this).children().first().children().first().attr("data-id");
$(this).children().first().children().first().next().children().first().next().next().children().first().after('<br/><button id="promote'+crewID+'" type="button" class="promoteClass"><h6>Manage in this Crew</h6></button> ');
$("[id=promote"+crewID+"]").click ( function () {
var playerName = $("div[class='user-data']").children().first().text();
var crewTag = $(this).parent().children().first().attr("href");
localStorage.setItem("queryPlayer", playerName);
var newWindow = window.open("https://socialclub.rockstargames.com"+crewTag+"/manage/hierarchy");
});
}
});
}
function writeMessage(nameStr, messageStr, kickOrBan) {
$("textarea[name='newMessageTextarea']").text(messageStr); //set message text
$("a[id='btnSend']").click(); //send
if (kickOrBan === "kick")
{
setTimeout(performKick, 1000, nameStr);
}
else
{
setTimeout(performBan, 1000, nameStr);
}
}
function performKick(nameStr) {
$("button:contains('kick')").click();
$("#infoText").text (nameStr + " has been kicked.");
setTimeout(confirmAction, 1500);
}
function performBan(nameStr) {
$("button:contains('ban')").click();
$("#infoText").text (nameStr + " has been banned.");
setTimeout(confirmAction, 1500);
}
function confirmAction()
{
$("a:contains('yes')").click();
setTimeout(wipeBlack, 1000);
}
function beginKickBan(kickOrBan)
{
var nameStr = document.getElementById("name").value;
var messageStr = document.getElementById("message").value;
if (nameStr === "")
{
$("#infoText").text ("Enter a valid name.");
return;
}
if ($("label[for='check_" + nameStr + "']").length) //This is nice - You can actually force the click without having to hit 'Next' to search each page individually! We also look for the checkmark here to be sure we actually have permission to kick/ban them.
{
$("label[for='check_" + nameStr + "']").click(); //Checkmate!
if (!(messageStr === "Optional Message") && !(messageStr === ""))
{
$("i[data-nickname='" + nameStr + "']").click(); //The little dots on the player card
setTimeout(sendMessage, 1500, nameStr, messageStr, kickOrBan);
}
else
{
setTimeout(performKick, 1000, nameStr);
}
}
else
{
$("#infoText").text ("'" + nameStr + "' was not found (or you don't have permission).");
}
}
function toggleCheckMark(nameStr, state)
{
if (nameStr === "")
{
$("#infoText").text ("Enter a valid name.");
return;
}
if ($("label[for='check_" + nameStr + "']").length) //This is nice - You can actually force the click without having to hit 'Next' to search each page individually! We also look for the checkmark here to be sure we actually have permission to kick/ban them.
{
$("label[for='check_" + nameStr + "']").click(); //Checkmate!
if (state === "check")
{
$("#infoText").text ("'" + nameStr + "' has been checkmarked. Use the original SocialClub Kick/Ban/Promote/Demote for this.");
}
else
{
$("#infoText").text ("'" + nameStr + "' has been uncheckmarked.");
}
}
else
{
$("#infoText").text ("'" + nameStr + "' was not found (or you don't have permission).");
}
}
//--- Use jQuery to activate the dialog buttons.
$("#kickButton").click ( function () {
beginKickBan("kick");
} );
$("#CloseDlgBtn").click ( function () {
$("#PopupContainer").hide ();
} );
$("#banButton").click ( function () {
beginKickBan("ban");
} );
$("#messageAll").click ( function () {
var players = new Array();
var enabled = false;
var finalPlayer = "";
var count = 0;
/*
//-----
//http://stackoverflow.com/questions/11003761/notepad-add-to-every-line
var registered = [
"EDDI2142",
"Ganjalo",
"TheTerminat0r"
];
*/
//-----
$("div[title='Deselect']").each(function() {
//players.push($(this).next());
//-----ADVANCED - UNCOMMENT THIS BLOCK AND THE "registered" LIST - ONLY PEOPLE NOT ON THE LIST WILL BE MESSAGED-----
/*
var isRegistered=false;
for(var i=0;i<registered.length;i++) {
if($(this).next().attr("data-nickname")==registered[i])
{
isRegistered=true;
}
}
if(!isRegistered)
{
//players.push($(this).next());
$(this).next().css( "border", "3px solid red" );
}
*/
//-----END ADVANCED-----
//-----NORMAL SECTION-----
if (count < 101 && ((document.getElementById("name").value === "" && !enabled) || (document.getElementById("name").value !== "Enter Name" && $(this).next().attr("data-nickname") === document.getElementById("name").value && !enabled))) //this section is for resuming messaging, if less than NAME then it doesn't include them
{
enabled = true;
players.push($(this).next());
count++;
}
else if (enabled)
{
if (count < 100)
{
players.push($(this).next());
}
else
{
enabled = false;
finalPlayer = $(this).next().attr("data-nickname");
}
count++;
}
//-----END NORMAL SECTION-----
});
messageFromListClickDots(players, finalPlayer);
} );
$("#msgAllFriends").click ( function () {
var players = new Array();
$("i[class='scicon-menu-dots player-card-actions']").each(function() {
players.push($(this));
});
if (players.length != $("div[class='inner clearfix']").children().first().children().first().html().replace(/[{()}]/g, '')) //http://i.imgur.com/TQeGpzd.png
{
$("#infoText").text ("Detected " + players.length + " friends, but you have " + $("div[class='inner clearfix']").children().first().children().first().html().replace(/[{()}]/g, '') + " friends. Please scroll down all the way before beginning messaging");
}
messageFromListClickDots(players, "");
} );
$("#removeAllChecked").click ( function () {
var checkmarkList = new Array();
$("[id^=friendBox]").each(function() {
if($(this).is(':checked'))
{
checkmarkList.push($(this).val());
}
});
removeListOfFriends(checkmarkList);
} );
$("#denyAll").click ( function () {
var denyList = new Array();
$("div[class='scicon-menu-dots player-card-actions']").each(function() {
denyList.push($(this).attr("data-nickname"));
});
denyRequests(denyList);
} );
function confirmRemoveFriend() {
$("a[id='btnConfirm']")[0].click();
}
function denyRequests(denyList) {
if (denyList.length < 1)
{
$("#infoText").text ("Finished with Request Denial.");
return;
}
else
{
$("#infoText").text (denyList.length + " left to deny.");
}
$("[div[data-nickname='" + denyList[0] + "']").click();
setTimeout(denyRequestReject, 4000, denyList);
}
function denyRequestReject(denyList) {
$("a[class='btnRejectFriend rejectRequest']")[0].click();
denyList.shift();
setTimeout(denyRequests, 11500, denyList);
}
function removeListOfFriends(checkmarkList) {
if (checkmarkList.length < 1)
{
$("#infoText").text ("Finished with Friend Removal.");
return;
}
else
{
$("#infoText").text (checkmarkList.length + " left to remove.");
}
if ($("[i[data-nickname='" + checkmarkList[0] + "']").length ) {
$("[i[data-nickname='" + checkmarkList[0] + "']").click();
setTimeout(removeListOfFriendsMore, 2000, checkmarkList);
}
else
{
$('html, body').animate({ scrollTop: $(document).height() }, 250);
setTimeout(removeListOfFriends, 500, checkmarkList);
}
}
function removeListOfFriendsMore(checkmarkList) {
$("a[title='More Options']")[0].click();
setTimeout(removeListOfFriendsDeleteBtn, 2000, checkmarkList);
}
function removeListOfFriendsDeleteBtn(checkmarkList) {
$("a[title='Unfriend']")[0].click();
setTimeout(removeListOfFriendsConfirm, 2000, checkmarkList);
}
function removeListOfFriendsConfirm(checkmarkList) {
$("a[id='btnConfirm']")[0].click();
checkmarkList.shift();
setTimeout(removeListOfFriends, 11000, checkmarkList);
}
function messageFromListClickDots(players, finalPlayer) {
if (players.length < 1)
{
$("#infoText").text ("Done with mass messaging. Enter " + finalPlayer + " to continue where you left off");
return;
}
else
{
$("#infoText").text ("" + players.length + " messages left");
}
var messageStr = document.getElementById("message").value;
if (!(messageStr === "Optional Message") && !(messageStr === ""))
{
players[0].click();
setTimeout(messageFromListClickMessage, 5000, players, finalPlayer);
}
else
{
$("#infoText").text ("Enter a message.");
return;
}
}
function messageFromListClickMessage(players, finalPlayer) {
$("a[title='Message']")[0].click(); //message button
setTimeout(messageFromListWriteMessage, 5000, players, finalPlayer);
}
function messageFromListWriteMessage(players, finalPlayer) {
$("textarea[name='newMessageTextarea']").text(document.getElementById("message").value); //set message text
setTimeout(messageFromListClickSendMessage, 1000, players, finalPlayer);
}
function messageFromListClickSendMessage(players, finalPlayer) {
$("button[id='btnSend']").click(); //send
players.shift();
setTimeout(messageFromListClickDots, 5000, players, finalPlayer);
}
function addDeleteButtons(){
$("i[class='scicon-menu-dots player-card-actions']").each(function() {
if ($(this).find(".removeFriendClass").length < 1) //dont do anything if the player card already has the Delete Friend button
{
$(this).append('<br/><button id="removeFriend'+($(this).attr("data-nickname")).replace(/\./g, "-")+'" type="button" class="removeFriendClass"><h6>Delete Friend</h6></button> ');
$(this).parent().children().first().next().children().first().next().after('<input id="friendBox' + $(this).attr("data-nickname") + '" type="checkbox" value="' + $(this).attr("data-nickname") + '">');
$("[id=removeFriend"+($(this).attr("data-nickname")).replace(/\./g, "-")+"]").click ( function () { //we have to create a button handler for each button directly since we're not adding them all at once.
$(this).parent().children().first().next().next().click();
setTimeout(unfriendMore, 1000);
});
}
});
$("div[class='scicon-menu-dots player-card-actions']").each(function() {
if ($(this).find(".denyFriendClass").length < 1) //dont do anything if the player card already has the Deny Friend button
{
$(this).append('<br/><button id="denyFriend'+($(this).attr("data-nickname")).replace(/\./g, "-")+'" type="button" class="denyFriendClass"><h6>Deny Friend</h6></button> ');
$(this).parent().children().first().next().children().first().next().after('<input id="denyBox' + $(this).attr("data-nickname") + '" type="checkbox" value="' + $(this).attr("data-nickname") + '">');
$("[id=denyFriend"+($(this).attr("data-nickname")).replace(/\./g, "-")+"]").click ( function () { //we have to create a button handler for each button directly since we're not adding them all at once.
//$(this).parent().children().first().next().css( "border", "3px solid red" );
//$(this).parent().children().first().next().next().click();
setTimeout(denyReject, 1000);
});
}
});
}
function denyReject() {
$("a[class='btnRejectFriend rejectRequest']").click();
}
$("#showRemover").click ( function () {
setInterval(addDeleteButtons, 250);
} );
$("#playerPopup").click ( function () {
var nameStr = document.getElementById("name").value;
if (nameStr === "")
{
$("#infoText").text ("Enter a valid name.");
return;
}
if ($("i[data-nickname='" + nameStr + "']").length) //we check for the dots here unlike the check for the checkmark in beginKickBan so that it works for anyone.
{
$("i[data-nickname='" + nameStr + "']").click(); //The little dots on the player card
}
else
{
$("#infoText").text ("'" + nameStr + "' was not found.");
}
} );
$("#listByActive").click ( function () {
var players = new Array();
$("a[class='player-card-actions']").each(function() {
players.push({name: $(this).attr("data-nickname"), val: $(this).parent().next().children().children().first().html()}); //make an object to keep the name+crew linked and sortable.
});
var crewName = $("#hierarchyFilterWrapper div[class='crewTag private']").children().first().html();
$("header").append ( '<div id="PlayerList" style="text-align:center"> ');
for (var i = 0; i < players.length; i++)
{
//name, active crew, and input for the checkbox. Each checkbox is linked to the player for tracking purposes.
if (crewName != players[i].val)
{
$("header").append ( '<h5 id="playerDate" style="color:white;text-align:center"><input id="listBox' + players[i].name + '" type="checkbox" value="' + players[i].name + '">' + players[i].name + ' - ' + players[i].val +'</h5>');
}
}
$("header").append ( '</div>');
$("[id^=listBox]").click ( function () { //This looks for any element starting with listBox, so listBoxUserA and listBox420yoloswagxXx are both hit.
if ( this.checked ) {
toggleCheckMark(this.value, "check");
} else {
toggleCheckMark(this.value, "unchecked");
}
});
} );
$("#denyAllJoin").click ( function () {
var rank5 = new Array();
$("#crewRankWrapper_5 i[class='scicon-menu-dots player-card-actions']").each(function() {
rank5.push($(this).attr("data-nickname"));
});
setTimeout(denyCrewJoinBegin, 1000, rank5, "No linked type specified");
} );
$("#denyAllJoinSparePSN").click ( function () {
var rank5 = new Array();
$("#crewRankWrapper_5 i[class='scicon-menu-dots player-card-actions']").each(function() {
rank5.push($(this).attr("data-nickname"));
});
setTimeout(denyCrewJoinBegin, 1000, rank5, "PSN", 0);
} );
$("#denyAllJoinSpareXbox").click ( function () {
var rank5 = new Array();
$("#crewRankWrapper_5 i[class='scicon-menu-dots player-card-actions']").each(function() {
rank5.push($(this).attr("data-nickname"));
});
setTimeout(denyCrewJoinBegin, 1000, rank5, "XBOX", 0);
} );
function denyCrewJoinBegin(listToDeny, flag, count) {
if (listToDeny.length < 1)
{
$("#infoText").text ("Denied/Accepted all crew join requests.");
return;
}
else if (count > 99)
{
$("#infoText").text ("Denied/Accepted 100 requests (Rockstar limit), refresh the page and reselect.");
return;
}
else
{
$("#infoText").text ("" + listToDeny.length + " left to deny if they do not have a linked account: " + flag);
}
count++;
$("i[data-nickname='"+listToDeny[0]+"'").click();
setTimeout(denyCrewJoinCheckAcceptReject, 5000, listToDeny, flag, count);
}
function denyCrewJoinCheckAcceptReject(listToDeny, flag, count) {
if($("a[title='Reject Crew Request']").length)
{
if($(".accounts " + flag).length)
{
$("a[title='Invite to Crew']")[0].click();
setTimeout(denyCrewJoinCancel, 5000, listToDeny, flag, count);
}
else
{
$("a[title='Reject Crew Request']")[0].click();
setTimeout(denyCrewJoinCancel, 5000, listToDeny, flag, count);
}
}
else
{
$("#infoText").text ("Could not open profile for " + listToDeny[0] + ", it is probably private");
listToDeny.shift();
setTimeout(denyCrewJoinBegin, 5000, listToDeny, flag, count);
}
}
function denyCrewJoinCancel(listToDeny, flag, count) {
$("a[title='Cancel']")[0].click();
listToDeny.shift();
setTimeout(denyCrewJoinBegin, 5500, listToDeny, flag, count);
}
$("#listByRank").click ( function () {
var rank1 = new Array();
var rank2 = new Array();
var rank3 = new Array();
var rank4 = new Array();
$("#crewRankWrapper_1 a[class='player-card-actions']").each(function() {
rank1.push({name: $(this).attr("data-nickname"), val: new Date($(this).parent().next().html().replace('Joined: ',''))});
});
$("#crewRankWrapper_2 a[class='player-card-actions']").each(function() {
rank2.push({name: $(this).attr("data-nickname"), val: new Date($(this).parent().next().html().replace('Joined: ',''))});
});
$("#crewRankWrapper_3 a[class='player-card-actions']").each(function() {
rank3.push({name: $(this).attr("data-nickname"), val: new Date($(this).parent().next().html().replace('Joined: ',''))});
});
$("#crewRankWrapper_4 a[class='player-card-actions']").each(function() {
rank4.push({name: $(this).attr("data-nickname"), val: new Date($(this).parent().next().html().replace('Joined: ',''))});
});
//Skip sorting to keep alhpabetical
$("header").append ( '<div id="PlayerList" style="text-align:center"> ');
$("header").append ( '<hr/ id="playerDate"><h1 id="playerDate" style="color:white;text-align:center">Rank 1</h1><h4 id="playerDate" style="color:white;text-align:center">Select all in this rank: <input id="selectAll" type="checkbox" value="Rank 1"></h4><h4 id="playerDate" style="color:white;text-align:center">Select all with different active crew: <input id="selectDifferentAll" type="checkbox" value="Rank 1"></h4><br/ id="playerDate">'); //Rank 1 + the checkmark for selecting all
for (var i = 0; i < rank1.length; i++)
{
$("header").append ( '<h5 id="playerDate" style="color:white;text-align:center"><input id="listBox' + rank1[i].name + '" type="checkbox" value="' + rank1[i].name + '">' + rank1[i].name + '</h5>'); //player name + checkbox
}
$("header").append ( '<hr/ id="playerDate"><h1 id="playerDate" style="color:white;text-align:center">Rank 2</h1><h4 id="playerDate" style="color:white;text-align:center">Select all in this rank: <input id="selectAll" type="checkbox" value="Rank 2"></h4><h4 id="playerDate" style="color:white;text-align:center">Select all with different active crew: <input id="selectDifferentAll" type="checkbox" value="Rank 2"></h4><br/ id="playerDate">');
for (var i = 0; i < rank2.length; i++)
{
$("header").append ( '<h5 id="playerDate" style="color:white;text-align:center"><input id="listBox' + rank2[i].name + '" type="checkbox" value="' + rank2[i].name + '">' + rank2[i].name + '</h5>');
}
$("header").append ( '<hr/ id="playerDate"><h1 id="playerDate" style="color:white;text-align:center">Rank 3</h1><h4 id="playerDate" style="color:white;text-align:center">Select all in this rank: <input id="selectAll" type="checkbox" value="Rank 3"></h4><h4 id="playerDate" style="color:white;text-align:center">Select all with different active crew: <input id="selectDifferentAll" type="checkbox" value="Rank 3"></h4><br/ id="playerDate">');
for (var i = 0; i < rank3.length; i++)
{
$("header").append ( '<h5 id="playerDate" style="color:white;text-align:center"><input id="listBox' + rank3[i].name + '" type="checkbox" value="' + rank3[i].name + '">' + rank3[i].name + '</h5>');
}
$("header").append ( '<hr/ id="playerDate"><h1 id="playerDate" style="color:white;text-align:center">Rank 4</h1><h4 id="playerDate" style="color:white;text-align:center">Select all in this rank: <input id="selectAll" type="checkbox" value="Rank 4"></h4><h4 id="playerDate" style="color:white;text-align:center">Select all with different active crew: <input id="selectDifferentAll" type="checkbox" value="Rank 4"></h4><br/ id="playerDate">');
for (var i = 0; i < rank4.length; i++)
{
$("header").append ( '<h5 id="playerDate" style="color:white;text-align:center"><input id="listBox' + rank4[i].name + '" type="checkbox" value="' + rank4[i].name + '">' + rank4[i].name + '</h5>');
}
$("header").append ( '</div>');
$("#infoText").text ("Rank List generated.");
$("[id^=listBox]").click ( function () { //indivudual player checkboxes again
if ( this.checked ) {
toggleCheckMark(this.value, "check");
} else {
toggleCheckMark(this.value, "unchecked");
}
});
$("[id^=selectAll]").click ( function () { //the checkboxes for selecting all players in a rank
var rankToUse = this.value.replace('Rank ',''); //convert the value to just the number
if ( this.checked ) {
$("#crewRankWrapper_"+rankToUse+" a[class='player-card-actions']").each(function() { //go through each player and checkem
//-----ADVANCED - UNCOMMENT THIS BLOCK AND COMMENT NORMAL BLOCK TO SELECT PLAYERS *NOT* ON THE "registered" LIST-----
/*var registered = [
"name1",
"name2",
"name3"
];
var isRegistered=false;
for(var i=0;i<registered.length;i++) {
if($(this).attr("data-nickname").toUpperCase()==registered[i].toUpperCase())
{
isRegistered=true;
}
}
if(!isRegistered)
{
toggleCheckMark($(this).attr("data-nickname"), "check");
}
*/
//-----END ADVANCED-----
//-----NORMAL-----
toggleCheckMark($(this).attr("data-nickname"), "check");
//-----END NORMAL-----
});
$("#infoText").text ("All of " + this.value + " has been checkmarked. Use the normal SocialClub Kick/Ban/Promote/Demote options.");
} else {
$("#crewRankWrapper_"+rankToUse+" a[class='player-card-actions']").each(function() {
toggleCheckMark($(this).attr("data-nickname"), "unchecked");
});
$("#infoText").text ("All of " + this.value + " has been unchecked.");
}
});
$("[id^=selectDifferentAll]").click ( function () { //the checkboxes for selecting all players in a rank
var rankToUse = this.value.replace('Rank ',''); //convert the value to just the number
var crewName = $("#hierarchyFilterWrapper div[class='crewTag private']").children().first().html();
if ( this.checked ) {
$("#crewRankWrapper_"+rankToUse+" a[class='player-card-actions']").each(function() { //go through each player and checkem
$(this).parent().next().children().first().children().first().css( "border", "3px solid red" );
if (crewName != $(this).parent().next().children().first().children().first().html())
{
toggleCheckMark($(this).attr("data-nickname"), "check");
}
});
$("#infoText").text ("All of " + this.value + " with a different active crew has been checkmarked. Use the normal SocialClub Kick/Ban/Promote/Demote options.");
} else {
$("#crewRankWrapper_"+rankToUse+" a[class='player-card-actions']").each(function() {
if (crewName != $(this).parent().next().children().first().children().first().html())
{
toggleCheckMark($(this).attr("data-nickname"), "unchecked");
}
});
$("#infoText").text ("All of " + this.value + " with a different active crew has been unchecked.");
}
});
} );
$("#CloseListBtn").click ( function () {
$("*#playerDate").remove(); //This ends up removing every listing (*) related to either list based off playerDate being in the ID for each.
$("#infoText").text ("List hidden.");
} );