-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
GiveawayCompanion.user.js
4055 lines (3330 loc) · 135 KB
/
GiveawayCompanion.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 Giveaway Companion
// @description Saves your time on games giveaway sites
// @description:ru Экономит ваше время на сайтах с раздачами игр
// @author longnull
// @namespace longnull
// @version 1.7.6
// @homepage https://github.com/longnull/GiveawayCompanion
// @supportURL https://github.com/longnull/GiveawayCompanion/issues
// @updateURL https://raw.githubusercontent.com/longnull/GiveawayCompanion/master/GiveawayCompanion.user.js
// @downloadURL https://raw.githubusercontent.com/longnull/GiveawayCompanion/master/GiveawayCompanion.user.js
// @match *://*.grabfreegame.com/giveaway/*
// @match *://*.bananatic.com/*/giveaway/*
// @match *://*.gamingimpact.com/giveaway/*
// @match *://*.whosgamingnow.net/giveaway/*
// @match *://*.gamehag.com/*
// @match *://*.gleam.io/*/*
// @match *://*.giveaway.su/giveaway/view/*
// @match *://*.keyjoker.com/*
// @match *://*.key-hub.eu/giveaway/*
// @match *://*.givee.club/*/event/*
// @match *://*.opquests.com/*
// @connect steamcommunity.com
// @connect grabfreegame.com
// @connect bananatic.com
// @connect gamingimpact.com
// @connect *
// @grant GM_setValue
// @grant GM.setValue
// @grant GM_getValue
// @grant GM.getValue
// @grant GM_xmlhttpRequest
// @grant GM.xmlHttpRequest
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js
// ==/UserScript==
(async () => {
'use strict';
const version = {
string: '1.7.6',
changes: {
default:
`<ul>
<li>Steam: fixed loading of tasks related to games</li>
<li>Removed support for key.gift</li>
<li>Removed support for chubkeys.com</li>
</ul>`,
ru:
`<ul>
<li>Steam: исправлена загрузка заданий связанных с играми</li>
<li>Удалена поддержка key.gift</li>
<li>Удалена поддержка chubkeys.com</li>
</ul>`
}
};
const config = {
// Output debug info into console (false - disabled, true - enabled)
// Выводить отладочную информацию в консоль (false - выключено, true - включено)
debug: false,
// Features related to Steam groups (false - disabled, true - enabled)
// Функционал связанный с группами Steam (false - выключено, true - включено)
steamGroups: true,
// Features related to Steam wishlist (false - disabled, true - enabled)
// Функционал связанный со списком желаемого Steam (false - выключено, true - включено)
steamAppWishlist: true,
// Features related to application following in Steam (false - disabled, true - enabled)
// Функционал связанный с подпиской на приложения в Steam (false - выключено, true - включено)
steamAppFollow: true,
// Features related to adding an application to Steam library (false - disabled, true - enabled)
// Функционал связанный с добавлением приложения в библиотеку Steam (false - выключено, true - включено)
steamAppAddToLibrary: true,
// Size of the buttons (pixels)
// Размер кнопок (пиксели)
buttonsSize: 40,
notifications: {
// Maximum number of notifications
// Максимальное количество уведомлений
maxCount: 5,
// Newest notifications on top (false - disabled, true - enabled)
// Новые уведомления вверху (false - выключено, true - включено)
newestOnTop: false,
// Notifications width (pixels)
// Ширина уведомлений (пиксели)
width: 400,
// How long the notification will display without user interaction (milliseconds, 0 - infinite, can be overridden)
// Как долго будет отображаться уведомление без пользовательского взаимодействия (миллисекунды, 0 - бесконечно, может быть переопределено)
timeout: 10000,
// How long the notification will display after the user moves the mouse out of timed out notification (milliseconds)
// Как долго будет отображаться "просроченное" уведомление после того, как пользователь убрал курсор (миллисекунды)
extendedTimeout: 3000,
// Close notification on click (can be overridden)
// Закрывать уведомление по клику (может быть переопределено)
closeOnClick: false
},
// Sites settings
// Настройки сайтов
sitesConfig: {
// Settings for Gleam
// Настройки для Gleam
gleam: {
// Completion of tasks that require input from the user
// Выполнение заданий, требующих ввода от пользователя
answerQuestions: {
// false - disabled, true - enabled
// false - выключено, true - включено
enabled: false,
// Text
// Текст
answer: 'Yes'
},
// Completion of tasks that require a correct answer from the user (client-side verification)
// Выполнение заданий, требующих правильного ответа от пользователя (проверка на стороне клиента)
answerQuestionsWithCheck: {
// false - disabled, true - enabled
// false - выключено, true - включено
enabled: false
},
// Fill in username in Twitter tasks
// Заполнить имя пользователя в Twitter заданиях
twitterSetUsername: {
// false - disabled, true - enabled
// false - выключено, true - включено
enabled: false,
// Username (if empty, the script will take the username from the email)
// Имя (если пусто, то скрипт возьмёт имя из email)
username: ''
},
// Fill in username in TikTok tasks
// Заполнить имя пользователя в TikTok заданиях
tiktokSetUsername: {
// false - disabled, true - enabled
// false - выключено, true - включено
enabled: false,
// Username (if empty, the script will take the username from the email)
// Имя (если пусто, то скрипт возьмёт имя из email)
username: ''
},
}
},
sites: [
{
host: ['grabfreegame.com', 'bananatic.com', 'gamingimpact.com'],
element: 'a[href*="logout"]',
steamKeys: '.code:visible',
conditions: [
{
element: '.tasks li:has(.banicon-steam2)',
steamGroups() {
const tasks = $J('.tasks li:has(.banicon-steam2) .buttons button:first-child');
const groups = [];
for (const task of tasks) {
const val = $J(task).attr('onclick');
if (val) {
const url = val.match(/'(.+)'/);
if (url) {
groups.push(url[1]);
}
}
}
return groups;
}
},
{
element: '.tasks li:not(:has(.completed)):not(:has(.banicon-twitter)):not(.tasks li:has(.banicon-youtube):not(:has([data-ytid])))',
buttons: [
{
type: 'tasks',
cancellable: true,
click(params) {
const tasks = $J(params.self.element);
log.debug(`tasks found : ${tasks.length}`);
if (tasks.length) {
return new Promise(async (resolve) => {
let done = 0;
for (let i = 0; i < tasks.length; i++) {
if (params.cancelled) {
log.debug('cancelled');
break;
}
const buttons = $J(tasks.get(i)).find('.buttons button');
if (buttons.length < 2) {
continue;
}
if (!$J(buttons.get(0)).attr('data-ytid')) {
const val = $J(buttons.get(0)).attr('onclick');
if (val) {
let url = val.match(/'(.+)'/);
if (!url) {
log.debug(`${i + 1} : cannot extract url : ${val}`);
continue;
}
url = url[1];
log.debug(`${i + 1} : making action request to ${url}`);
try {
await $J.get(url);
} catch (e) {}
}
}
const val = $J(buttons.get(1)).attr('onclick');
if (val) {
let url = val.match(/'(.+)'/);
if (!url) {
log.debug(`${i + 1} : cannot extract url : ${val}`);
continue;
}
url = url[1];
log.debug(`${i + 1} : making verify request to ${url}`);
try {
await $J.get(url);
} catch (e) {}
}
params.button.progress(tasks.length, i + 1);
done++;
log.debug(`${i + 1} : done`);
}
if (done) {
notifications.success(i18n.get('reload-to-see-changes'), {timeout: 0});
}
resolve();
});
}
}
}
]
}
]
},
{
host: 'whosgamingnow.net',
element: 'a[href*="logout"]',
steamKeys: '.SteamKey:visible',
steamGroups: '.action[href*="steamcommunity.com/groups/"]',
conditions: [
{
element: '.action:not(:has(.fa-check-square-o))',
buttons: [
{
type: 'tasks',
click(params) {
const tasks = unsafeWindow.$(params.self.element);
log.debug(`tasks found : ${tasks.length}`);
tasks.trigger('click');
}
}
]
}
]
},
{
host: 'gamehag.com',
console: true,
element: '!#login-tools',
steamKeys: '.response-key .code-text:visible',
conditions: [
{
path: /\/giveaway\//,
steamKeys: '.giveaway-key input:visible%val',
steamGroups() {
const groups = [];
$J('.single-giveaway-task').each((i, el) => {
const href = $J(el).find('.task-icon use').attr('xlink:href');
if (href && href.includes('nc-logo-steam')) {
const url = $J(el).find('.task-actions a').attr('href');
if (url) {
groups.push(url);
}
}
});
return groups;
},
conditions: [
{
elementAnd: ['.single-giveaway-task:has(.notdone):has(.task-actions a):has(.task-actions button),.single-giveaway-task:has(.notdone):has(.task-actions .giveaway-survey)', '!.giveaway-content .alert-danger:visible', '!.giveaway-key input:visible'],
buttons: [
{
type: 'tasks',
cancellable: true,
click(params) {
const tasks = $J(params.self.elementAnd[0]);
log.debug(`tasks found : ${tasks.length}`);
if (tasks.length) {
return new Promise((resolve) => {
const completeTask = async (el) => {
const task = $J(el);
const action = task.find('.task-actions a');
const verify = task.find('.task-actions button');
if (action.length && verify.length) {
let href = action.attr('href');
log.debug(`${i + 1} : completeTask() : making action request : ${href}`);
try {
let response = await $J.get(href);
let lnk = $J(response.content).find('.game-list .col:not(:first-child) .game-tile .actions .btn-primary');
if (lnk.length) {
href = lnk.attr('href');
log.debug(`${i + 1} : completeTask() : it looks like a "play game" task, making "/play" request : ${href}`);
response = await $J.get(href);
log.debug(`${i + 1} : completeTask() : "/play" request done`);
lnk = $J(response).find('#single-game-play');
if (lnk.length) {
href = lnk.attr('href');
log.debug(`${i + 1} : completeTask() : making "/redirect" request : ${href}`);
await $J.get(href);
log.debug(`${i + 1} : completeTask() : "/redirect" request done`);
}
}
} catch (e) {}
log.debug(`${i + 1} : completeTask() : clicking verify button...`);
verify.trigger('click');
} else {
const survey = task.find('.task-actions .giveaway-survey');
if (survey.length) {
const id = survey.attr('data-task_id');
if (id) {
log.debug(`${i + 1} : completeTask() : survey task : ${id}`);
unsafeWindow.currentSurveyId = id;
unsafeWindow.giveawaySurvCompleted();
}
}
}
};
let i = 0;
const ajaxComplete = (e, xhr, settings) => {
if (settings.url.includes('/giveaway/sendtask')) {
log.debug(`${i + 1} : ajaxComplete() : /giveaway/sendtask`);
i++;
params.button.progress(tasks.length, i);
if (i >= tasks.length) {
log.debug('all tasks done');
unsafeWindow.$(document).unbind('ajaxComplete', ajaxComplete);
return resolve();
}
if (params.cancelled) {
log.debug('cancelled');
unsafeWindow.$(document).unbind('ajaxComplete', ajaxComplete);
return resolve();
}
completeTask(tasks.get(i));
}
};
unsafeWindow.$(document).ajaxComplete(ajaxComplete);
completeTask(tasks.get(i));
});
}
}
}
]
}
]
}
]
},
{
host: 'gleam.io',
check(params) {
const container = $J('.popup-blocks-container');
if (!container.length) {
return false;
}
params.self._gleam = unsafeWindow.angular.element(container.get(0)).scope();
return !!params.self._gleam;
},
ready(params) {
for (const entry of params.self._gleam.entry_methods) {
if (params.self._gleam.isTimerAction(entry)) {
entry.timePassed = true;
}
}
},
steamKeys(params) {
return params.self._gleam.bestCouponCode();
},
steamGroups(params) {
const groups = [];
for (const entry of params.self._gleam.entry_methods) {
if (entry.entry_type === 'steam_join_group') {
groups.push(entry.config3);
}
}
return groups;
},
conditions: [
{
getEntries(params) {
return $J('.entry-method:visible:not(.completed-entry-method)').filter((i, e) => {
const scope = unsafeWindow.angular.element(e).scope();
return scope &&
params.site._gleam.canEnter(scope.entry_method) &&
!params.site._gleam.isEntered(scope.entry_method) &&
params.site._gleam.enoughUserDetails(scope.entry_method) &&
(/(custom_action|_view|_visit|blog_comment|twitter_tweet|twitter_retweet|twitter_follow|tiktok_visit|tiktok_follow)/.test(scope.entry_method.entry_type) || (
params.site._gleam.enoughEntryDetails(scope.entry_method) &&
(!scope.entry_method.requires_authentication || params.site._gleam.isAuthenticated(scope.entry_method, scope.entry_method.provider))
));
});
},
check(params) {
return params.site._gleam.contestantState.contestant.id &&
!params.site._gleam.bestCouponCode() &&
params.self.getEntries(params).length;
},
buttons: [
{
type: 'tasks',
cancellable: true,
click(params) {
const tasks = params.self.getEntries(params);
log.debug(`tasks found : ${tasks.length}`);
if (tasks.length) {
return new Promise(async (resolve) => {
const emailName = params.site._gleam.contestantState.contestant.email.match(/[^@]+/)[0].replace(/[\.\+]/g, '_').slice(-15);
for (let i = 0; i < tasks.length; i++) {
if (params.cancelled) {
log.debug('cancelled');
return resolve();
}
if (params.site._gleam.bestCouponCode()) {
log.debug('key is available');
return resolve();
}
const scope = unsafeWindow.angular.element(tasks[i]).scope();
try {
if (/(custom_action|_view|_visit|blog_comment|tiktok_visit|tiktok_follow)/.test(scope.entry_method.entry_type)) {
log.debug(`${i + 1} : visit :`, scope.entry_method.action_description);
params.site._gleam.triggerVisit(scope.entry_method);
await utils.sleep(300);
}
if ((scope.entry_method.entry_type === 'custom_action' && /(Ask a question|Allow question or tracking)/.test(scope.entry_method.method_type)) ||
scope.entry_method.entry_type === 'blog_comment' || scope.entry_method.config3 === 'Question' || scope.entry_method.config5 === 'Question'
) {
let answer;
if (scope.entry_method.config5 === '1') {
if (config.sitesConfig.gleam.answerQuestionsWithCheck.enabled) {
answer = decodeURIComponent(atob(scope.entry_method.config8).replace(/\+/g, ' ')).split(/\r|\n/).find((v) => !!v);
}
} else if (config.sitesConfig.gleam.answerQuestions.enabled && config.sitesConfig.gleam.answerQuestions.answer) {
answer = config.sitesConfig.gleam.answerQuestions.answer;
}
if (answer) {
log.debug(`${i + 1} : details :`, answer, ':', scope.entry_method.action_description);
params.site._gleam.entryDetailsState[scope.entry_method.id] = answer;
params.site._gleam.entryState.formData[scope.entry_method.id] = answer;
}
}
if (scope.entry_method.entry_type === 'tiktok_follow' && config.sitesConfig.gleam.tiktokSetUsername.enabled &&
!params.site._gleam.entryState.formData[scope.entry_method.id]
) {
const tiktokName = config.sitesConfig.gleam.tiktokSetUsername.username ? config.sitesConfig.gleam.tiktokSetUsername.username : emailName;
log.debug(`${i + 1} : tiktok username :`, tiktokName, ':', scope.entry_method.action_description);
params.site._gleam.entryDetailsState[scope.entry_method.id] = tiktokName;
params.site._gleam.entryState.formData[scope.entry_method.id] = tiktokName;
}
if (/(twitter_tweet|twitter_retweet|twitter_follow)/.test(scope.entry_method.entry_type)) {
log.debug(`${i + 1} : twitter attempt :`, scope.entry_method.action_description);
params.site._gleam.attemptEntry(scope.entry_method);
await utils.sleep(200);
if (config.sitesConfig.gleam.twitterSetUsername.enabled && !params.site._gleam.entryState.formData[scope.entry_method.id]) {
const twitterName = config.sitesConfig.gleam.twitterSetUsername.username ? config.sitesConfig.gleam.twitterSetUsername.username : emailName;
log.debug(`${i + 1} : twitter username :`, twitterName, ':', scope.entry_method.action_description);
scope.entry_method.show_extra = true;
params.site._gleam.entryDetailsState[scope.entry_method.id] = {twitter_username: twitterName};
params.site._gleam.entryState.formData[scope.entry_method.id] = {twitter_username: twitterName};
}
}
if (params.site._gleam.enoughEntryDetails(scope.entry_method) &&
(!scope.entry_method.requires_authentication || params.site._gleam.isAuthenticated(scope.entry_method, scope.entry_method.provider))
) {
log.debug(`${i + 1} : confirm :`, scope.entry_method.action_description);
params.site._gleam.resumeEntry(scope.entry_method);
while (scope.entry_method.entering) {
await utils.sleep(500);
}
}
} catch (e) {
log.debug(`${i + 1} : task error :`, e);
}
params.button.progress(tasks.length, i + 1);
}
log.debug('all tasks done');
resolve();
});
}
}
}
]
}
]
},
{
host: 'giveaway.su',
element: 'a[href*="logout"]',
steamKeys: '.giveaway-key input%val',
steamGroups() {
const groups = [];
$J('#actions tr:has(.fa-steam-symbol)').each((i, el) => {
const btn = $J(el).find('button[data-type="action.universal"]');
if (btn.length) {
const action = JSON.parse(window.atob(btn.attr('data-action')));
if (action.task.includes('steamcommunity.com/groups/') || action.task.includes('bit.ly/')) {
groups.push(action.task);
}
}
});
return groups;
}
},
{
host: 'keyjoker.com',
element: 'a[href*="logout"]',
conditions: [
{
path: /^\/entries/,
steamGroups: '.list-complete-item:has(.fa-steam) a.btn-primary',
conditions: [
{
element: '.list-complete-item button',
buttons: [
{
type: 'tasks',
cancellable: true,
click(params) {
const tasks = $J(params.self.element);
log.debug(`tasks found : ${tasks.length}`);
if (tasks.length) {
return new Promise(async (resolve) => {
document.cookie = 'fraud_warning_notice=1; expires=Sun, 1 Jan 2030 00:00:00 UTC; path=/';
for (let i = 0; i < tasks.length; i++) {
if (params.cancelled) {
break;
}
log.debug(`${i + 1} : click`);
tasks.get(i).click();
await utils.sleep(200);
await utils.waitForElement('.list-complete-item button .spinner-border', false);
log.debug(`${i + 1} : task done`);
params.button.progress(tasks.length, i + 1);
}
if (params.cancelled) {
log.debug('cancelled');
} else {
log.debug('all tasks done');
}
resolve();
});
}
}
}
]
}
]
},
{
path: /^\/account\/keys/,
steamKeys: '[id^="key-"]',
ready() {
$J('.card-body .col-auto img').on('click', (e) => {
const key = steam.extractKeys($J(e.currentTarget).parents('.card-body').find('[id^="key-"]').text());
if (key) {
steam.openKeyActivationPage(key[0]);
}
});
$J('head').append(
`<style>
.card-body .col-auto img {
cursor: pointer;
}
</style>`
);
}
}
]
},
{
host: 'key-hub.eu',
element: 'a[href*="logout"]',
steamGroups: ['.task a[href*="steamcommunity.com/gid/"]', '.task a[href*="steamcommunity.com/groups/"]'],
steamAppWishlist: '.task a[href*="store.steampowered.com/app/"]',
conditions: [
{
element: '.task:not(:has(.task-result.fa-check-circle[style*="display: flex"])) a[href*="/away?data="]',
buttons: [
{
type: 'tasks',
cancellable: true,
click(params) {
const tasks = $J(params.self.element);
log.debug(`tasks found : ${tasks.length}`);
if (tasks.length) {
return new Promise(async (resolve) => {
for (let i = 0; i < tasks.length; i++) {
if (params.cancelled) {
break;
}
const url = $J(tasks.get(i)).attr('href');
log.debug(`${i + 1} : making request : ${url}`);
try {
await $J.get(url);
} catch (e) {}
log.debug(`${i + 1} : task done`);
params.button.progress(tasks.length, i + 1);
}
if (params.cancelled) {
log.debug('cancelled');
} else {
log.debug('all tasks done');
}
resolve();
});
}
}
}
]
}
]
},
{
host: 'givee.club',
element: 'a[href*="logout"]',
steamGroups: '.event-actions tr:has(.fa-steam-symbol) .event-action-label a:not([href*="#"])',
steamAppWishlist: ['.event-actions tr:has(.fa-plus-circle) .event-action-label a:not([href*="#"])', '.event-actions tr:has(.fa-plus-circle) .event-action-label a[href="#"]@data-steam-wishlist-appid'],
steamAppFollow: '.event-actions tr:has(.fa-heart) .event-action-label a:not([href*="#"])',
conditions: [
{
element: '.event-action-buttons .glyphicon-refresh',
buttons: [
{
type: 'tasks',
cancellable: true,
click(params) {
const tasks = $J(params.self.element);
log.debug(`tasks found : ${tasks.length}`);
if (tasks.length) {
return new Promise(async (resolve) => {
for (let i = 0; i < tasks.length; i++) {
if (params.cancelled) {
break;
}
log.debug(`${i + 1} : click`);
const task = tasks.get(i);
task.click();
await utils.waitForElement('.event-action-checking .glyphicon-refresh', false, false, task.parent);
log.debug(`${i + 1} : task done`);
params.button.progress(tasks.length, i + 1);
}
if (params.cancelled) {
log.debug('cancelled');
} else {
log.debug('all tasks done');
}
resolve();
});
}
}
}
]
}
]
},
{
host: 'opquests.com',
element: 'form[action*="logout"]',
conditions: [
{
path: /^\/quests\//,
steamGroups: '.items-center:has(.fa-users):has(.submit-loader) a[href*="steamcommunity.com/groups/"]',
steamAppWishlist: '.items-center:has(.fa-list):has(.submit-loader) a[href*="store.steampowered.com/app/"]',
steamAppFollow: '.items-center:has(.fa-gamepad):has(.submit-loader) a[href*="store.steampowered.com/app/"]',
steamAppAddToLibrary: '.items-center:has(.fa-plus-square):has(.submit-loader) a[href*="store.steampowered.com/app/"]',
conditions: [
{
element: '.items-center .submit-loader',
buttons: [
{
type: 'tasks',
cancellable: true,
click(params) {
const tasks = $J(params.self.element);
log.debug(`tasks found : ${tasks.length}`);
if (tasks.length) {
return new Promise(async (resolve) => {
const m = window.location.pathname.match(/\/quests\/(\d+)/);
log.debug('making confirm request');
try {
await $J.get(`https://opquests.com/quests/${m[1]}?confirm=1`);
} catch (e) {}
let done = 0;
for (let i = 0; i < tasks.length; i++) {
if (params.cancelled) {
break;
}
const task = $J(tasks.get(i));
const token = task.parent().find('input[name="_token"]').val();
const taskId = task.parent().find('input[name="task_id"]').val();
log.debug(`${i + 1} : making request`);
try {
await $J.post('https://opquests.com/entries', {_token: token, task_id: taskId});
} catch (e) {}
params.button.progress(tasks.length, i + 1);
done++;
log.debug(`${i + 1} : done`);
}
if (params.cancelled) {
log.debug('cancelled');
} else {
log.debug('all tasks done');
}
if (done) {
notifications.success(i18n.get('reload-to-see-changes'), {timeout: 0});
}
resolve();
});
}
}
}
]
}
]
},
{
path: /^\/keys/,
steamKeys: ['button[data-clipboard-text]@data-clipboard-text', '.w-full .mb-2'],
ready() {
const imgs = $J('.items-center .p-4 img');
if (imgs.length) {
imgs.on('click', (e) => {
steam.openKeyActivationPage($J(e.currentTarget).parents('.items-center').find('.mb-2:nth-child(2)').text().trim());
});
$J('head').append(
`<style>
.items-center .p-4 img {
cursor: pointer;
}
</style>`
);
}
}
},
]
}
]
};
// https://materialdesignicons.com
const icons = {
checkmark: '<svg viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" /></svg>',
key: '<svg viewBox="0 0 24 24"><path d="M7,14A2,2 0 0,1 5,12A2,2 0 0,1 7,10A2,2 0 0,1 9,12A2,2 0 0,1 7,14M12.65,10C11.83,7.67 9.61,6 7,6A6,6 0 0,0 1,12A6,6 0 0,0 7,18C9.61,18 11.83,16.33 12.65,14H17V18H21V14H23V10H12.65Z" /></svg>',
group: '<svg viewBox="0 0 24 24"><path d="M19 17V19H7V17S7 13 13 13 19 17 19 17M16 8A3 3 0 1 0 13 11A3 3 0 0 0 16 8M19.2 13.06A5.6 5.6 0 0 1 21 17V19H24V17S24 13.55 19.2 13.06M18 5A2.91 2.91 0 0 0 17.11 5.14A5 5 0 0 1 17.11 10.86A2.91 2.91 0 0 0 18 11A3 3 0 0 0 18 5M8 10H5V7H3V10H0V12H3V15H5V12H8Z" /></svg>',
wishlist: '<svg viewBox="0 0 24 24"><path d="M17,14H19V17H22V19H19V22H17V19H14V17H17V14M5,3H19C20.11,3 21,3.89 21,5V12.8C20.39,12.45 19.72,12.2 19,12.08V5H5V19H12.08C12.2,19.72 12.45,20.39 12.8,21H5C3.89,21 3,20.11 3,19V5C3,3.89 3.89,3 5,3M7,7H17V9H7V7M7,11H17V12.08C16.15,12.22 15.37,12.54 14.68,13H7V11M7,15H12V17H7V15Z" /></svg>',
follow: '<svg viewBox="0 0 24 24"><path d="M23.5 17L18.5 22L15 18.5L16.5 17L18.5 19L22 15.5L23.5 17M22 13.5L22 13.8C21.37 13.44 20.67 13.19 19.94 13.07C19.75 12.45 19.18 12 18.5 12H17V7H12V5.5C12 4.67 11.33 4 10.5 4C9.67 4 9 4.67 9 5.5V7H4L4 9.12C5.76 9.8 7 11.5 7 13.5C7 15.5 5.75 17.2 4 17.88V20H6.12C6.8 18.25 8.5 17 10.5 17C11.47 17 12.37 17.3 13.12 17.8L13 19C13 20.09 13.29 21.12 13.8 22H13.2V21.7C13.2 20.21 12 19 10.5 19C9 19 7.8 20.21 7.8 21.7V22H4C2.9 22 2 21.1 2 20V16.2H2.3C3.79 16.2 5 15 5 13.5C5 12 3.79 10.8 2.3 10.8H2V7C2 5.9 2.9 5 4 5H7.04C7.28 3.3 8.74 2 10.5 2C12.26 2 13.72 3.3 13.96 5H17C18.1 5 19 5.9 19 7V10.04C20.7 10.28 22 11.74 22 13.5Z" /></svg>',
library: '<svg viewBox="0 0 24 24"><path d="M13 3V11H21V3H13M3 21H11V13H3V21M3 3V11H11V3H3M13 16H16V13H18V16H21V18H18V21H16V18H13V16Z" /></svg>',
cancel: '<svg viewBox="0 0 24 24"><path d="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12C4,13.85 4.63,15.55 5.68,16.91L16.91,5.68C15.55,4.63 13.85,4 12,4M12,20A8,8 0 0,0 20,12C20,10.15 19.37,8.45 18.32,7.09L7.09,18.32C8.45,19.37 10.15,20 12,20Z" /></svg>',
success: '<svg viewBox="0 0 24 24"><path d="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4M11,16.5L6.5,12L7.91,10.59L11,13.67L16.59,8.09L18,9.5L11,16.5Z" /></svg>',
info: '<svg viewBox="0 0 24 24"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z" /></svg>',
info2: '<svg viewBox="0 0 24 24"><path d="M13.5,4A1.5,1.5 0 0,0 12,5.5A1.5,1.5 0 0,0 13.5,7A1.5,1.5 0 0,0 15,5.5A1.5,1.5 0 0,0 13.5,4M13.14,8.77C11.95,8.87 8.7,11.46 8.7,11.46C8.5,11.61 8.56,11.6 8.72,11.88C8.88,12.15 8.86,12.17 9.05,12.04C9.25,11.91 9.58,11.7 10.13,11.36C12.25,10 10.47,13.14 9.56,18.43C9.2,21.05 11.56,19.7 12.17,19.3C12.77,18.91 14.38,17.8 14.54,17.69C14.76,17.54 14.6,17.42 14.43,17.17C14.31,17 14.19,17.12 14.19,17.12C13.54,17.55 12.35,18.45 12.19,17.88C12,17.31 13.22,13.4 13.89,10.71C14,10.07 14.3,8.67 13.14,8.77Z" /></svg>',
warning: '<svg viewBox="0 0 24 24"><path d="M11,15H13V17H11V15M11,7H13V13H11V7M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20Z" /></svg>',
error: '<svg viewBox="0 0 24 24"><path d="M12,2L1,21H23M12,6L19.53,19H4.47M11,10V14H13V10M11,16V18H13V16" /></svg>',
close: '<svg viewBox="0 0 24 24"><path d="M19,3H16.3H7.7H5A2,2 0 0,0 3,5V7.7V16.4V19A2,2 0 0,0 5,21H7.7H16.4H19A2,2 0 0,0 21,19V16.3V7.7V5A2,2 0 0,0 19,3M15.6,17L12,13.4L8.4,17L7,15.6L10.6,12L7,8.4L8.4,7L12,10.6L15.6,7L17,8.4L13.4,12L17,15.6L15.6,17Z" /></svg>'
};
const i18n = {
format(str, vars) {
const replaceStringIds = (s) => {
return s.replace(/\[([a-z0-9\-]+)\]/g, (m, id) => {
return this.lang[id] ? replaceStringIds(this.lang[id]) : m;
});
};
str = replaceStringIds(str);
if (typeof vars === 'object') {
Object.keys(vars).forEach((item) => {
str = str.replace(new RegExp(`{${item}}`, 'g'), utils.encodeEntities(vars[item]));
});
}
return str;
},
get(id, vars) {
if (!this.lang) {
return;
}
let res = this.lang[id];
if (typeof res === 'undefined' && this.lang !== this.langs.default) {
res = this.langs.default[id];
}
return this.format(res, vars);
},
lang: null,
langs: {
default: {
'confirm-tasks': 'Confirm tasks',
'cancel': 'Cancel',
'useful-info': 'Useful information',
'reload-to-see-changes': '<a href="javascript:window.location.reload(false)">Reload</a> the page to see changes.',
'steam-activate-key': 'Open Steam key activation page ({key})',
'steam-loading-tasks': 'Loading Steam tasks...',
'steam-group-join': 'Join Steam group "{group}" (Ctrl+Click - open the group in a new tab)',
'steam-group-leave': 'Leave Steam group "{group}" (Ctrl+Click - open the group in a new tab)',
'steam-init-groups-request-failed': 'Failed to load <a href="https://steamcommunity.com/my/groups" target="_blank">your groups</a>. <a href="https://steamcommunity.com" target="_blank">Steam Community</a> is probably down.',
'steam-init-store-request-failed': 'Failed to get information from your Steam account. <a href="https://store.steampowered.com" target="_blank">Steam Store</a> is probably down.',
'steam-join-group-failed': 'Failed to join the <a href="{groupLink}" target="_blank">group</a>. <a href="https://steamcommunity.com" target="_blank">Steam Community</a> is probably experiencing some issues.',
'steam-join-group-join-request-sent': 'Join request sent. To join the <a href="{groupLink}" target="_blank">group</a>, your join request must be approved by the group administrator.',
'steam-join-group-not-logged': 'Failed to join the <a href="{groupLink}" target="_blank">group</a>. [steam-community-not-logged]',
'steam-join-group-not-found': 'Failed to join the <a href="{groupLink}" target="_blank">group</a>. Looks like the group does not exist.',
'steam-leave-group-failed': 'Failed to leave the <a href="{groupLink}" target="_blank">group</a>. <a href="https://steamcommunity.com" target="_blank">Steam Community</a> is probably experiencing some issues.',
'steam-leave-group-not-logged': 'Failed to leave the <a href="{groupLink}" target="_blank">group</a>. [steam-community-not-logged]',
'steam-app-wishlist-add': 'Add game #{appId} to Steam wishlist (Ctrl+Click - open the game in a new tab)',
'steam-app-wishlist-remove': 'Remove game #{appId} from Steam wishlist (Ctrl+Click - open the game in a new tab)',
'steam-app-wishlist-add-failed': 'Failed to add to Steam wishlist. [steam-store-issues]',
'steam-app-wishlist-remove-failed': 'Failed to remove from Steam wishlist. [steam-store-issues]',
'steam-app-follow': 'Follow game #{appId} on Steam (Ctrl+Click - open the game in a new tab)',
'steam-app-unfollow': 'Unfollow game #{appId} on Steam (Ctrl+Click - open the game in a new tab)',
'steam-app-follow-failed': 'Failed to follow a game on Steam. [steam-store-issues]',
'steam-app-unfollow-failed': 'Failed to unfollow a game on Steam. [steam-store-issues]',
'steam-app-add-to-library': 'Add game #{appId} to Steam library (Ctrl+Click - open the game in a new tab)',
'steam-app-add-to-library-failed': 'Failed to add a game to Steam library. [steam-store-issues]',
'steam-community-not-logged': 'It looks like you are not logged in to <a href="https://steamcommunity.com" target="_blank">Steam Community</a>.',
'steam-store-not-logged': 'It looks like you are not logged in to <a href="https://store.steampowered.com" target="_blank">Steam Store</a>.',
'steam-store-issues': 'Perhaps you are not logged in to <a href="https://store.steampowered.com" target="_blank">Steam Store</a> or Steam is experiencing some issues.',
'gc-updated': `Giveaway Companion has been updated to version ${version.string}.<br><br><b>Changes:</b>`
},
ru: {
'confirm-tasks': 'Подтвердить задания',
'cancel': 'Отмена',
'useful-info': 'Полезная информация',
'reload-to-see-changes': '<a href="javascript:window.location.reload(false)">Обновите</a> страницу, чтобы увидеть изменения.',
'steam-activate-key': 'Открыть страницу активации Steam ключа ({key})',
'steam-loading-tasks': 'Загрузка заданий Steam...',
'steam-group-join': 'Вступить в Steam группу "{group}" (Ctrl+Клик - открыть группу в новой вкладке)',
'steam-group-leave': 'Выйти из Steam группы "{group}" (Ctrl+Клик - открыть группу в новой вкладке)',
'steam-init-groups-request-failed': 'Не удалось загрузить <a href="https://steamcommunity.com/my/groups" target="_blank">ваши группы</a>. <a href="https://steamcommunity.com" target="_blank">Сообщество Steam</a>, возможно, неактивно.',
'steam-init-store-request-failed': 'Не удалось загрузить информацию из вашего аккаунта Steam. <a href="https://store.steampowered.com" target="_blank">Магазин Steam</a>, возможно, неактивен.',
'steam-join-group-failed': 'Не удалось вступить в <a href="{groupLink}" target="_blank">группу</a>. <a href="https://steamcommunity.com" target="_blank">Сообщество Steam</a>, возможно, испытывает какие-то проблемы.',
'steam-join-group-join-request-sent': 'Заявка на вступление отправлена. Чтобы вступить в <a href="{groupLink}" target="_blank">группу</a>, вашу заявку должен одобрить администратор группы.',
'steam-join-group-not-logged': 'Не удалось вступить в <a href="{groupLink}" target="_blank">группу</a>. [steam-community-not-logged]',
'steam-join-group-not-found': 'Не удалось вступить в <a href="{groupLink}" target="_blank">группу</a>. Похоже, группа не существует.',
'steam-leave-group-failed': 'Не удалось выйти из <a href="{groupLink}" target="_blank">группы</a>. <a href="https://steamcommunity.com" target="_blank">Сообщество Steam</a>, возможно, испытывает какие-то проблемы.',
'steam-leave-group-not-logged': 'Не удалось выйти из <a href="{groupLink}" target="_blank">группы</a>. [steam-community-not-logged]',
'steam-app-wishlist-add': 'Добавить в список желаемого Steam игру #{appId} (Ctrl+Клик - открыть игру в новой вкладке)',
'steam-app-wishlist-remove': 'Удалить из списка желаемого Steam игру #{appId} (Ctrl+Клик - открыть игру в новой вкладке)',
'steam-app-wishlist-add-failed': 'Не удалось добавить в список желаемого Steam. [steam-store-issues]',
'steam-app-wishlist-remove-failed': 'Не удалось удалить из списка желаемого Steam. [steam-store-issues]',
'steam-app-follow': 'Подписаться в Steam на игру #{appId} (Ctrl+Клик - открыть игру в новой вкладке)',
'steam-app-unfollow': 'Отписаться в Steam от игры #{appId} (Ctrl+Клик - открыть игру в новой вкладке)',
'steam-app-follow-failed': 'Не удалось подписаться на Steam игру. [steam-store-issues]',
'steam-app-unfollow-failed': 'Не удалось отписаться от Steam игры. [steam-store-issues]',
'steam-app-add-to-library': 'Добавить игру #{appId} в библиотеку Steam (Ctrl+Клик - открыть игру в новой вкладке)',
'steam-app-add-to-library-failed': 'Не удалось добавить игру в библиотеку Steam. [steam-store-issues]',
'steam-community-not-logged': 'Похоже, вы не авторизованы в <a href="https://steamcommunity.com" target="_blank">Сообществе Steam</a>.',