Last active
February 14, 2016 21:10
-
-
Save lilliliilil/e8fad459da390c63bdb6 to your computer and use it in GitHub Desktop.
Installation link: https://gist.github.com/thepheer/e8fad459da390c63bdb6/raw/Steam%2520Mass%2520Decline.user.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==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