forked from Revadike/EnhancedBarter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Enhanced Barter.user.js
1984 lines (1725 loc) · 94.5 KB
/
Enhanced Barter.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 Enhanced Barter
// @icon https://bartervg.com/imgs/ico/barter/favicon-32x32.png
// @namespace Revadike
// @author Revadike
// @version 1.2.2
// @description This userscript aims to enhance your experience at barter.vg
// @match https://barter.vg/*
// @match https://wwww.barter.vg/*
// @connect revadike.ga
// @connect steamcommunity.com
// @connect steamtrades.com
// @connect store.steampowered.com
// @grant GM_addStyle
// @grant GM_getResourceText
// @grant GM_info
// @grant GM_setClipboard
// @grant GM_xmlhttpRequest
// @grant unsafeWindow
// @run-at document-start
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/fuse.js/3.4.4/fuse.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/history.js/1.8/bundled-uncompressed/html4+html5/jquery.history.js
// @require https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/13.1.5/nouislider.min.js
// @resource noUiSliderCss https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/13.1.5/nouislider.min.css
// @homepageURL https://github.com/Revadike/EnhancedBarter/
// @supportURL https://github.com/Revadike/EnhancedBarter/issues
// @downloadURL https://github.com/Revadike/EnhancedBarter/raw/master/Enhanced%20Barter.user.js
// @updateURL https://github.com/Revadike/EnhancedBarter/raw/master/Enhanced%20Barter.user.js
// ==/UserScript==
// ==Code==
"use strict";
const requests = [];
const requestRateLimit = 200;
const localStorage = unsafeWindow.localStorage;
let myuid, mysid, streps, usergroups, itemnames;
function init() {
setTimeout(initBarter, 0);
}
function initBarter() {
setInterval(handleRequests, requestRateLimit);
$.fn.serializeObject = serializeObject;
// $.ajaxSetup({
// "beforeSend": (xhr, options) => {
// showSpinner(options.url);
// xhr.url = options.url;
// const request = () => {
// options.beforeSend = (x, o) => x.url = o.url;
// $.ajax(options);
// };
// requests.push(request);
// },
// "complete": (xhr) => hideSpinner(xhr.url)
// });
$.post = jqueryPost;
unsafeWindow.$ = $;
unsafeWindow.syncLibrary = syncLibrary;
$(document).ready(barterReady);
}
function barterReady() {
console.log(`[Enhanced Barter] Enhancing`);
// Every barter page
setTimeout(ajaxify, 0);
GM_addStyle(GM_getResourceText(`noUiSliderCss`));
GM_addStyle(stylesheet);
$(`li.bottomline`).after(`<li class="bottomline" title="${GM_info.script.name} (${GM_info.script.version}) by ${GM_info.script.author}">
<a target="_blank" href="https://github.com/Revadike/EnhancedBarter/">
<span>🤖︎</span>${GM_info.script.name}
</a>
</li>`);
$(`.sortBy`).after(`<div id="filtercontainer">
<span class="activityIcon normal gray">¶</span> Filter by
<input id="filterBy" type="text" placeholder="Search in displayed rows..." style="width: 530px;">
</div>`);
$(`#filtercontainer`).attr(`class`, $(`.sortBy`).attr(`class`));
$(`#filterBy`).on(`change keyup paste`, filterRows);
streps = JSON.parse(localStorage.stReps || `{}`);
$(`a:has(>[alt="Steam Trades icon"])`).get().forEach(addSteamTradesRep);
if ($(`#q`).length > 0) {
itemnames = JSON.parse(localStorage.itemnames || `{}`);
addAutoComplete();
}
usergroups = JSON.parse(localStorage.usergroups || `{}`);
// The match page and user profile page
$(`#tradeUser [label=Groups] option, [name=group] option`).get().forEach((elem) => {
const id = Math.abs(elem.value);
const offset = 64; // Char code offset
const name = usergroups[id >= offset ? id - offset : id];
if (!name) {
return;
}
elem.innerText = `${elem.innerText} : ${name}`;
});
// The match page
const cats = [`trade`, `wish`];
const sortings = {};
cats.forEach((cat) => {
sortings[cat] = {};
sortings[cat][`az`] = $(`select#${cat}Game option`).get();
const initial = sortings[cat].az.shift();
sortings[cat][`90`] = [...sortings[cat].az].sort((a, b) => parseInt(b.innerText.split(` (`).pop().replace(`)`, ``)) - parseInt(a.innerText.split(` (`).pop().replace(`)`, ``)));
$(`select#${cat}Game`).after(`
<div id="${cat}Sort" style="display: inline;">
<label> Sorted by </label>
<a data-sort="az" data-selected="1" style="text-decoration: none; font-weight: bold; color: inherit;">A-Z</a>
<label>/</label>
<a data-sort="90" data-selected="0" style="cursor: pointer;">9-0</a>
</div>
`);
$(`#${cat}Sort [data-sort]`).click((event) => {
$(`#${cat}Sort [data-selected="1"]`).attr(`data-selected`, 0).attr(`style`, `cursor: pointer;`);
$(event.target).attr(`data-selected`, 1).attr(`style`, `text-decoration: none; font-weight: bold; color: inherit;`);
const sortby = $(event.target).data(`sort`);
console.log(sortings[cat][sortby][0]);
$(`select#${cat}Game`).html([initial, ...sortings[cat][sortby]]).val(0);
});
});
// Any bundle page
if ($(`[accesskey="b"]`).parent().hasClass(`nav-sel`)) {
$(`.warnings`).append(`<li style="float: right">
<input id="togglebtn" onsubmit="void(0)" value="Hide/Show" type="button" class="addTo offer bold pborder">
</li>
<li style="float: right">
<select id="toggleselect" title="Select which items you want to hide or show" class="pborderHover">
<option value="[type=checkbox]:checked">Selected</option>
<option value=".blist">Blacklist</option>
<option value=".trad">Tradables</option>
<option value=".wish">Wishlist</option>
<option value=".libr">Library</option>
</select>
</li>`);
$(`#togglebtn`).click(toggleBundleItems);
}
// The creating offer page
$(`[name=remove_offer_items]`).val(`- Remove Selected`).css(`width`, `23.8%`).css(`margin-left`, `-4px`).removeClass(`extraLeft`).after(`<input type="button" value="◧ Invert Selection" style="width: 23.8%; margin-left: 0.5%" class="checkall addTo bborder" onsubmit="void(0)"><input type="button" value="🔓︎ Enable Locked" style="width: 23.8%; margin-left: 0.5%" class="enableall addTo oborder" onsubmit="void(0)">`);
$(`[name=add_to_offer]`).val(`+ Add Selected`).css(`width`, `23.8%`).css(`margin-right`, `0.5%`);
$(`.checkall`).click(checkAllTradables);
$(`.enableall`).click(enableAllTradables);
// Every next barter page will have the sign out link
if ($(`#signin`).length === 0 || $(`abbr+ a:has(.icon)`).length === 0) {
return;
}
myuid = $(`#signin`).attr(`href`).split(`/`)[4];
mysid = $(`abbr+ a:has(.icon)`).attr(`href`).split(`/`)[4];
// Every next barter page will be on /u/myuid/
if (!$(`h1 > a`).is(`[href*="/u/${myuid}"]`)) {
return;
}
// The library page
if ($(`[accesskey="l"]`).parent().hasClass(`nav-sel`) ) {
$(`[name="sync_list"]`).after(`<input type="button" title="Sync ALL owned games and DLC" value="↻ Comprehensive Sync with Steam" style="margin-left: 0.5%" id="libsync" class="addTo gborder" onsubmit="void(0)">`);
$(`#libsync`).click(clickLibSyncBtn);
}
// The settings page
if ($(`.preferences`).length > 0) {
$(`#offer`).before(`<div id="groups">
<h3 class="listName sborder">👪︎ User Group Names</h3>
<p>
<select name="groupid">
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
<option value="4">D</option>
<option value="5">E</option>
<option value="6">F</option>
<option value="7">G</option>
<option value="8">H</option>
<option value="9">I</option>
<option value="10">J</option>
<option value="11">K</option>
<option value="12">L</option>
<option value="13">M</option>
<option value="14">N</option>
<option value="15">O</option>
<option value="16">P</option>
<option value="17">Q</option>
<option value="18">R</option>
<option value="19">S</option>
<option value="20">T</option>
<option value="21">U</option>
<option value="22">V</option>
<option value="23">W</option>
<option value="24">X</option>
<option value="25">Y</option>
<option value="26">Z</option>
</select>
<input type="text" name="groupname" placeholder="E.g. Unowned collectors">
<input type="button" value="Save" id="savegroup" class="addTo dborder">
</p>
</div>`);
$(`#savegroup`).click((event) => {
event.preventDefault();
const id = $(`[name=groupid]`).val();
const name = $(`[name=groupname]`).val();
usergroups[id] = name;
localStorage.usergroups = JSON.stringify(usergroups);
});
$(`[name=groupid]`).change((event) => {
const id = event.target.value;
$(`[name=groupname]`).val(usergroups[id]);
});
$(`[name=groupid]`).trigger(`change`);
}
// The offer overview page
if ($(`li:has([accesskey="o"])`).is(`.nav-sel`) && $(`.activity`).length > 0) {
$(`[name="offer_setup"]+`).after(`<input id="automatedoffer" onsubmit="void(0)" value="Begin Automated Offer" class="addTo offer bold pborder" type="button" style="float: right;">`);
$(`#automatedoffer`).parents(`form`).css(`width`, `100%`);
$(`#automatedoffer`).click(setupAutomatedOffer);
$(`.showMoreArea`).last().after(`<p>
<label for="offersearch">
<strong>Filter: </strong>
</label>
<input class="addTo pborder" id="offersearch" type="text" placeholder="Search in displayed offers..." style="width: 210px;">
<input class="addTo pborder" style="float: right; margin-left: 4px;" id="canceloffers" type="button" onsubmit="void(0)" value="Cancel Offers">
<input class="addTo pborder" style="float: right; margin-left: 4px;" id="messageoffers" type="button" onsubmit="void(0)" value="Message Offers">
<input class="addTo pborder" style="float: right; margin-left: 4px;" id="extendoffers" type="button" onsubmit="void(0)" value="Change Expiration">
</p>`);
$(`#canceloffers`).click(cancelOffers);
$(`#messageoffers`).click(messageOffers);
$(`#extendoffers`).click(extendExpiry);
$(`#offersearch`).on(`change keyup paste`, searchOffers);
}
// The accepted offer page
$(`input[value='Completed Offer']`).click(finalizeOffer);
}
function clickLibSyncBtn(event) {
event.preventDefault();
showSpinner(`libsync`);
$(event.target).prop(`disabled`, true).val(`↻ Syncing...`);
syncLibrary(() => {
hideSpinner(`libsync`);
$(event.target).prop(`disabled`, false).val(`✔ Done`);
});
}
function showSpinner(instanceid) {
if ($(`.spinner`).length === 0) { // to avoid multiple spinners
$(`body`).prepend(`<div class="spinner"></div>`);
}
$(`.spinner`).attr(`data-instanceid`, instanceid);
}
function hideSpinner(instanceid) {
$(`.spinner[data-instanceid='${instanceid}']`).remove();
}
function enableAllTradables(event) {
event.preventDefault();
if (!confirm(`Are you sure you want to enable disabled tradables? Make sure the other party is okay with this!`)) {
return;
}
$(event.target).parents(`.tradables`).find(`.collectionSelect input[disabled]`).get().forEach((elem) => {
elem.removeAttribute(`disabled`);
elem.removeAttribute(`title`);
elem.name = `add_to_offer_${$(`.enableall:first`).is(event.target) ? `1` : `2`}[]`;
elem.id = $(elem).find(`+`).attr(`for`);
elem.value = `${$(elem).parents(`tr`).data(`item-id`)},${$(elem).next().attr(`for`).replace(`edit`, ``)}`;
});
$(event.target).remove();
}
function checkAllTradables(event) {
event.preventDefault();
$(event.target).parents(`.tradables`).find(`.collectionSelect input[type=checkbox]`).get().forEach((elem) => elem.checked = !elem.checked);
}
function toggleBundleItems(event) {
event.preventDefault();
$(`.collection tbody > tr:has(${$(`#toggleselect`).val()}):not(:has(.bargraphs))`).toggle();
$(`.collection tbody > tr:visible [type=checkbox]`).prop(`disabled`, false);
$(`.collection tbody > tr:hidden [type=checkbox]`).prop(`disabled`, true);
}
function createRep(rep) {
if (rep && isFinite(rep.m) && isFinite(rep.p)) {
return `<span class="strep" title="Steam Trades score">( <span class="plus">+${rep.p}</span>, <span class="minus${rep.m !== 0 ? ` hasMinus` : ``}">${rep.m}</span> )</span>`;
}
return $(`<span class="strep notfound">( none )</span>`);
}
function addSteamTradesRep(elem) {
const steamid = elem.href.split(`/`)[4];
if (streps[steamid] && streps[steamid].t && Date.now() - streps[steamid].t <= 48 * 60 * 60 * 1000) {
$(elem).after(createRep(streps[steamid]));
return;
}
request({
"method": `GET`,
"url": elem.href,
"onload": (response) => {
streps[steamid] = {};
const plus = parseInt($(`.increment_positive_review_count`, response.responseText).first().text().replace(`,`, ``));
const minus = parseInt($(`.increment_negative_review_count`, response.responseText).first().text().replace(`,`, ``));
if (!isNaN(plus) && !isNaN(minus)) {
streps[steamid].p = plus;
streps[steamid].m = minus;
}
streps[steamid].t = Date.now();
localStorage.stReps = JSON.stringify(streps);
$(elem).after(createRep(streps[steamid]));
}
});
}
function addAutoComplete() {
if (Date.now() - itemnames.lastupdated <= 24 * 60 * 60 * 1000) {
const data = Object.entries(itemnames.data).map((e) => ({ "id": e[0], "title": e[1] }));
// eslint-disable-next-line no-undef
const fuse = new Fuse(data, {
"shouldSort": true,
"threshold": 0.3,
"maxPatternLength": 32,
"minMatchCharLength": 2,
"keys": [`id`, `title`]
});
let delay;
$(`#q`).parent().append(`<div id="acbox" class="autocomplete"></div>`);
$(`#q`).on(`change keyup paste`, (event) => {
clearTimeout(delay);
showSpinner(`autocomplete`);
delay = setTimeout(() => {
const val = event.target.value.trim();
$(`#acbox`).html(``);
hideSpinner(`autocomplete`);
if (val.length <= 2) {
return;
}
const results = fuse.search(val);
for (let i = 0; i < 10; i++) {
const item = results.shift();
if (item) {
$(`#acbox`).append(`<p style="margin: 0.5em;"><a href="/i/${item.id}/">${item.title}</a></p>`);
}
}
if (results.length === 0) {
return;
}
$(`#acbox`).append(`<strong style="margin: 0.5em;"><a href="/search?q=${encodeURIComponent(val)}">And ${results.length} more...</a></strong>`);
}, 500);
}).blur(() => setTimeout(() => $(`#acbox`).hide(), 200)).focus(() => $(`#acbox`).show());
return;
}
request({
"method": `GET`,
"url": `https://barter.vg/browse/json/`,
"onload": (response) => {
let json;
try {
json = JSON.parse(response.responseText);
} catch (e) {
return;
}
itemnames.data = {};
for (const id in json) {
itemnames.data[id] = json[id].title.trim();
}
itemnames.lastupdated = Date.now();
localStorage.itemnames = JSON.stringify(itemnames);
addAutoComplete();
}
});
}
function handleRequests() {
if (requests.length === 0) {
return;
}
if (requests.length === 1) {
setTimeout(() => console.log(`All ajax requests are served!`), requestRateLimit);
}
console.log(`${requests.length} Ajax requests remaining...\nThis will roughly take ${requests.length * requestRateLimit / 1000} seconds to complete.`);
const req = requests.shift();
if (typeof request === `function`) {
req();
}
}
function finalizeOffer(event) {
event.preventDefault();
const main = $(event.target).parents(`#main`);
const steamid = $(`#offerHeader [alt="Steam icon"]`, main).get().map((elem) => elem.title).find((id) => id !== mysid);
const name = $(`#offerHeader tr:has([title="${steamid}"]) > td:nth-child(2) > strong > a`, main).text();
const form = $(event.target).parents(`form`);
const url = form.attr(`action`).split(`#`)[0];
const msg = `+REP ${name} is an amazing trader, recommended! We successfully completed this trade: ${url}. Thanks a lot for the trade!`;
$(event.target).val(`Completing trade, sending feedback and syncing library...`).prop(`disabled`, true);
showSpinner(`feedback`);
setPostTradeClipboard(url);
$.post(url, form.serializeObject(), () => postSteamTradesComment(msg, steamid, () => syncLibrary(() => location.href = url)));
}
async function syncLibrary(callback) {
if (callback) {
await syncLibrary().catch(callback);
callback();
return;
}
return new Promise(async(res, rej) => {
request({
"url": `https://barter.vg/u/${myuid}/l/`,
"method": `POST`,
"headers": {
"Content-Type": `application/x-www-form-urlencoded`
},
"data": $.param({
"sync_list": `↻ Sync List`,
"type": 1
}),
"onload": () => true
});
const response = await request({
"method": `GET`,
"url": `http://store.steampowered.com/dynamicstore/userdata/?t=${Date.now()}`
}).catch(rej);
const json = JSON.parse(response.responseText);
const ownedApps = json.rgOwnedApps;
const ownedPackages = json.rgOwnedPackages;
await request({
"url": `https://barter.vg/u/${myuid}/l/e/`,
"method": `POST`,
"headers": {
"Content-Type": `application/x-www-form-urlencoded`
},
"data": $.param({
"bulk_IDs": `app/${ownedApps.join(`,app/`)},sub/${ownedPackages.join(`,sub/`)}`,
"add_IDs": `+ Add IDs`,
"action": `Edit`,
"change_attempted": 1,
"add_from": `IDs`
})
}).catch(rej);
res();
});
}
async function postSteamTradesComment(msg, steamid, callback) {
const empty = () => {};
callback = callback || empty;
const response = await request({
"method": `GET`,
"url": `https://www.steamtrades.com/user/${steamid}`,
"headers": {
"Accept": `text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3`,
"Accept-Encoding": `gzip, deflate, br`,
"Accept-Language": `en`
}
}).catch(callback);
const profile_id = $(`[name=profile_id]`, response.responseText).val();
const xsrf_token = $(`[name=xsrf_token]`, response.responseText).val();
if (!profile_id || !xsrf_token) {
callback();
return;
}
const data = {
"do": `review_insert`,
"xsrf_token": xsrf_token,
"profile_id": profile_id,
"rating": 1,
"description": msg
};
await request({
"method": `POST`,
"url": `https://www.steamtrades.com/ajax.php`,
"data": $.param(data),
"headers": {
"Content-Type": `application/x-www-form-urlencoded; charset=UTF-8`,
"Accept": `application/json, text/javascript, */*; q=0.01`,
"Accept-Encoding": `gzip, deflate, br`,
"Accept-Language": `en`
}
}).catch(callback);
callback();
}
function setPostTradeClipboard(url) {
const sgprofile = `https://www.steamtrades.com/user/${mysid}`;
const msg = `Thanks for the trade!\nI completed the trade on barter.vg and left feedback on your steamtrades profile.\nIf you haven't done so already, could you please do the same?\n${url}\n${sgprofile}`;
GM_setClipboard(msg);
}
function setupAutomatedOffer() {
$.post(`/u/${myuid}/o/`, {
"to_user_id": -2,
"offer_setup": 1
}, (data) => {
$.post($(`[rel=canonical]`, `<div>${data}</div>`).attr(`href`), {
"offer_setup": 3,
"cancel_offer": `☒ Cancel Offer`
});
parseHtml(data);
$(`#main h2`).html(`🤖︎✉ Automated Offers`);
$(`#offerHeaderTo`).html(`To <strong>Qualified Users</strong> (select options below)`);
$(`#offerHeaderTo`).parent().next().remove();
$(`#offerHeaderTo`).parent().before(`<tr>
<td class="gray">
<span>Via</span>
</td>
<td colspan="6" class="gray">
<a href="https://steamcommunity.com/groups/bartervg/discussions/6/1470841715930902039/">
<span title="version ${GM_info.script.version}">${GM_info.script.name}</span>
</a>
<a href="https://github.com/Royalgamer06/EnhancedBarter/">
<img src="https://bartervg.com/imgs/ico/github.png" alt="GitHub icon" title="GitHub" class="icon">
</a>
<span>(not associated with Barter.vg)</span>
</td>
</tr>`);
$(`#offer`).replaceWith(`<form id=offer>${$(`#offer`).html()}</form>`);
$(`[name=cancel_offer]`).replaceWith(`<input class="addTo failed" value="🗑 Cancel and Discard Offer" type="button" onclick="location.reload()">`);
$(`.tradables:nth-child(3) legend`).html(`${$(`.tradables:nth-child(3) legend`).html().replace(`<strong class="midsized offer">1</strong> of `, `<input min="1" id="from_ratio" name="from_ratio" type="number" value="1" style="width: 40px;"> of `)}...`);
$(`form[action*=comments]`).remove();
$(`.noborder:nth-child(3)`).nextAll().remove();
$(`.collectionSelect`).nextAll().remove();
$(`#exchanges`).nextAll().remove();
$(`#offer`).nextAll().remove();
$(`.tradables`).after(`
<ul>
...to users who...
<li> <input type="checkbox" name="offering_to" id="towishlist" value="wishlist" checked="true"> <label for="towishlist">...have them in their wishlist...</label></li>
<li> <input type="checkbox" name="offering_to" id="tounowned" value="unowned"> <label for="tounowned">...do <strong>not</strong> have them in their library...</label></li>
<!-- <li> <input type="checkbox" name="offering_to" id="tolibrary" value="library"> <label for="tolibrary">...have them in their library...</label></li> -->
<li> <input type="checkbox" name="offering_to" id="totradable" value="tradable"> <label for="totradable">...have them for trade...</label></li>
</ul>
<div style="margin: 2em 0; border-top: 1px solid rgb(153, 17, 187); border-bottom: 1px solid rgb(153, 17, 187);" class="offerDivide">
<strong class="midsized">⇅</strong> ...in exchange for...
</div>
<p>
... <input min="1" id="to_ratio" name="to_ratio" type="number" value="1" style="width: 40px;"> of their tradables of type(s)...
</p>
<p>
<input type="checkbox" name="type" id="game" value="game" checked="true"> <label for="game">Game</label>
<input type="checkbox" name="type" id="dlc" value="dlc"> <label for="dlc">DLC</label>
<input type="checkbox" name="type" id="application" value="application"> <label for="application">Application</label>
<input type="checkbox" name="type" id="tool" value="tool"> <label for="tool">Tool</label>
<input type="checkbox" name="type" id="demo" value="demo"> <label for="demo">Demo</label>
<input type="checkbox" name="type" id="mod" value="mod"> <label for="mod">Mod</label>
<input type="checkbox" name="type" id="media" value="media"> <label for="media">Media</label>
<input type="checkbox" name="type" id="movie" value="movie"> <label for="movie">Movie</label>
<input type="checkbox" name="type" id="video" value="video"> <label for="video">Video</label>
<input type="checkbox" name="type" id="episode" value="episode"> <label for="episode">Episode</label>
<input type="checkbox" name="type" id="series" value="series"> <label for="series">Series</label>
<input type="checkbox" name="type" id="guide" value="guide"> <label for="guide">Guide</label>
<input type="checkbox" name="type" id="config" value="config"> <label for="config">Config</label>
<input type="checkbox" name="type" id="storeonly" value="storeonly"> <label for="storeonly">Storefront Only</label>
<input type="checkbox" name="type" id="advertising" value="advertising"> <label for="advertising">Advertising</label>
<input type="checkbox" name="type" id="hardware" value="hardware"> <label for="hardware">Hardware</label>
<input type="checkbox" name="type" id="unknown" value="unknown"> <label for="unknown">Unknown</label>
<input type="checkbox" name="type" id="unset" value="unset"> <label for="unset">Unset</label>
</p>
<p>
...meeting these requirements...
</p>
<fieldset>
<small>TIP: Hover over the (?) with your mouse cursor for a better description and explanation of the requirement.</small>
</fieldset>
<fieldset style="border-top: 1px solid rgb(153, 17, 187);">
<div id="limit" data-max="10000" class="offerSlider"></div>
Offer count (<a style="cursor: help; text-decoration: none;" title="The number range of offers you want to send. \nIf you only have a limited stock of your selected tradable(s), I'd recommend limiting your offers to avoid getting more accepted offers than you can fulfill. \nNote that barter has a daily limit for offers. Please complain to barter.vg about this.">?</a>)
</fieldset>
<!-- <fieldset>
<div id="DLC" data-max="1" data-suffix="%" class="offerSlider"></div>
DLC (<a style="cursor: help; text-decoration: none;" title="Include DLC? \nThere are 3 options: 0%-0% means no DLC, 0%-100% means allow DLC (don't care) and 100%-100% means DLC only.">?</a>)
</fieldset> -->
<fieldset>
<div id="limited" data-max="1" data-suffix="%" class="offerSlider"></div>
Steam Limited (<a style="cursor: help; text-decoration: none;" title="Include Steam Limited? \nSteam Limited: no +1 for your library, no achievement showcase. \nThere are 3 options: 0%-0% means no Steam Limited, 0%-100% means allow Steam Limited (don't care) and 100%-100% means Steam Limited only.">?</a>)
</fieldset>
<fieldset>
<div id="givenaway" data-max="1" data-suffix="%" class="offerSlider"></div>
Given away (<a style="cursor: help; text-decoration: none;" title="Include games that are free or have been given away before?\nThere are 3 options: 0%-0% means no given away, 0%-100% means allow given away (don't care) and 100%-100% means given away only.">?</a>)
</fieldset>
<fieldset>
<div id="bundles" data-max="100" class="offerSlider"></div>
Bundles count (<a style="cursor: help; text-decoration: none;" title="The range of the number of times the game has been bundled. \nChoose range 0-0 to only want never bundled games. \nChoose range 1-max to avoid never-bundled games.">?</a>)
</fieldset>
<fieldset>
<div id="cards" data-max="100" class="offerSlider"></div>
Cards count (<a style="cursor: help; text-decoration: none;" title="The range of the how many Steam Trading Cards a game must have. \nChoose range 0-0 to only want games with no cards. \nChoose range 1-max to only want games with cards (any amount).">?</a>)
</fieldset>
<fieldset>
<div id="achievements" data-max="1000000" class="offerSlider"></div>
Achievements count (<a style="cursor: help; text-decoration: none;" title="The range of how many achievements a game must have. \nChoose range 0-0 to only want games with no achievements. \nChoose range 1-max if you only want games with achievements (any amount).">?</a>)
</fieldset>
<fieldset>
<div id="reviews" data-max="1000000" class="offerSlider"></div>
Review count (<a style="cursor: help; text-decoration: none;" title="I recommend leaving this one on default (0-max). \nThe range of how many reviews a game must have. \nChoose range 0-0 to only want games with no reviews. \nChoose range 1-max if you only want games with reviews (any amount).">?</a>)
</fieldset>
<fieldset>
<div id="scores" data-max="100" data-suffix="%" class="offerSlider"></div>
Review score (<a style="cursor: help; text-decoration: none;" title="The percentage range of the game review score. \nThe default range (0%-100%) allows games with any review score.">?</a>)
</fieldset>
<fieldset>
<div id="price" data-max="10000" data-prefix="$" class="offerSlider"></div>
Price (<a style="cursor: help; text-decoration: none;" title="The price range of the game. \nThe default range (0$-max$) allows games with any price amount. \nI'd recommend adjusting this range to roughly match your selected tradable(s).">?</a>)
</fieldset>
<fieldset>
<div id="year" data-min="1950" data-max="2050" class="offerSlider"></div>
Release year (<a style="cursor: help; text-decoration: none;" title="The release year range of the game.">?</a>)
</fieldset>
<fieldset>
<div id="wishlist" data-max="10000" class="offerSlider"></div>
Wishlist count (<a style="cursor: help; text-decoration: none;" title="The range of the wishlist count: the number of Barter.vg users that have the game in their wishlist. \nI'd recommend adjusting this range to roughly match your selected tradable(s).">?</a>)
</fieldset>
<fieldset>
<div id="library" data-max="10000" class="offerSlider"></div>
Library count (<a style="cursor: help; text-decoration: none;" title="The range of the library count: the number of Barter.vg users that have the game in their library. \nIf you want only rare games (games nobody or only a few have), you can lower the upper range bound.">?</a>)
</fieldset>
<fieldset style="border-bottom: 1px solid rgb(153, 17, 187);">
<div id="tradables" data-max="10000" class="offerSlider"></div>
Tradables count (<a style="cursor: help; text-decoration: none;" title="The range of the tradables count or availability: the number of Barter.vg users that have the game to trade.">?</a>)
</fieldset>
<p style="float: left;">...from these platforms...</p>
<p style="margin-left: 50%;">...from users who...</p>
<div style="width: 50%; float: right; height: 14em; overflow: auto; border-top: 1px solid rgb(153, 17, 187); border-bottom: 1px solid rgb(153, 17, 187);">
<ul>
<li> <input type="checkbox" name="want_from" id="wantwishlist" value="wishlist" checked="true"> <label for="wantwishlist">...have those tradables in your wishlist.</label></li>
<li> <input type="checkbox" name="want_from" id="wantunowned" value="unowned"> <label for="wantunowned">...do <strong>not</strong> have those tradables in your library.</label></li>
<li> <input type="checkbox" name="want_from" id="wantlibrary" value="library"> <label for="wantlibrary">...have those tradables in your library.</label></li>
<li> <input type="checkbox" name="want_from" id="wanttradable" value="tradable"> <label for="wanttradable">...have those tradables in your tradables list.</label></li>
</ul>
</div>
<div style="width: 50%; height: 14em; overflow: auto; border-top: 1px solid rgb(153, 17, 187); border-bottom: 1px solid rgb(153, 17, 187);">
<ul>
<li><input type="checkbox" name="platform" id="steam" value="1" checked="true"><label for="steam">Steam</label></li>
<li><input type="checkbox" name="platform" id="steampkg" value="2"><label for="steampkg">Steam Package</label></li>
<li><input type="checkbox" name="platform" id="humblebundle" value="3"><label for="humblebundle">Humble Bundle</label></li>
<li><input type="checkbox" name="platform" id="gog" value="4"><label for="gog">GOG.com</label></li>
<li><input type="checkbox" name="platform" id="origin" value="5"><label for="origin">Origin</label></li>
<li><input type="checkbox" name="platform" id="desura" value="6"><label for="desura">Desura</label></li>
<li><input type="checkbox" name="platform" id="indiegala" value="7"><label for="indiegala">Indiegala</label></li>
<li><input type="checkbox" name="platform" id="fanatical" value="8"><label for="fanatical">Fanatical</label></li>
<li><input type="checkbox" name="platform" id="groupees" value="9"><label for="groupees">Groupees</label></li>
<li><input type="checkbox" name="platform" id="indieroyale" value="10"><label for="indieroyale">Indie Royale</label></li>
<li><input type="checkbox" name="platform" id="gamersgate" value="11"><label for="gamersgate">GamersGate</label></li>
<li><input type="checkbox" name="platform" id="amazon" value="12"><label for="amazon">Amazon</label></li>
<li><input type="checkbox" name="platform" id="humblebundle" value="13"><label for="humblebundle">Humble Store</label></li>
<li><input type="checkbox" name="platform" id="uplay" value="14"><label for="uplay">Uplay</label></li>
<li><input type="checkbox" name="platform" id="lazyguys" value="15"><label for="lazyguys">Lazy Guys Bundle</label></li>
<li><input type="checkbox" name="platform" id="greenlight" value="16"><label for="greenlight">Green Light Bundle</label></li>
<li><input type="checkbox" name="platform" id="dailyindie" value="17"><label for="dailyindie">DailyIndieGame</label></li>
<li><input type="checkbox" name="platform" id="flyingbundle" value="18"><label for="flyingbundle">Flying Bundle</label></li>
<li><input type="checkbox" name="platform" id="steami" value="19"><label for="steami">Steam Item</label></li>
<li><input type="checkbox" name="platform" id="gmg" value="20"><label for="gmg">Green Man Gaming</label></li>
<li><input type="checkbox" name="platform" id="nuuvem" value="21"><label for="nuuvem">Nuuvem</label></li>
<li><input type="checkbox" name="platform" id="macgamestore" value="22"><label for="macgamestore">MacGameStore</label></li>
<li><input type="checkbox" name="platform" id="playinjector" value="23"><label for="playinjector">Playinjector</label></li>
<li><input type="checkbox" name="platform" id="igamestand" value="24"><label for="igamestand">IndieGameStand</label></li>
<li><input type="checkbox" name="platform" id="3ds" value="25"><label for="3ds">Nintendo 3DS</label></li>
<li><input type="checkbox" name="platform" id="wiiu" value="26"><label for="wiiu">WiiU</label></li>
<li><input type="checkbox" name="platform" id="coinplay" value="27"><label for="coinplay">Coinplay.io</label></li>
<li><input type="checkbox" name="platform" id="itchio" value="28"><label for="itchio">itch.io</label></li>
<li><input type="checkbox" name="platform" id="superduper" value="29"><label for="superduper">Super-Duper Bundle</label></li>
<li><input type="checkbox" name="platform" id="onemore" value="30"><label for="onemore">one more bundle</label></li>
<li><input type="checkbox" name="platform" id="cubicbundle" value="31"><label for="cubicbundle">Cubic Bundle</label></li>
<li><input type="checkbox" name="platform" id="telltale" value="32"><label for="telltale">Telltale Games</label></li>
<li><input type="checkbox" name="platform" id="hrk" value="33"><label for="hrk">HRK</label></li>
<li><input type="checkbox" name="platform" id="wingamestore" value="34"><label for="wingamestore">WinGameStore</label></li>
<li><input type="checkbox" name="platform" id="sgreenlight" value="35"><label for="sgreenlight">Steam Greenlight</label></li>
<li><input type="checkbox" name="platform" id="orlygift" value="36"><label for="orlygift">Orlygift</label></li>
<li><input type="checkbox" name="platform" id="squareenix" value="37"><label for="squareenix">Square Enix</label></li>
<li><input type="checkbox" name="platform" id="otakumaker" value="38"><label for="otakumaker">OtakuMaker</label></li>
<li><input type="checkbox" name="platform" id="bundlekings" value="39"><label for="bundlekings">Bundle Kings</label></li>
<li><input type="checkbox" name="platform" id="gamebundle" value="40"><label for="gamebundle">GameBundle</label></li>
<li><input type="checkbox" name="platform" id="chronogg" value="41"><label for="chronogg">Chrono.gg</label></li>
<li><input type="checkbox" name="platform" id="dlgamer" value="42"><label for="dlgamer">DLGamer</label></li>
<li><input type="checkbox" name="platform" id="gamesplanet" value="43"><label for="gamesplanet">Gamesplanet</label></li>
<li><input type="checkbox" name="platform" id="silagames" value="44"><label for="silagames">Sila Games</label></li>
<li><input type="checkbox" name="platform" id="bunchofkeys" value="45"><label for="bunchofkeys">Bunch of Keys</label></li>
<li><input type="checkbox" name="platform" id="g2a" value="46"><label for="g2a">G2A</label></li>
<li><input type="checkbox" name="platform" id="steamground" value="47"><label for="steamground">Steamground</label></li>
<li><input type="checkbox" name="platform" id="99cent" value="48"><label for="99cent">99 Cent Bundle</label></li>
<li><input type="checkbox" name="platform" id="redacted" value="49"><label for="redacted">Redacted Network</label></li>
<li><input type="checkbox" name="platform" id="breadbox" value="50"><label for="breadbox">Bread Box Bundle</label></li>
<li><input type="checkbox" name="platform" id="ps4" value="51"><label for="ps4">PlayStation 4</label></li>
<li><input type="checkbox" name="platform" id="ps3" value="52"><label for="ps3">PlayStation 3</label></li>
<li><input type="checkbox" name="platform" id="xb360" value="53"><label for="xb360">Xbox 360</label></li>
<li><input type="checkbox" name="platform" id="xbone" value="54"><label for="xbone">Xbox One</label></li>
<li><input type="checkbox" name="platform" id="steamgifts" value="55"><label for="steamgifts">Steamgifts.com</label></li>
<li><input type="checkbox" name="platform" id="marvelous" value="56"><label for="marvelous">MarvelousCrate</label></li>
<li><input type="checkbox" name="platform" id="barter" value="57"><label for="barter">Barter.vg</label></li>
<li><input type="checkbox" name="platform" id="gogobundles" value="58"><label for="gogobundles">GoGoBundle</label></li>
<li><input type="checkbox" name="platform" id="cdkeys" value="59"><label for="cdkeys">CDKeys.com</label></li>
<li><input type="checkbox" name="platform" id="kinguin" value="60"><label for="kinguin">Kinguin</label></li>
<li><input type="checkbox" name="platform" id="unspecified2" value="61"><label for="unspecified2">Unspecified Platform</label></li>
<li><input type="checkbox" name="platform" id="otakubundle" value="62"><label for="otakubundle">Otaku Bundle</label></li>
<li><input type="checkbox" name="platform" id="dogebundle" value="63"><label for="dogebundle">DogeBundle</label></li>
<li><input type="checkbox" name="platform" id="plati" value="64"><label for="plati">Plati</label></li>
<li><input type="checkbox" name="platform" id="streamtrades" value="65"><label for="streamtrades">Steamtrades.com</label></li>
<li><input type="checkbox" name="platform" id="epicgamesstore" value="66"><label for="epicgamesstore">Epic Games Store</label></li>
<li><input type="checkbox" name="platform" id="twitch" value="67"><label for="twitch">Twitch</label></li>
<li><input type="checkbox" name="platform" id="indiedeals2" value="68"><label for="indiedeals2">IndieDeals.net</label></li>
<li><input type="checkbox" name="platform" id="tigb" value="69"><label for="tigb">The Indie Games Bundle</label></li>
<li><input type="checkbox" name="platform" id="tiltify" value="70"><label for="tiltify">Tiltify</label></li>
<li><input type="checkbox" name="platform" id="tremorgames" value="71"><label for="tremorgames">Tremor Games</label></li>
<li><input type="checkbox" name="platform" id="grepublic" value="72"><label for="grepublic">Games Republic</label></li>
<li><input type="checkbox" name="platform" id="2game" value="73"><label for="2game">2game</label></li>
<li><input type="checkbox" name="platform" id="d2d" value="74"><label for="d2d">Direct2Drive</label></li>
<li><input type="checkbox" name="platform" id="dreamgate" value="75"><label for="dreamgate">Dreamgate</label></li>
<li><input type="checkbox" name="platform" id="newegg" value="76"><label for="newegg">Newegg</label></li>
<li><input type="checkbox" name="platform" id="ps3" value="77"><label for="ps3">PSVita</label></li>
<li><input type="checkbox" name="platform" id="ps4" value="78"><label for="ps4">PSN</label></li>
<li><input type="checkbox" name="platform" id="embloo" value="79"><label for="embloo">Embloo</label></li>
<li><input type="checkbox" name="platform" id="battlenet" value="80"><label for="battlenet">battle.net</label></li>
<li><input type="checkbox" name="platform" id="gamivo" value="81"><label for="gamivo">Gamivo</label></li>
<li><input type="checkbox" name="platform" id="getgames" value="82"><label for="getgames">Get Games Go</label></li>
<li><input type="checkbox" name="platform" id="g2play" value="83"><label for="g2play">G2play</label></li>
<li><input type="checkbox" name="platform" id="fangamer" value="84"><label for="fangamer">Fangamer</label></li>
<li><input type="checkbox" name="platform" id="trove" value="85"><label for="trove">Humble Trove</label></li>
<li><input type="checkbox" name="platform" id="steam-tracker" value="86"><label for="steam-tracker">Steam-tracker</label></li>
<li><input type="checkbox" name="platform" id="blinkbundle" value="87"><label for="blinkbundle">Blink Bundle</label></li>
<li><input type="checkbox" name="platform" id="gamesrage" value="88"><label for="gamesrage">Games Rage</label></li>
<li><input type="checkbox" name="platform" id="bbandits" value="89"><label for="bbandits">Bundle Bandits</label></li>
<li><input type="checkbox" name="platform" id="bcentral" value="90"><label for="bcentral">Bundle Central</label></li>
<li><input type="checkbox" name="platform" id="bdragon" value="91"><label for="bdragon">Bundle Dragon</label></li>
<li><input type="checkbox" name="platform" id="biab" value="92"><label for="biab">Bundle In A Box</label></li>
<li><input type="checkbox" name="platform" id="cultofmac" value="93"><label for="cultofmac">Cult of Mac</label></li>
<li><input type="checkbox" name="platform" id="eurobundle" value="94"><label for="eurobundle">Eurobundle</label></li>
<li><input type="checkbox" name="platform" id="gram" value="95"><label for="gram">gram.pl</label></li>
<li><input type="checkbox" name="platform" id="indieammo" value="96"><label for="indieammo">Indie Ammo Box</label></li>
<li><input type="checkbox" name="platform" id="iborg" value="97"><label for="iborg">IndieBundle</label></li>
<li><input type="checkbox" name="platform" id="kissmb" value="98"><label for="kissmb">KissMyBundles</label></li>
<li><input type="checkbox" name="platform" id="madorc" value="99"><label for="madorc">MadOrc</label></li>
<li><input type="checkbox" name="platform" id="paddle" value="100"><label for="paddle">Paddle</label></li>
<li><input type="checkbox" name="platform" id="paywuw" value="101"><label for="paywuw">PayWUW</label></li>
<li><input type="checkbox" name="platform" id="peonb" value="102"><label for="peonb">Peon Bundle</label></li>
<li><input type="checkbox" name="platform" id="gameolith" value="103"><label for="gameolith">Gameolith</label></li>
<li><input type="checkbox" name="platform" id="selectnp" value="104"><label for="selectnp">Select n' Play</label></li>
<li><input type="checkbox" name="platform" id="shinyloot" value="105"><label for="shinyloot">ShinyLoot</label></li>
<li><input type="checkbox" name="platform" id="stacksocial" value="106"><label for="stacksocial">StackSocial</label></li>
<li><input type="checkbox" name="platform" id="universala" value="107"><label for="universala">Universala</label></li>
<li><input type="checkbox" name="platform" id="vodo" value="108"><label for="vodo">VODO</label></li>
<li><input type="checkbox" name="platform" id="cybundle" value="109"><label for="cybundle">CY Bundle</label></li>
<li><input type="checkbox" name="platform" id="discord" value="110"><label for="discord">Discord</label></li>
<li><input type="checkbox" name="platform" id="lequestore" value="111"><label for="lequestore">lequestore</label></li>
<li><input type="checkbox" name="platform" id="rockstar" value="112"><label for="rockstar">Rockstar Social Club</label></li>
<li><input type="checkbox" name="platform" id="disc" value="113"><label for="disc">From boxed copy</label></li>
<li><input type="checkbox" name="platform" id="puppygames" value="114"><label for="puppygames">PuppyGames</label></li>
<li><input type="checkbox" name="platform" id="igpack" value="115"><label for="igpack">Indie-games pack</label></li>
<li><input type="checkbox" name="platform" id="supershock" value="116"><label for="supershock">Super Shock Bundle</label></li>
<li><input type="checkbox" name="platform" id="charlies" value="117"><label for="charlies">Charlie's Games</label></li>
<li><input type="checkbox" name="platform" id="socks" value="118"><label for="socks">Buy Games Not Socks</label></li>
<li><input type="checkbox" name="platform" id="subsoap" value="119"><label for="subsoap">Subsoap</label></li>
<li><input type="checkbox" name="platform" id="bitcoin" value="120"><label for="bitcoin">Bitcoin Bundle</label></li>
<li><input type="checkbox" name="platform" id="gamersgate" value="121"><label for="gamersgate">IndieFort</label></li>
<li><input type="checkbox" name="platform" id="voidu" value="122"><label for="voidu">Voidu</label></li>
<li><input type="checkbox" name="platform" id="gemly" value="123"><label for="gemly">gemly</label></li>
<li><input type="checkbox" name="platform" id="akens" value="124"><label for="akens">akens.ru</label></li>
<li><input type="checkbox" name="platform" id="farmkeys" value="125"><label for="farmkeys">FarmKEYS</label></li>
<li><input type="checkbox" name="platform" id="tkfg" value="126"><label for="tkfg">TKFG</label></li>
<li><input type="checkbox" name="platform" id="greenlighta" value="127"><label for="greenlighta">Greenlight Arcade</label></li>
<li><input type="checkbox" name="platform" id="h2o" value="128"><label for="h2o">H2O Bundle</label></li>
<li><input type="checkbox" name="platform" id="oculus" value="129"><label for="oculus">Oculus</label></li>
<li><input type="checkbox" name="platform" id="razer" value="130"><label for="razer">Razer</label></li>
<li><input type="checkbox" name="platform" id="alienware" value="131"><label for="alienware">Alienware</label></li>
<li><input type="checkbox" name="platform" id="ign" value="132"><label for="ign">IGN</label></li>
<li><input type="checkbox" name="platform" id="microsoft" value="133"><label for="microsoft">Microsoft Store</label></li>
<li><input type="checkbox" name="platform" id="alphabundle" value="134"><label for="alphabundle">Alpha Bundle</label></li>
<li><input type="checkbox" name="platform" id="opiumpulses" value="135"><label for="opiumpulses">Opium Pulses</label></li>
<li><input type="checkbox" name="platform" id="brightlocker" value="137"><label for="brightlocker">BrightLocker</label></li>
<li><input type="checkbox" name="platform" id="oyvey" value="138"><label for="oyvey">Oy Vey Keys</label></li>
<li><input type="checkbox" name="platform" id="stardock" value="139"><label for="stardock">Stardock</label></li>
<li><input type="checkbox" name="platform" id="lootcrate" value="140"><label for="lootcrate">Loot Crate</label></li>
<li><input type="checkbox" name="platform" id="allyouplay" value="141"><label for="allyouplay">Allyouplay</label></li>
<li><input type="checkbox" name="platform" id="bestbuy" value="142"><label for="bestbuy">Best Buy</label></li>
<li><input type="checkbox" name="platform" id="gameuk" value="143"><label for="gameuk">GAME UK</label></li>
<li><input type="checkbox" name="platform" id="gamebillet" value="144"><label for="gamebillet">Gamebillet</label></li>
<li><input type="checkbox" name="platform" id="gamestop" value="145"><label for="gamestop">GameStop</label></li>
<li><input type="checkbox" name="platform" id="xbone" value="146"><label for="xbone">Xbox Live</label></li>
<li><input type="checkbox" name="platform" id="arenanet" value="147"><label for="arenanet">ArenaNet</label></li>
<li><input type="checkbox" name="platform" id="bethesda" value="148"><label for="bethesda">Bethesda.net</label></li>
<li><input type="checkbox" name="platform" id="gamehag" value="149"><label for="gamehag">Gamehag</label></li>
<li><input type="checkbox" name="platform" id="kartridge" value="150"><label for="kartridge">Kartridge</label></li>
<li><input type="checkbox" name="platform" id="lootboy" value="151"><label for="lootboy">LootBoy</label></li>
<li><input type="checkbox" name="platform" id="dlhnet" value="152"><label for="dlhnet">Dlh.net</label></li>
<li><input type="checkbox" name="platform" id="giveawaysu" value="153"><label for="giveawaysu">GiveAway.su</label></li>
<li><input type="checkbox" name="platform" id="gleam" value="154"><label for="gleam">Gleam</label></li>
<li><input type="checkbox" name="platform" id="gamehunt" value="155"><label for="gamehunt">GAMEHUNT</label></li>
<li><input type="checkbox" name="platform" id="grabfreegame" value="156"><label for="grabfreegame">GrabFreeGame</label></li>
<li><input type="checkbox" name="platform" id="wgn" value="157"><label for="wgn">Who's Gaming Now?!</label></li>
<li><input type="checkbox" name="platform" id="keyjoker" value="158"><label for="keyjoker">KeyJoker</label></li>
<li><input type="checkbox" name="platform" id="devsource" value="159"><label for="devsource">From Dev / Pub</label></li>
<li><input type="checkbox" name="platform" id="blank" value="160"><label for="blank">WeGame X</label></li>
<li><input type="checkbox" name="platform" id="blank" value="161"><label for="blank">Indie Face Kick</label></li>
</ul>
</div>`);
$(`#offerStatus`).html(`<div class="statusCurrent">Creating...</div><div class="">Preparing...</div><div class="">Sending offers...</div><div class="">Completed</div>`);
$(`#offer`).prepend(`<div>
<textarea class="offer_message" name="message" id="offerMessage" placeholder="Add a public comment to automated offers that is relevant and respectful" title="optional public comment up to 255 characters" maxlength="255" style="width: 100%;"></textarea>
</div>`);
$(`#from_ratio`).attr(`max`, $(`.tradables input`).length);
$(`.tradables input[type=checkbox]`).click(() => {
const n = $(`.tradables input:checked`).length;
$(`#from_ratio`).attr(`max`, n || 1);
$(`#from_ratio`).val(Math.min(n || 1, parseInt($(`#from_ratio`).val())));
});
$(`#from_ratio`).change(() => $(`#from_ratio`).val(Math.min(parseInt($(`#from_ratio`).attr(`max`)), parseInt($(`#from_ratio`).val()))));
$(`#exchanges`).nextAll().remove();
$(`[name=offer_setup]`).remove();
$(`#exchanges`).after(`
<p>
<label for="expire_days">Offer expires in </label>
<select name="expire_days" id="expire_days">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option selected="selected">15</option>
</select>
days.
</p>
<p>
<label for="counter_preference">Counter offer is </label>
<select name="counter_preference" id="counter_preference">
<option value="-1">Discouraged, don't display counter</option>
<option value="0" selected="selected">OK, display counter</option>
<option value="1">Encouraged, bold counter</option>
</select>
.
</p>
<p>
<input type="checkbox" name="synclib" id="synclib" value="true" checked><label for="synclib">Synchronize your <a target="_blank" href="/u/${myuid}/l/">barter library</a> with <a target="_blank" href="https://store.steampowered.com/dynamicstore/userdata/">steam store userdata</a> first (RECOMMENDED).</label>
</p>
<p><button id="massSendBtn" class="addTo gborder acceptOption" style="font-weight: bold; color: green; width: 100%; height: 2em; font-size: 1.2em; cursor: pointer;">Finish and Send Automated Offers</button>`);
$(`#massSendBtn`).click((event) => {
event.preventDefault();
sendAutomatedOffers();
});
$(`[name='add_to_offer_1[]']`).attr(`name`, `offering`);
$(`#offerStatus+ div`).remove();
$(`#offerStatus`).attr(`style`, `border-top: 1px solid rgb(153, 17, 187); border-bottom: 1px solid rgb(153, 17, 187);`);
$(`.offerSlider`).get().forEach(addSlider);
});
}
function addSlider(slider) {
const min = parseInt($(slider).data(`min`)) || 0;
const max = parseInt($(slider).data(`max`)) || 1000;
const digits = max.toString().split(``).length;
const prefix = $(slider).data(`prefix`) || ``;
const suffix = $(slider).data(`suffix`) || ``;
const isToggle = max === 1;
const isPercent = suffix === `%`;
if (isToggle && !isPercent) {
$(slider).after(`<input type="hidden" value="true" name="${slider.id}">`);
} else {
$(slider).after(`<input type="hidden" value="0" name="min${slider.id}">`);
$(slider).after(`<input type="hidden" value="${max}" name="max${slider.id}">`);
}
const toggleTooltip = (val) => {
if (max === 1) {
if (isPercent) {
return val ? `100%` : `0%`;
} else {
return val ? `Yes` : `No`;
}
}
return `${prefix}${Number(val).toFixed(0)}${suffix}`;
};
const range = { min, max };
const n = Math.log10(max);
if (min === 0 && n - Math.floor(n) === 0) {
let percentage = 0;
for (let i = 1; i <= digits - 1; i++) {
percentage += 100 / (digits - 1);
range[`${percentage}%`] = Math.pow(10, i);
}
}
// eslint-disable-next-line no-undef
noUiSlider.create(slider, {
"start": isToggle && !isPercent ? max : [0, max],
"connect": !isToggle || isPercent,
"behaviour": isToggle && !isPercent ? `none` : `tap`,
"tooltips": [{ "to": toggleTooltip }].concat(isToggle && !isPercent ? [] : [{ "to": toggleTooltip }]),
"step": 1,
"range": range
}).on(`update`, (values) => {
if (isToggle && !isPercent) {
const value = parseInt(values[0]);
$(`[name="${slider.id}"]`).val(Boolean(value));
if (value) {
$(slider).addClass(`on`);
} else {
$(slider).removeClass(`on`);
}
} else {
$(`[name="min${slider.id}"]`).val(Number(values[0]).toFixed(0));
$(`[name="max${slider.id}"]`).val(Number(values[1]).toFixed(0));
}
});
if (isToggle && !isPercent) {
$(slider).find(`.noUi-connects`).click(() => slider.noUiSlider.set(parseInt(slider.noUiSlider.get()) ? 0 : 1));
}
}
function checkSettings(settings) {
if (!settings) {
settings = $(`#offer`).serializeObject();
}
settings = fixObjectTypes(settings);
if (!settings.offering) {
alert(`Please select ${settings.from_ratio} or more of your tradable(s) that you want to offer.`);
return;
}
if (!settings.offering_to) {
alert(`Please select 1 or more trader groups you want to sent offers to.`);
return;