Nuklon / Steam-Economy-Enhancer

Enhances the Steam Inventory and Steam Market.
MIT License
1.59k stars 180 forks source link

[Suggestion] Add a button to hide inventory cards #178

Open darkdroider opened 1 year ago

darkdroider commented 1 year ago

Add a button to hide inventory cards. Some cards you reserve for crafting badges or for collecting, and don't want to sell them. It would be interesting to be able to hide them, in order to leave only the tradable cards showing. Thus facilitating, visualize and sell with the script.

disanyixing commented 1 year ago
(function ($, async) {
    $.noConflict(true);

    var NotSellCard = {
        1: {//account1
            218410: true,
            619390: true,
            1186460: true,
            399120: true,
        },
        2: {//account2
            766280: true,
            548840: true,
        },
    }
    ……
})(jQuery, async);
function sellAllCards() {
    loadAllInventories().then(function () {
        var items = getInventoryItems();
        var filteredItems = [];

        items.forEach(function (item) {
            if (!getIsTradingCard(item) || !item.marketable) {
                return;
            }

            let str = item.description.market_hash_name;
            let index = str.indexOf('-');
            let gameid = str.slice(0, index);
            let result = {};
            let flag = 0;
            for (let key in NotSellCard) {
                result[key] = {};
                for (let subKey in NotSellCard[key]) {
                    if (subKey == gameid) {
                        flag = 1;
                    }
                }
            }

            if (flag == 1) {
                console.log('Do not sell ' + gameid + ' card.');
            } else {
                filteredItems.push(item);
            }
        });

        sellItems(filteredItems);
    }, function () {
        logDOM('Could not retrieve the inventory...');
    });
}

When the game ID in NotSellCard, you click 'Sell All Cards' button, which will not sell the game ID cards.

The above code will not sell all cards with game ID 218410,619390,1186460,399120,766280,548840.