From 24854f3e1032d1d8c5ffead97006e0cff581fb86 Mon Sep 17 00:00:00 2001 From: Abhorrent_Anger Date: Thu, 21 Mar 2024 14:50:16 +0200 Subject: [PATCH] Filter expensive items --- index.html | 3 ++- script.js | 43 +++++++++++++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index 58ecd48..763dabf 100644 --- a/index.html +++ b/index.html @@ -14,8 +14,9 @@ + - + \ No newline at end of file diff --git a/script.js b/script.js index cfc67c8..24a87a8 100644 --- a/script.js +++ b/script.js @@ -1,9 +1,9 @@ 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⚡' + '76561198311319887': 'Weapon Crusher', '76561199039790818': 'Megumin', '76561199140988104': 'Bela', + '76561198104201017': 'Daniela', '76561199125108615': 'Squid Girl Bot', '76561199550718094': 'refbot.tf', + '76561199202848205': 'The Agency', '76561199034865605': 'Amazon Prime' }; -var ignorable_accounts = ['76561198042562877', '76561199193118161', '76561199090583973']; +var ignorable_accounts = ['76561198042562877', '76561199193118161', '76561199090583973', '76561198103306049']; var ignored_accounts = []; decaled_objects = { 'Conscientious Objector': '3.66', 'Clan Pride': '2.11', 'Flair!': '4.22', 'Photo Badge': '2.44' } backpack_page_limit = 10; @@ -35,7 +35,7 @@ function handleItem(item, price) { var steam_name = $(this).attr('data-name'); if (ignorable_accounts.includes(steam_id)) { if (!ignored_accounts.includes(steam_id)) { - var ignore_accounts = $('#ignore-accounts'); + var ignore_accounts = $('#ignored-accounts'); ignore_accounts.append('' + steam_name + '; '); ignore_accounts.fadeIn(); ignored_accounts.push(steam_id); @@ -91,27 +91,46 @@ function handleAccount(steam_id, steam_name) { }); } +function getHiddenAccountLink(steam_id, steam_name) { + return '' + steam_name + '; '; +} + 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); if (decaled_items.length == 0) { var empty_accounts = $('#empty-accounts'); - empty_accounts.append('' + steam_name + '; '); + empty_accounts.append(getHiddenAccountLink(steam_id, steam_name)); empty_accounts.fadeIn(); return false; } var inventory = $('
'); inventory.append('

' + steam_name + '

'); 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.append($(this).parent()); + a.append(parent); 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'); if (inventories.length > 0) { - var child_count = inventory.children().length; - inventory.attr('data-items', child_count); + inventory.attr('data-items', item_count); var last_div = null; inventories.each(function () { if (child_count > $(this).children().length) { @@ -125,7 +144,7 @@ function handleHTML(steam_id, steam_name, html_string) { $('body').prepend(inventory); } } else { - $('#empty-accounts').before(inventory); + $('#filtered-accounts').before(inventory); } }