Skip to content

Instantly share code, notes, and snippets.

@lukeramsden
Last active April 15, 2022 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukeramsden/d1aa21800aa8c87678edeb972f763fc6 to your computer and use it in GitHub Desktop.
Save lukeramsden/d1aa21800aa8c87678edeb972f763fc6 to your computer and use it in GitHub Desktop.
Accept All Steam Trade Offers With Steam Inventory Helper

Install Steam Inventory Helper, then copy and paste this script in to your browser console. Will accept each trade offer one-by-one with a 3.5 second interval. Uses a nice little ratelimiting function I found on StackOverflow.

// http://jsfiddle.net/dandv/47cbj/
function RateLimit(fn, delay, context) {
var queue = [], timer = null;
function processQueue() {
var item = queue.shift();
if (item)
fn.apply(item.context, item.arguments);
if (queue.length === 0)
clearInterval(timer), timer = null;
}
return function limited() {
queue.push({
context: context || this,
arguments: [].slice.call(arguments)
});
if (!timer) {
processQueue(); // start immediately on the first invocation
timer = setInterval(processQueue, delay);
}
}
}
var AcceptTrade = RateLimit(function(id) {
console.log(`Accept Trade ${id}`);
eval(`AcceptTradeOffer("${id}")`);
}, 3500);
$J('a.btn_grey_grey.btn_es_decline').each(function(i, e) {
AcceptTrade(e.href.replace('javascript:DeclineTradeOffer("',"").replace('");', ""));
});
@unek
Copy link

unek commented Apr 15, 2022

// http://jsfiddle.net/dandv/47cbj/
function RateLimit(fn, delay, context) {
    var queue = [], timer = null;

    function processQueue() {
        var item = queue.shift();
        if (item)
            fn.apply(item.context, item.arguments);
        if (queue.length === 0)
            clearInterval(timer), timer = null;
    }

    return function limited() {
        queue.push({
            context: context || this,
            arguments: [].slice.call(arguments)
        });
        if (!timer) {
            processQueue();  // start immediately on the first invocation
            timer = setInterval(processQueue, delay);
        }
    }
}

var AcceptTrade = RateLimit(function(id) {
    console.log(`Accept Trade ${id}`);
    eval(`AcceptTradeOffer("${id}")`);
}, 3500);

$J('.tradeoffer_footer_actions .whiteLink:last-child').each(function(i, e) {
    AcceptTrade(e.href.replace('javascript:DeclineTradeOffer( \'',"").replace('\');', ""));
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment