var checkable_accounts = { '76561198311319887': 'Weapon Crusher' }; decaled_objects = { 'Conscientious Objector': '3.66', 'Clan Pride': '2.11', 'Flair!': '4.22', 'Photo Badge': '2.44' } backpack_page_limit = 3; function fetchAccounts() { var deferred = new $.Deferred(); for (const [item, price] of Object.entries(decaled_objects)) { handleItem(item, price); } deferred.resolve(checkable_accounts); return deferred.promise() } function handleItem(item, price) { for (let i = 1; i <= backpack_page_limit; i++) { $.ajax({ dataType: 'html', url: 'https://backpack.tf/classifieds', data: 'page=' + i + '&item=' + encodeURIComponent(item) + '&quality=6&tradable=1&craftable=1&australium=-1&killstreak_tier=0&numeric=price&comparison=lt&value=' + price + '&low=' + price, async: false, tryCount: 0, retryLimit: 3, success: function (msg) { if ($('.col-md-6:first .alert', msg).length > 0) { return false; } $('.col-md-6:first .user-link', msg).each(function () { checkable_accounts[$(this).attr('data-id')] = $(this).attr('data-name'); }); }, error: function (response, status, error) { if (response.status == 429) { this.tryCount++; if (this.tryCount <= this.retryLimit) { setTimeout(() => { $.ajax(this); }, 3000); return; } } } }); } } function handleAccounts() { for (const [steamid64, name] of Object.entries(checkable_accounts)) { handleAccount(steamid64, name); } } function handleAccount(steamid64, name) { var url = "https://backpack.tf/_inventory/" + steamid64; $.ajax({ dataType: 'json', url: url, async: false, tryCount: 0, retryLimit: 3, success: function (msg) { handleHTML(steamid64, name, msg['html']); }, error: function (response, status, error) { if (response.status == 429) { this.tryCount++; if (this.tryCount <= this.retryLimit) { setTimeout(() => { $.ajax(this); }, 3000); return; } } } }); } function handleHTML(steamid64, name, html_string) { html = $.parseHTML(html_string); var decaled_items = $('div.decal', html); if (decaled_items.length == 0) { var empty_accounts = $('#empty-accounts'); empty_accounts.append('' + name + '; '); empty_accounts.fadeIn(); return false; } var inventory = $('
'); inventory.append('