Last active
February 9, 2022 14:26
-
-
Save sergiosusa/dc395ed41d59175ff93239b82ca368e9 to your computer and use it in GitHub Desktop.
Bring some utilities to the Steam Trade Matcher results page.
This file contains 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 Steamtrade Matcher Scan Utilities | |
// @namespace http://sergiosusa.com | |
// @version 0.3 | |
// @description Bring some utilities to the Steam Trade Matcher results page. | |
// @author Sergio Susa ([email protected]) | |
// @match http://www.steamtradematcher.com/compare | |
// @match https://www.steamtradematcher.com/compare | |
// @grant none | |
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js | |
// ==/UserScript== | |
const BOT_USER = '(Trade bot)'; | |
const STM_USER = '(STM user)'; | |
(function() { | |
'use strict'; | |
$.noConflict(); | |
jQuery( document ).ready(function() { | |
insertGraphicElements(); | |
}); | |
})(); | |
function insertGraphicElements() { | |
var progressDiv = $('#progress-div')[0]; | |
var html = '<div class="panel panel-default" id="utilities-div">' + | |
'<div class="panel-heading">' + | |
'<h3 class="panel-title">Filter Utilities</h3>' + | |
'</div>' + | |
'<div class="panel-body"> ' + | |
'<div id="show-trade-bots-btn" class="trade-button">Show trade bots</div>' + | |
'<div id="show-non-trade-bots-btn" class="trade-button">Show non trade bots</div>' + | |
'<div id="show-all-btn" class="trade-button">Show all</div>' + | |
'<hr>'+ | |
'<div id="order-by-trade-quantity-btn" class="trade-button">Order by trade quantity</div>' + | |
'<hr>'+ | |
'<div id="open-trades-btn" class="trade-button">Open the first <input style="width: 23px;height: 23px;" id="numTrades" type="text" value="3" > trades</div>' + | |
'</div>' + | |
'</div>'; | |
var newElement = document.createElement('div'); | |
newElement.innerHTML = html; | |
insertBefore(newElement, progressDiv); | |
var showTradeBotsBtn = document.getElementById('show-trade-bots-btn'); | |
showTradeBotsBtn.onclick = function() { showTradeBots(); return false; }; | |
var showNonTradeBotsBtn = document.getElementById('show-non-trade-bots-btn'); | |
showNonTradeBotsBtn.onclick = function() { showNonTradeBots(); return false; }; | |
var showAllBtn = document.getElementById('show-all-btn'); | |
showAllBtn.onclick = function() { showAll(); return false; }; | |
var orderByBtn = document.getElementById('order-by-trade-quantity-btn'); | |
orderByBtn.onclick = function() { orderByTradeQuantity(); return false; }; | |
var openTradeBtn = document.getElementById('open-trades-btn'); | |
openTradeBtn.onclick = function() { openTrades(); return false; }; | |
var numTradesInput = document.getElementById('numTrades'); | |
numTradesInput.onclick = function() {event.stopPropagation(); return false; }; | |
} | |
function showTradeBots(){ | |
showUserByType(BOT_USER); | |
} | |
function showNonTradeBots(){ | |
showUserByType(STM_USER); | |
} | |
function showAll(){ | |
showUserByType(null); | |
} | |
function showUserByType(type){ | |
jQuery(".stm-user").each(function(){ | |
userType = jQuery(this).html(); | |
var nodeTo = jQuery(this).parent().parent().parent(); | |
if (userType == type || type === null){ | |
nodeTo.show(); | |
} else { | |
nodeTo.hide(); | |
} | |
}); | |
} | |
function orderByTradeQuantity(){ | |
var results = jQuery('#match-results > div'); | |
results.detach().sort( | |
function(a, b) { | |
var astts = jQuery(a).find(".match-container").length; | |
var bstts = jQuery(b).find(".match-container").length; | |
return (astts < bstts) ? ((astts < bstts) ? 1 : 0) : -1; | |
}); | |
$('#match-results').append(results); | |
} | |
function openTrades() | |
{ | |
var numTrades = parseInt(jQuery("#numTrades")[0].value); | |
if (isNaN(numTrades)){ | |
alert("plase, enter a number, not:" + jQuery("#numTrades")[0].value); | |
return; | |
} | |
var tradeBtns = jQuery("a div.trade-button:visible"); | |
if (tradeBtns.length < numTrades) { | |
numTrades = tradeBtns.length; | |
} | |
var x = 0; | |
var refreshIntervalId = setInterval(function(){ | |
if (x >= numTrades){ | |
clearInterval(refreshIntervalId); | |
return; | |
} | |
tradeBtns[x].click(); | |
x++; | |
}, 3000); | |
} | |
/*********************************************************** | |
* Utility Functions | |
**********************************************************/ | |
function insertAfter(newNode, referenceNode) { | |
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); | |
} | |
function insertBefore(newNode, referenceNode){ | |
referenceNode.parentNode.insertBefore(newNode, referenceNode); | |
} |
thank you!
i migrate this to a repository with some improvements: https://github.com/sergiosusa/steamtradematcher-enhanced
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this script!
However, I prefer to have a smaller filter view, instead of having it stretched over the whole page. So I've replaced line 29 with: