Skip to content

Instantly share code, notes, and snippets.

@lilliliilil
Last active February 14, 2016 21:10
Show Gist options
  • Select an option

  • Save lilliliilil/e8fad459da390c63bdb6 to your computer and use it in GitHub Desktop.

Select an option

Save lilliliilil/e8fad459da390c63bdb6 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Steam Mass Decline
// @version 0.1
// @match *://steamcommunity.com/*/tradeoffers/
// @grant none
// ==/UserScript==
var controls = document.querySelector('.rightcol_controls_content'),
button = controls.appendChild(document.createElement('div')),
label = button.appendChild(document.createElement('span'));
function decline(id) {
return ActOnTradeOffer(id, 'decline', 'Trade Declined', 'Decline Trade');
}
function declineAll() {
var links = document.querySelectorAll('.tradeoffer_footer_actions > :last-child'),
ids = [].slice.call(links).map(function (a) { return +a.href.split("'")[1]; });
return Promise.all(ids.map(decline));
}
function disableButton() {
button.disabled = true;
button.classList.add('btn_disabled');
}
function enableButton() {
button.disabled = false;
button.classList.remove('btn_disabled');
}
label.textContent = 'DECLINE THEM ALL';
button.className = 'btn_grey_grey_outer_bevel btn_small new_trade_offer_btn';
button.style.marginTop = '1em';
button.addEventListener('click', function () {
if(button.disabled) return;
disableButton();
declineAll().catch(console.error.bind(console)).then(enableButton);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment