Filter expensive items

This commit is contained in:
Abhorrent_Anger 2024-03-21 14:50:16 +02:00
parent de47ccdec2
commit 24854f3e10
2 changed files with 33 additions and 13 deletions

View File

@ -14,8 +14,9 @@
</head> </head>
<body> <body>
<h4 id="filtered-accounts" style='display:none'>Filtered items from </h4>
<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> <h4 id="ignored-accounts" style='display:none'>Ignored items from </h4>
</body> </body>
</html> </html>

View File

@ -1,9 +1,9 @@
var checkable_accounts = { var checkable_accounts = {
'76561198311319887': 'Weapon Crusher', '76561199039790818': 'Megumin [⇄ 24/7]', '76561199140988104': 'Bela🔥⇄', '76561198311319887': 'Weapon Crusher', '76561199039790818': 'Megumin', '76561199140988104': 'Bela',
'76561198104201017': 'Daniela⚡⇄', '76561199125108615': 'Squid Girl Bot', '76561199550718094': '¹⚡️ refbot.tf', '76561198104201017': 'Daniela', '76561199125108615': 'Squid Girl Bot', '76561199550718094': 'refbot.tf',
'76561199202848205': 'The Agency', '76561199034865605': '[⇄] Amazon Prime ⚡24/7⚡' '76561199202848205': 'The Agency', '76561199034865605': 'Amazon Prime'
}; };
var ignorable_accounts = ['76561198042562877', '76561199193118161', '76561199090583973']; var ignorable_accounts = ['76561198042562877', '76561199193118161', '76561199090583973', '76561198103306049'];
var ignored_accounts = []; 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 = 10; backpack_page_limit = 10;
@ -35,7 +35,7 @@ function handleItem(item, price) {
var steam_name = $(this).attr('data-name'); var steam_name = $(this).attr('data-name');
if (ignorable_accounts.includes(steam_id)) { if (ignorable_accounts.includes(steam_id)) {
if (!ignored_accounts.includes(steam_id)) { if (!ignored_accounts.includes(steam_id)) {
var ignore_accounts = $('#ignore-accounts'); var ignore_accounts = $('#ignored-accounts');
ignore_accounts.append('<a href="https://next.backpack.tf/profiles/' + steam_id + '">' + steam_name + '</a>; '); ignore_accounts.append('<a href="https://next.backpack.tf/profiles/' + steam_id + '">' + steam_name + '</a>; ');
ignore_accounts.fadeIn(); ignore_accounts.fadeIn();
ignored_accounts.push(steam_id); ignored_accounts.push(steam_id);
@ -91,27 +91,46 @@ function handleAccount(steam_id, steam_name) {
}); });
} }
function getHiddenAccountLink(steam_id, steam_name) {
return '<a href="https://next.backpack.tf/profiles/' + steam_id + '">' + steam_name + '</a>; ';
}
function handleHTML(steam_id, steam_name, html_string) { function handleHTML(steam_id, steam_name, html_string) {
html = $.parseHTML(html_string); var html = $.parseHTML(html_string);
var filtered_item_count = 0;
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/' + steam_id + '">' + steam_name + '</a>; '); empty_accounts.append(getHiddenAccountLink(steam_id, steam_name));
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/' + steam_id + '"><h3>' + steam_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 parent = $(this).parent();
if (parent.hasClass('q-440-11') || parent.hasClass('nocraft') || parent.attr('data-listing_price').indexOf('keys') >= 0) {
filtered_item_count++;
return;
}
var url = "https://next.backpack.tf/item/" + parent.attr('data-id');
var a = $('<a href="' + url + '"></a>'); var a = $('<a href="' + url + '"></a>');
a.append($(this).parent()); a.append(parent);
inventory.append(a); inventory.append(a);
}); });
if (filtered_item_count) {
var link = getHiddenAccountLink(steam_id, steam_name);
link.prepend('(' + filtered_item_count + ') ')
$('#filtered-accounts').append(link);
$('#filtered-accounts').fadeIn();
}
var item_count = inventory.children().length - 1;
if (item_count <= 0) {
return false;
}
var inventories = $('.inventory'); var inventories = $('.inventory');
if (inventories.length > 0) { if (inventories.length > 0) {
var child_count = inventory.children().length; inventory.attr('data-items', item_count);
inventory.attr('data-items', child_count);
var last_div = null; var last_div = null;
inventories.each(function () { inventories.each(function () {
if (child_count > $(this).children().length) { if (child_count > $(this).children().length) {
@ -125,7 +144,7 @@ function handleHTML(steam_id, steam_name, html_string) {
$('body').prepend(inventory); $('body').prepend(inventory);
} }
} else { } else {
$('#empty-accounts').before(inventory); $('#filtered-accounts').before(inventory);
} }
} }