Enhancements
This commit is contained in:
parent
02c36c06ca
commit
de47ccdec2
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h4 id="empty-accounts" style='display:none'>No decaled items from </h4>
|
<h4 id="empty-accounts" style='display:none'>No decaled items from </h4>
|
||||||
|
<h4 id="ignore-accounts" style='display:none'>Ignoring items from </h4>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
70
script.js
70
script.js
|
@ -1,31 +1,50 @@
|
||||||
var checkable_accounts = { '76561198311319887': 'Weapon Crusher' };
|
var checkable_accounts = {
|
||||||
|
'76561198311319887': 'Weapon Crusher', '76561199039790818': 'Megumin [⇄ 24/7]', '76561199140988104': 'Bela🔥⇄',
|
||||||
|
'76561198104201017': 'Daniela⚡⇄', '76561199125108615': 'Squid Girl Bot', '76561199550718094': '¹⚡️ refbot.tf',
|
||||||
|
'76561199202848205': 'The Agency', '76561199034865605': '[⇄] Amazon Prime ⚡24/7⚡'
|
||||||
|
};
|
||||||
|
var ignorable_accounts = ['76561198042562877', '76561199193118161', '76561199090583973'];
|
||||||
|
var ignored_accounts = [];
|
||||||
decaled_objects = { 'Conscientious Objector': '3.66', 'Clan Pride': '2.11', 'Flair!': '4.22', 'Photo Badge': '2.44' }
|
decaled_objects = { 'Conscientious Objector': '3.66', 'Clan Pride': '2.11', 'Flair!': '4.22', 'Photo Badge': '2.44' }
|
||||||
backpack_page_limit = 3;
|
backpack_page_limit = 10;
|
||||||
|
|
||||||
function fetchAccounts() {
|
function fetchAccounts() {
|
||||||
var deferred = new $.Deferred();
|
|
||||||
for (const [item, price] of Object.entries(decaled_objects)) {
|
for (const [item, price] of Object.entries(decaled_objects)) {
|
||||||
handleItem(item, price);
|
handleItem(item, price);
|
||||||
}
|
}
|
||||||
deferred.resolve(checkable_accounts);
|
|
||||||
return deferred.promise()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleItem(item, price) {
|
function handleItem(item, price) {
|
||||||
|
var stop = false;
|
||||||
for (let i = 1; i <= backpack_page_limit; i++) {
|
for (let i = 1; i <= backpack_page_limit; i++) {
|
||||||
|
var url = 'https://backpack.tf/classifieds';
|
||||||
|
var 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;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
dataType: 'html',
|
dataType: 'html',
|
||||||
url: 'https://backpack.tf/classifieds',
|
url: url,
|
||||||
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,
|
data: data,
|
||||||
async: false,
|
|
||||||
tryCount: 0,
|
tryCount: 0,
|
||||||
retryLimit: 3,
|
retryLimit: 20,
|
||||||
success: function (msg) {
|
success: function (msg) {
|
||||||
if ($('.col-md-6:first .alert', msg).length > 0) {
|
if ($('.col-md-6:first .alert', msg).length > 0) {
|
||||||
|
stop = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$('.col-md-6:first .user-link', msg).each(function () {
|
$('.col-md-6:first .user-link', msg).each(function () {
|
||||||
checkable_accounts[$(this).attr('data-id')] = $(this).attr('data-name');
|
var steam_id = $(this).attr('data-id');
|
||||||
|
var steam_name = $(this).attr('data-name');
|
||||||
|
if (ignorable_accounts.includes(steam_id)) {
|
||||||
|
if (!ignored_accounts.includes(steam_id)) {
|
||||||
|
var ignore_accounts = $('#ignore-accounts');
|
||||||
|
ignore_accounts.append('<a href="https://next.backpack.tf/profiles/' + steam_id + '">' + steam_name + '</a>; ');
|
||||||
|
ignore_accounts.fadeIn();
|
||||||
|
ignored_accounts.push(steam_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (!(steam_id in checkable_accounts)) {
|
||||||
|
handleAccount(steam_id, steam_name);
|
||||||
|
checkable_accounts[steam_id] = steam_name;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: function (response, status, error) {
|
error: function (response, status, error) {
|
||||||
|
@ -34,55 +53,55 @@ function handleItem(item, price) {
|
||||||
if (this.tryCount <= this.retryLimit) {
|
if (this.tryCount <= this.retryLimit) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
$.ajax(this);
|
$.ajax(this);
|
||||||
}, 3000);
|
}, 3000 + i * 300 + this.retryCount * 70 + Math.floor(Math.random() * 1000));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (stop) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAccounts() {
|
function handleAccounts() {
|
||||||
for (const [steamid64, name] of Object.entries(checkable_accounts)) {
|
for (const [steam_id, steam_name] of Object.entries(checkable_accounts)) {
|
||||||
handleAccount(steamid64, name);
|
handleAccount(steam_id, steam_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAccount(steamid64, name) {
|
function handleAccount(steam_id, steam_name) {
|
||||||
var url = "https://backpack.tf/_inventory/" + steamid64;
|
var url = "https://backpack.tf/_inventory/" + steam_id;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
url: url,
|
url: url,
|
||||||
async: false,
|
|
||||||
tryCount: 0,
|
tryCount: 0,
|
||||||
retryLimit: 3,
|
retryLimit: 30,
|
||||||
success: function (msg) { handleHTML(steamid64, name, msg['html']); },
|
success: function (msg) { handleHTML(steam_id, steam_name, msg['html']); },
|
||||||
error: function (response, status, error) {
|
error: function (response, status, error) {
|
||||||
if (response.status == 429) {
|
|
||||||
this.tryCount++;
|
this.tryCount++;
|
||||||
if (this.tryCount <= this.retryLimit) {
|
if (this.tryCount <= this.retryLimit) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
$.ajax(this);
|
$.ajax(this);
|
||||||
}, 3000);
|
}, 3000 + this.tryCount * 40 + Math.floor(Math.random() * 1000));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleHTML(steamid64, name, html_string) {
|
function handleHTML(steam_id, steam_name, html_string) {
|
||||||
html = $.parseHTML(html_string);
|
html = $.parseHTML(html_string);
|
||||||
var decaled_items = $('div.decal', html);
|
var decaled_items = $('div.decal', html);
|
||||||
if (decaled_items.length == 0) {
|
if (decaled_items.length == 0) {
|
||||||
var empty_accounts = $('#empty-accounts');
|
var empty_accounts = $('#empty-accounts');
|
||||||
empty_accounts.append('<a href="https://next.backpack.tf/profiles/' + steamid64 + '">' + name + '</a>; ');
|
empty_accounts.append('<a href="https://next.backpack.tf/profiles/' + steam_id + '">' + steam_name + '</a>; ');
|
||||||
empty_accounts.fadeIn();
|
empty_accounts.fadeIn();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var inventory = $('<div class="inventory"></div>');
|
var inventory = $('<div class="inventory"></div>');
|
||||||
inventory.append('<a href="https://next.backpack.tf/profiles/' + steamid64 + '"><h3>' + name + '</h3></a>');
|
inventory.append('<a href="https://next.backpack.tf/profiles/' + steam_id + '"><h3>' + steam_name + '</h3></a>');
|
||||||
decaled_items.each(function () {
|
decaled_items.each(function () {
|
||||||
var url = "https://next.backpack.tf/item/" + $(this).parent().attr('data-id');
|
var url = "https://next.backpack.tf/item/" + $(this).parent().attr('data-id');
|
||||||
var a = $('<a href="' + url + '"></a>');
|
var a = $('<a href="' + url + '"></a>');
|
||||||
|
@ -111,7 +130,6 @@ function handleHTML(steamid64, name, html_string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$.when(fetchAccounts()).done(function () {
|
|
||||||
handleAccounts();
|
handleAccounts();
|
||||||
});
|
fetchAccounts();
|
||||||
});
|
});
|
Loading…
Reference in New Issue