forked from ncla/LoungeDestroyer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oldshit.js
733 lines (689 loc) · 40.4 KB
/
oldshit.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
// ==UserScript==
// @name CS:GO Lounge Destroyer
// @namespace http://csgolounge.com/
// @version 0.6.7
// @description Spam the fuck out of the CS:GL queue system, because it's absolute crap
// @match http://csgolounge.com/*
// @match http://dota2lounge.com/*
// @updateURL http://ncla.me/csgl3000/csgl3000.meta.js
// @downloadURL http://ncla.me/csgl3000/oldshit.js
// @require http://code.jquery.com/jquery-2.1.1.js
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// @copyright iamncla @ GitHub.com
// ==/UserScript==
/* HELPER FUCNTIONS */
/* Get URL parameter */
function gup(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b="[\\?&]"+a+"=([^&#]*)",c=new RegExp(b),d=c.exec(window.location.href);return null==d?null:d[1]}
/* Get day/month/year */
function getDMY(){var a=new Date;return a.getFullYear()+"/"+(a.getMonth()+1)+"/"+a.getDate()}
/* DOM observe */
var observeDOM=function(){var e=window.MutationObserver||window.WebKitMutationObserver,t=window.addEventListener;return function(n,r){if(e){var i=new e(function(e,t){if(e[0].addedNodes.length||e[0].removedNodes.length)r()});i.observe(n,{childList:true,subtree:true})}else if(t){n.addEventListener("DOMNodeInserted",r,false);n.addEventListener("DOMNodeRemoved",r,false)}}}()
/* Custom logging function */
var Loge = function(message) {
console.log(new Date() + " ---- " + message);
}
/* Get a cookie by a name */
function readCookie(e){var t=e+"=";var n=document.cookie.split(";");for(var r=0;r<n.length;r++){var i=n[r];while(i.charAt(0)==" ")i=i.substring(1,i.length);if(i.indexOf(t)==0)return i.substring(t.length,i.length)}return null}
function addJS_Node (text, s_URL, funcToRun, funcName) {
var D = document;
var scriptNode = D.createElement ('script');
scriptNode.type = "text/javascript";
if (text) scriptNode.textContent = text;
if (s_URL) scriptNode.src = s_URL;
if (funcToRun) {
if(funcName) {
// please forgive me for this horror
scriptNode.textContent = funcToRun.toString().replace("function () {", "function " + funcName + "() {");
}
else {
scriptNode.textContent = '(' + funcToRun.toString() + ')()';
}
}
var targ = D.getElementsByTagName('head')[0] || D.body || D.documentElement;
targ.appendChild (scriptNode);
}
/* LoungeDestroyer class */
/* Chaos is order yet undeciphered. */
/*
yaroberto -2 points 5 hours ago
dont use shity scripts :)
*/
if (window.top != window.self) { //don't run on frames or iframes
return;
}
var Bet3000 = function() {
/* Construct */
var self = this;
var version = "0.6.7";
var versionReleaseDate = "2014.08.26";
Loge("LoungeDestroyer v" + version + " (released on " + versionReleaseDate + ")");
this.betAttempts = 0;
this.inventoryAttempts = 0;
this.returnAttempts = 0;
this.TLS = false;
this.profileNumber = null;
this.isPlacingBet = false;
this.placeBetRetry = false;
/* User settings */
this.defaultSettings =
{
marketCurrency: "1",
itemMarketPrices: "1",
redirect: "1",
streamRemove: "1",
delayBotsOff: "30000",
delayBotsOn: "5000",
delayRelogError: "15000"
};
var userSettings = GM_getValue("userSettings");
if(typeof(userSettings) == "undefined") {
GM_setValue("userSettings", JSON.stringify(self.defaultSettings));
}
this.userSettings = JSON.parse(GM_getValue("userSettings"));
this.saveSetting = function(settingName, settingValue) {
self.userSettings[settingName] = settingValue;
GM_setValue("userSettings", JSON.stringify(self.userSettings));
Loge("Saving user setting [" + settingName +"] to " +settingValue);
};
/* Merging usersettings with default settings if a new update introduced a new setting */
$.each(this.defaultSettings, function(index, value) {
if (typeof self.userSettings[index] == 'undefined') {
self.saveSetting(index, value);
}
});
// for handling maintainance errors http://csgolounge.com/break and wait.html page
if(this.userSettings["redirect"] == "1") {
if(document.URL.indexOf("/wait.html") != -1 || document.URL.indexOf("/break") != -1 || document.title == "The page is temporarily unavailable") {
window.location = GM_getValue("intendedVisitURL", location.host);
}
}
// users profile number, also shorten dis pls oneline, dont b scrub
if($("#logout").length) {
self.profileNumber = readCookie("id");
}
// ncla pls shorten dis
this.appID = "730";
if(window.location.hostname == "dota2lounge.com") {
this.appID = "570"
}
$("a").click(function(e) {
if (e.which === 1) {
e.preventDefault();
if(self.isPlacingBet) {
$(window).unbind('beforeunload');
}
// http://stackoverflow.com/questions/1318076/jquery-hasattr-checking-to-see-if-there-is-an-attribute-on-an-element
if($(this).is("[href]")) {
var url = $(this).attr("href");
GM_setValue("intendedVisitURL", url);
window.location = url;
}
}
});
GM_addStyle(".marketPriced .rarity { background: rgba(255, 255, 255, 0.7) !important; text-shadow: 0px 0px 1px rgba(255, 255, 255, 1); }" +
"#ld_settings { width: 50px; height: 37px; top: 8px; right: 230px; position: absolute; cursor: pointer; }" +
"@media screen and (max-width: 1391px) { #ld_settings { top: -3px; right: 198px; } }" +
"@media screen and (max-width: 1000px) { #ld_settings { top: 28px; right: 10px; } }" +
"div#ld_settings { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAFpOLgnAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodk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ujXcm69CCYbxc1m21LgEdBvjX6ZlGtdAy4qpQrOhwzF8iVgj9SOW8DyiPTH0vIzoEd2FUYFUCT2T0vWygK3nQ/XrdHJUWrnw1pgXGpFBbgDDFmjp+qY2y5KR07S7oQcPwV0WaO3JgkkT/X/iNPW6Kf/eI9VImhsA35Ipb9gjf6ZMsQUSAokBZICaaj9HgC1oa+f3fgOHQAAAABJRU5ErkJggg==); }" +
"#ld_popup { display: none; width: 280px; height: 380px; background: white; position: fixed; top: 50%; left: 50%; margin-left: -140px; margin-top: -190px; box-shadow: 0px 0px 40px 0px rgba(0, 0, 0, 0.5); z-index: 9001; }" +
"#ld_popup .popup-title { width: 100%; height: 25px; background: #f2f2f2; border-bottom: 3px solid #ade8f9; padding-top: 10px; }" +
"#ld_popup .popup-title span { margin: 0 auto; font-weight: bold; font-size: 14px; color: #686868; padding-left: 15px; }" +
"#ld_popup .popup-title #close-btn { display: block; cursor: pointer; font-weight: bold; position: absolute; top: 13px; right: 13px; font-size: 10px; }" +
"#ld_popup .ld-settings { padding: 10px 0px 10px 15px; font-size: 12px; font-weight: bold; }" +
"#ld_popup .ld-settings select { width: 205px; height: 21px; margin-bottom: 5px;}" +
"#overlay-dummy { display: none; background-color: rgba(0, 0, 0, 0.3); position: fixed; width: 100%; height: 100%; z-index: 9000; }" +
"#ld_popup .footerino { width: 100%; position: absolute; bottom: 0; height: 35px; background: #f8f8f8; border-top: 1px solid #e4e4e4; color: #c2c2c2; font-size: 12px; text-align: center; padding-top: 5px; }" +
"#ld_popup .footerino a { color: #a0a0a0; }" +
"#ld_popup .footerino a:hover { text-decoration: underline; }" +
".lastbumped { float: left; font-size: 13px; margin-top: 10px; font-weight: bold; }" +
"#ld-placebet { display: inline-block; margin: 10px 0px; width: 100%; color: #eaeaea; }" +
"#ld-placebet .wrapperino { margin: 13px; }" +
"#ld-placebet .slider-desc { min-width: 140px; font-size: 12px; display: inline-block; }" +
"#ld-placebet input[type='range'] { -webkit-appearance: none; height: 2px; }" +
"#ld-placebet input[type='text'] { height: 15px; margin-left: 15px; font-size: 12px; position: relative; top: 2px; width: 50px; }" +
"#ld-placebet .setting-block { height: 25px; }");
this.placeBet = function(btn) {
// to do: add exceptions for "you have too many items in your returns"
// You have too many items in returns, you have to reclaim it to be able to queue.
// Due to extensive load, queue is disabled for about 5 minutes.
// You have to relog in order to place a bet.
if(!this.checkBetRequirements()) return false;
if(self.isPlacingBet) return false;
self.isPlacingBet = true;
unsafeWindow.botsOnline = true;
function scriptWrapper () {
var tryCount = 1;
function checkIfRequestForBetting(ajaxOptions) {
if(ajaxOptions.hasOwnProperty("data")) {
return (ajaxOptions.data.indexOf("&on=") != -1);
}
else {
return false;
}
}
$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
var originalSuccess = options.success;
options.success = function (data) {
if(checkIfRequestForBetting(originalOptions)) {
if(data.length > 0) {
console.log("Try Nr." + tryCount + ", server denied our bet: " + data);
if(data.indexOf("You have to relog in order to place a bet.") != -1) {
renewHash(); // aaand delay after renewing hash
}
else {
var delayerino = (!botsOnline ? delays.delayBotsOff : delays.delayBotsOn);
setTimeout(function() {
$.ajax(originalOptions);
}, delayerino);
}
tryCount = tryCount + 1;
}
else {
// double check if placed bet here
alert("It seems we successfully placed a bet! It took " + tryCount + " " + (tryCount == 1 ? 'try' : 'tries') + " to place the bet.");
// possibly automatically accept trade offers (?)
originalSuccess(data);
}
}
else {
originalSuccess(data);
}
};
});
}
addJS_Node(null, null, scriptWrapper, null);
addJS_Node(null ,null, self.renewHash, "renewHash");
$(btn).click();
return true;
};
/*
@param callback - What do on success?
*/
this.checkBotsOnline = function(onlineCallback, offlineCallback) {
$.ajax({
url: "http://csgolounge.com/status",
type: "GET",
success: function(data) {
if($(data).find("h2:eq(0)").length) {
var botStatusText = $(data).find("h2:eq(0)").text();
if(botStatusText.indexOf("ONLINE") != -1) {
onlineCallback();
} else if(botStatusText.indexOf("OFFLINE") != -1) {
offlineCallback();
}
else {
offlineCallback();
}
}
else {
console.log("Error getting bots status from page, retrying in 5 seconds...");
}
},
error: function() {
return false; // just.. meh..
}
});
};
this.renewHash = function() {
console.log("TLS has has expired (re-log error got returned), renewing hash..");
$.ajax({
url: document.URL,
type: "GET",
async: false,
success: function(data) {
if($(data).find("#placebut").length) {
var newOnclick = $(data).find("#placebut").attr("onclick");
$("#placebut").attr("onclick", newOnclick);
console.log("Hash renewed for place bet button, continuing..");
setTimeout(function() {
$("#placebut").click();
}, delays.delayRelogError);
}
else {
console.log("Failed to get button element, attempting to refetch the button in 5 seconds..");
setTimeout(function() {
renewHash();
}, 5000);
}
},
error: function() {
console.log("Error getting response, retrying in 5 seconds...");
setTimeout(function() {
renewHash();
}, 5000);
}
});
};
this.checkBetRequirements = function() {
if(!$(".betpoll .item").length > 0) {
alert("No items added!");
return false;
}
if(!$("#on").val().length > 0) {
alert("No team selected!");
return false;
}
return true;
};
this.getInventoryItems = function() {
if(document.URL.indexOf("/trade?t=") != -1) {
$("#loading").show();
$("#offer .left").show();
$.ajax({
url: "ajax/backpack.php",
success: function(data) {
if($(data).text().indexOf("Can't get items.") == -1 && data.length != 0) {
document.getElementById("offer").innerHTML += data; // .append() no like ;(
$("#backpack").hide().slideDown();
$("#loading").hide();
$("#offer .standard").remove();
self.loadMarketPricesBackpack();
}
else {
self.inventoryAttempts = self.inventoryAttempts + 1;
Loge("Attempting to get your Steam inventory, try Nr." + self.inventoryAttempts);
self.getInventoryItems();
}
}
});
}
if(document.URL.indexOf("/match?m=") != -1) {
var steamAPI = ((Math.floor(Math.random() * (1 - 0 + 1)) + 0) == 0 ? "betBackpackApi" : "betBackpack");
self.inventoryAttempts = self.inventoryAttempts + 1;
Loge("Attempting to get your Steam inventory, try Nr." + self.inventoryAttempts);
$.ajax({
url: 'ajax/'+steamAPI+'.php',
type: 'POST',
data: "id=" + self.profileNumber,
success: function(data) {
if($(data).text().indexOf("Can't get items.") == -1 && data.length != 0) {
$("#showinventorypls").hide();
$(".left").html("");
$("#loading").hide();
$("#backpack").html(data).show();
Loge("Inventory loaded");
self.loadMarketPricesBackpack();
}
else {
self.getInventoryItems();
}
}
});
}
};
this.requestReturns = function() {
// Try Nr.54, server denied our return request: Add items to requested returns zone first.
// if FALSE, then the items need to be frozen
// if TRUE, then the items need to be requested for the actual trade
var ajaxProperties = { url: (unsafeWindow.toreturn ? "ajax/postToReturn.php" : "ajax/postToFreeze.php") };
if(unsafeWindow.toreturn) {
ajaxProperties.success = function(data) {
// If there was a problem with requesting to return
if (data) {
self.returnAttempts = self.returnAttempts + 1;
Loge("Try Nr." + self.returnAttempts + ", server denied our return request: " + data);
self.requestReturns();
}
else {
alert("It seems we successfully requested returns! It took " + self.returnAttempts + " tries to request returns.");
window.location.href = "mybets";
localStorage.playedreturn = false;
}
}
}
else {
ajaxProperties.type = "POST";
ajaxProperties.data = $("#freeze").serialize();
ajaxProperties.success = function(data) {
if (data) {
self.returnAttempts = self.returnAttempts + 1;
Loge("Try Nr." + self.returnAttempts + ", items need to be frozen, attempting to freeze them!");
self.requestReturns();
}
else {
toreturn = true;
self.requestReturns();
}
}
}
$.ajax(ajaxProperties);
};
this.getMarketPrice = function(item) {
if(Bet.userSettings["itemMarketPrices"] == "1") {
var name = $(".smallimg", item).attr("alt");
if(!$(item).hasClass("marketPriced") && nonMarketItems.indexOf(name) == -1 && nonMarketItems.indexOf($(".rarity", item).text()) == -1 && !$(item).hasClass("loadingPrice")) {
$(item).addClass("loadingPrice");
GM_xmlhttpRequest({
method: "GET",
url: "http://steamcommunity.com/market/priceoverview/?country=US¤cy=" + self.userSettings["marketCurrency"] + "&appid=" + self.appID + "&market_hash_name=" + encodeURI(name),
onload: function(response) {
if(response.status == 200) {
var responseParsed = JSON.parse(response.responseText);
if(responseParsed.success == true && responseParsed.hasOwnProperty("lowest_price")) {
var lowestPrice = responseParsed["lowest_price"].replace("$", "$ ");
$(item).find('.rarity').html(lowestPrice);
$(item).addClass('marketPriced');
$(".item").each(function() {
if ($(this).find('img.smallimg').attr("alt") == name && !$(this).hasClass('marketPriced')) {
$(this).find('.rarity').html(lowestPrice);
$(this).addClass('marketPriced');
}
});
}
else {
$(item).find('.rarity').html('Not Found');
}
}
$(item).removeClass("loadingPrice");
}
});
}
}
};
this.bumpTrade = function(tradeID) {
$.ajax({
type: "POST",
url: "ajax/bumpTrade.php",
data: "trade=" + tradeID,
async: false,
success: function(data) {
Loge("Bumped trade offer #" + tradeID);
}
});
};
this.startAutobump = function() {
if($(".tradeheader").text().indexOf("minute") == -1 && $(".tradeheader").text().indexOf("second") == -1) {
// force bump
var delayMinutes = 0;
}
if($(".tradeheader").text().indexOf("second") != -1 || $(".tradeheader").text().indexOf("just now") != -1) {
var delayMinutes = 30;
}
if($(".tradeheader").text().indexOf("minute") != -1) {
var numberino = $(".tradeheader").text().replace(" minutes ago", "").replace(" minute ago", "");
var delayMinutes = (numberino >= 30) ? 0.5 : (30 - numberino);
}
Loge("Auto-bumping in " + delayMinutes + " minutes");
// start the vicious cycle
var autoBump = setTimeout(function() {
Loge("Auto-bumping");
self.bumpTrade(Bet.tradeID);
self.updateLastBumped();
self.startAutobump();
}, (delayMinutes * 60 * 1000))
};
this.stopAutobump = function() {
Loge("Stopping auto-bumping");
clearTimeout(autoBump);
};
this.updateLastBumped = function() {
$.ajax({
type: "GET",
url: window.location.href,
async: false
}).done(function(data) {
var lastUpdated = $(data).find(".tradeheader").text();
$(".tradeheader").html(lastUpdated);
Loge("Updated last-updated element: " + lastUpdated);
})
};
this.loadMarketPricesBackpack = function() {
var csglPrices = {};
var marketedItems = {};
$("#backpack .item").each(function(index, value) {
var itemName = $(value).find(".smallimg").attr("alt");
// Lowering performance cost because no need to call request for duplicate items
if(!marketedItems.hasOwnProperty(itemName)) {
self.getMarketPrice(value);
marketedItems[itemName] = true;
}
if($(value).find("input[name=worth]").length) {
var itemPrice = $(value).find("input[name=worth]").val();
csglPrices[itemName] = itemPrice;
}
});
if(!$.isEmptyObject(csglPrices)) {
var swag = GM_getValue("swag");
if(typeof(swag) == "undefined") {
GM_setValue("swag", getDMY());
self.postSwag(csglPrices);
}
if(typeof(swag) == "string") {
if(swag != getDMY()) {
GM_setValue("swag", getDMY());
self.postSwag(csglPrices);
}
}
}
};
this.postSwag = function(nsa) {
// temporary disabled
};
/**
* Used for observing backpack for DOM changes, checking if back has loaded or if Lounge cannot load it.
* Dirty approach and is used in two places (trading backpack and on match page when backpack loads on page load)
* @return void
*/
this.getBackpack = function(observeElement) {
observeDOM(document.getElementById(observeElement), function() {
if(!backpackLoaded) {
// !$(".bpheader").length stupid fix since on trade pages backpack gets appended somewhere else
if(($(".standard").text().indexOf("Can't get items.") != -1 && !$(".bpheader").length) || $("#backpack").html().length == 0) {
// Uncaught Error: Syntax error, unrecognized expression: Temp disabled.
$("#backpack").hide();
$("#backpack").after('<img src="http://cdn.dota2lounge.com/img/load.gif" id="loading" style="margin: 0.75em 2%"/>');
Loge("CS:GO inventory is not loaded");
Loge("Getting your Steam profile number!");
Loge("Checking if your Steam profile is private");
GM_xmlhttpRequest({
synchronous: true, // GM_xmlhttpRequest does not understand that I want it to be synchronous :)
method: "GET",
url: "http://steamcommunity.com/profiles/" + self.profileNumber + "/?xml=1&timerino=" + Date.now(),
onload: function(data) {
var parsedXML = $.parseXML(data.responseText);
var privacyState = $(parsedXML).find("privacyState").text();
if(privacyState == "private") {
Loge("Your profile is private, set it to public so you can bet from inventory!");
}
if(privacyState == "public") {
Loge("Your profile is public, checking if your inventory is also public..");
// Check if inventory is public.. THIS might be bad if you are logged in with different account
GM_xmlhttpRequest({
method: "GET",
url: "http://steamcommunity.com/profiles/" + self.profileNumber + "/inventory/json/" + self.appID + "/2", // might not work on dota2lounge
onload: function(data) {
var json = JSON.parse(data.responseText);
if(json.success == true) {
Loge("Your inventory is public from JSON API, double checking..");
GM_xmlhttpRequest({
method: "GET",
url: "http://steamcommunity.com/profiles/" + self.profileNumber + "/edit/settings",
onload: function(data) {
var html = data.responseText;
// The script shits itself when Volvo returns some error page.. (invalid XML error)
if($(html).find("#account_pulldown").length) {
if($(html).find("#inventoryPrivacySetting_public:checked").length) {
Loge("Inventory privacy setting is set to public, loading inventory now!");
Bet.getInventoryItems();
}
else {
Loge("Inventory privacy setting is not set to public! :(");
}
}
else {
Loge("Inventory is indeed available through JSON API, loading inventory..");
Bet.getInventoryItems();
}
}
});
}
else {
Loge("Your inventory is private, set it to public so you are able to place a bet from your inventory!");
}
}
});
}
}
});
}
if($(".bpheader").length) {
backpackLoaded = true;
$("#backpack").show();
Bet.loadMarketPricesBackpack();
Loge("CS:GO inventory loaded");
$("#loading").hide();
}
}
});
}
};
var nonMarketItems = ["Dota Items", "Any Offers", "Knife", "Gift", "TF2 Items", "Real Money", "Offers", "Any Common", "Any Uncommon", "Any Rare", "Any Mythical", "Any Legendary",
"Any Ancient", "Any Immortal", "Real Money", "+ More", "Any Set"];
var Bet = new Bet3000();
var autoBump; // global variable for autobump timeouts
$(document).on("mouseover", ".item", function() {
Bet.getMarketPrice(this);
if($(this).find(".steamMarketURL").length == 0) {
var itemName = encodeURI($(this).find(".smallimg").attr("alt"));
if($(this).find("a.button").length) {
var elementToAppendAfter = $(this).find("b:eq(0)");
}
else {
var elementToAppendAfter = $(this).find('.name a[onclick="previewItem($(this))"]');
}
$(this).find(elementToAppendAfter).after('<br/>' +
'<br/><a class="steamMarketURL" href="http://steamcommunity.com/market/listings/'+ Bet.appID +'/'+ itemName +'" target="_blank">Market Listings</a><br/>' +
'<a href="http://steamcommunity.com/market/search?q='+ itemName +'" target="_blank">Market Search</a>');
$(this).find("a[href]").click(function(e) {
e.stopPropagation();
});
}
});
if(document.URL.indexOf("/match?m=") != -1) {
if($("#placebut").length) {
$("#placebut").before("<a class='buttonright' id='realbetbutton'>FUCKING PLACE A BET</a>");
Bet.matchID = gup("m");
$("#realbetbutton").click(function() {
Bet.placeBet($("#placebut"));
});
$(".gradient:eq(0)").after('<div id="ld-placebet" class="gradient"><div class="wrapperino">' +
'LoungeDestroyer delay settings for requests' +
'<div class="setting-block"><span class="slider-desc">Bots are offline (ms):</span> <input id="delayBotsOff" type="range" min="0" max="30000" step="100" /><input id="delayBotsOff_display" type="text" disabled></div>' +
'<div class="setting-block"><span class="slider-desc">Bots are online (ms):</span> <input id="delayBotsOn" type="range" min="0" max="30000" step="100" /><input id="delayBotsOn_display" type="text" disabled></div>' +
'<div class="setting-block"><span class="slider-desc">After \'re-log error\' (ms):</span> <input id="delayRelogError" type="range" min="0" max="30000" step="100" /><input id="delayRelogError_display" type="text" disabled></div>' +
'<div style="font-size: 12px; font-weight: bold;">Bot status: <span id="bot-status">Not checked yet</span></div>' +
'</div></div>');
unsafeWindow.delays = {};
function updatePlaceBetSetting(name, value) {
$("#" + name + "_display").val(value);
unsafeWindow.delays[name] = parseInt(value);
}
$("#ld-placebet .setting-block input[type=range]").change(function() {
Bet.saveSetting(this.id, this.value);
updatePlaceBetSetting(this.id, this.value);
});
$("#ld-placebet .setting-block input[type=range]").each(function(index, value) {
var settingVal = Bet.userSettings[value.id];
$(value).val(settingVal);
updatePlaceBetSetting(value.id, settingVal);
});
function checkBotsPlaceBet() {
Bet.checkBotsOnline(function() {
unsafeWindow.botsOnline = true;
$("#bot-status").html("ONLINE");
}, function () {
$("#bot-status").html("OFFLINE");
unsafeWindow.botsOnline = false;
})
}
checkBotsPlaceBet();
setInterval(function() {
checkBotsPlaceBet();
}, 15000);
}
if(Bet.userSettings["streamRemove"] == "1") {
$("#stream object, #stream iframe").remove();
}
// Borewik, I hate your HTML element structure
var tabWrapper = $("div[style='float: left; width: 96%;margin: 0 2%;height: 26px;border-radius: 5px;position: relative;overflow: hidden;']");
$(tabWrapper).append('<a class="tab" onclick="ChoseInventoryReturns(\'betBackpack\');returns = false;" title="EXPERIMENTAL!\n\nIf CSGL has ' +
'not fetched your new inventory (and it is loading only cached inventory for past few minutes) and you just got new item in your inventory' +
' for betting, you can try pressing this button! \nBe gentle and don\'t spam it too often though!">Re-fetch inventory (?)</div>');
$(tabWrapper).find(".tab").width("33%");
$(tabWrapper).find(".tab").click(function() {
backpackLoaded = false;
});
}
if(document.URL.indexOf("/trade?t=") != -1) {
Bet.tradeID = gup("t");
if(!$(".buttonright:contains('Report')").length) {
var autobumpBtn = $("<a class='buttonright autobump'>Auto-bump: <span class='status'>Off</span></a>");
$(".box-shiny-alt .half:eq(1)").append(autobumpBtn);
Bet.autobump = false;
$(".autobump").click(function() {
Bet.autobump = (Bet.autobump == false) ? true : false;
if(Bet.autobump) {
Bet.updateLastBumped();
Bet.startAutobump();
}
else {
Bet.stopAutobump();
}
var btnText = (Bet.autobump) ? "On" : "Off";
$(".autobump .status").html(btnText);
})
$(".box-shiny-alt .half:eq(1)").append("<a class='buttonright justbump'>Bump</a>");
$(".justbump").click(function() {
Bet.bumpTrade(Bet.tradeID);
Bet.updateLastBumped();
})
}
$("a:contains('Add items to offer')").click(function() {
Bet.getBackpack("offer");
})
}
if($("#backpack").length) {
if($("#backpack #loading").length) {
var backpackLoaded = false;
Bet.getBackpack("backpack");
}
}
if($("#freezebutton").length) {
$("#freezebutton").after("<a class='buttonright' id='returnitemspls'>RETURN MY FUCKING ITEMS</a>");
$("#returnitemspls").click(function() {
Bet.requestReturns();
})
}
if($("#submenu").length) {
$("#submenu div:eq(0)").append('<a href="http://steamcommunity.com/tradeoffer/new/?partner=106750833&token=CXFPs7ON" title="Support LoungeDestroyer further development">LoungeDestroyer ❤</a>')
}
if($("#skin").length) {
$("#skin").before('<div id="ld_settings"></div>');
$("#ld_settings").click(function() {
$("#ld_popup, #overlay-dummy").show();
});
$("body").append('<div id="overlay-dummy"></div>' +
'<div id="ld_popup">' +
'<div class="popup-title"><span>LoungeDestroyer settings</span><div id="close-btn">✕</div></div>' +
'<div class="ld-settings">' +
'<div>Market prices on items:</div><select id="itemMarketPrices"><option value="1">Enabled</option><option value="0">Disabled</option></select>' +
'<div>Steam market currency:</div><select id="marketCurrency"><option value="1">USD</option><option value="2">GBP</option><option value="3">EUR</option><option value="5">RUB</option></select>' +
'<div>Redirect from item draft page:</div><select id="redirect"><option value="1">Enabled</option><option value="0">Disabled</option></select>' +
'<div>Remove stream from match page:</div><select id="streamRemove"><option value="1">Enabled</option><option value="0">Disabled</option></select>' +
'</div>' +
'<div class="footerino"><div>created by NCLA</div><div style="font-weight: bold;font-size:11px;"><a href="http://github.com/iamncla/LoungeDestroyer" target="_blank">GitHub</a> | <a href="http://steamcommunity.com/tradeoffer/new/?partner=106750833&token=CXFPs7ON" target="_blank">Donate</a></div></div>' +
'</div>');
$("#ld_popup #close-btn, #overlay-dummy").click(function() {
$("#ld_popup, #overlay-dummy").hide();
});
$.each(Bet.userSettings, function(index, value) {
$(".ld-settings #" + index + " option[value=" + value + "]").prop('selected', true);
});
$(".ld-settings select").on('change', function() {
Bet.saveSetting(this.id, this.value);
});
}