Skip to content

Instantly share code, notes, and snippets.

@LaBlazer
Created July 22, 2017 22:01
Show Gist options
  • Save LaBlazer/405677f26f9098a839f264969bc338b4 to your computer and use it in GitHub Desktop.
Save LaBlazer/405677f26f9098a839f264969bc338b4 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name SteamTrades Auto Bump
// @namespace ST_AUTOBUMP
// @author LBLZR_
// @description Bumps the post every 60 minutes + random drift
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js
// @include https://*.steamtrades.com/trade/*
// ==/UserScript==
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function scheduleReload(seconds){
//we add a random drift to the time
seconds += getRandomInt(10, 150);
console.log("Reload scheduled after " + seconds + " seconds...");
setTimeout(function(){
window.location.reload(1);
}, seconds*1000);
}
$(function() {
if($(".dropdown_btn.js_trade_bump").length>0){
var bumpTime = 3600;
$.ajax({
method: "POST",
url: "/ajax.php",
dataType: "json",
data: $(".dropdown_btn.js_trade_bump").data("form")
}).done(function(e) {
if(e.success){
console.log("Bumped...");
scheduleReload(bumpTime);
}else{
console.log("Bump failed, we probably bumped this thread recently...");
var delay = /Please wait another (\d+) minute/g.exec(e.popup_heading_h2);
console.log(e.popup_heading_h2);
if(delay != null && delay.length > 1){
bumpTime -= (60-Number(delay[1]))*60;
scheduleReload(bumpTime);
}else{
console.log("Could not find the wait time...");
scheduleReload(bumpTime);
}
}
});
}else{
console.log("This is probably not our trade, not bumping...");
}
});
@LaBlazer
Copy link
Author

LaBlazer commented Nov 17, 2019

Maybe detach the tab and run it in separate window or use a different browser? Another option would probably be to use a js service worker but I'm not exactly sure how to get that working with grease/tampermonkey...

This script is pretty old and I'm not involved in Steam trading anymore so I don't think there's any point in improving it 🤷‍♂️.

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