Skip to content

Instantly share code, notes, and snippets.

@L3n1n
Last active May 26, 2022 00:37
Show Gist options
  • Save L3n1n/98ecfe23c9a6cf2311614dcadd01e706 to your computer and use it in GitHub Desktop.
Save L3n1n/98ecfe23c9a6cf2311614dcadd01e706 to your computer and use it in GitHub Desktop.
Steam Cup Event Badge 2022
// ==UserScript==
// @name Steam Cup Event Badge 2022
// @namespace https://gist.github.com/L3n1n
// @version 0.6
// @description Automatic voting
// @author L3n1n
// @match *://store.steampowered.com/category/racing*
// @updateURL https://gist.githubusercontent.com/L3n1n/98ecfe23c9a6cf2311614dcadd01e706/raw/SteamCupEventBadge2022.user.js
// @downloadURL https://gist.githubusercontent.com/L3n1n/98ecfe23c9a6cf2311614dcadd01e706/raw/SteamCupEventBadge2022.user.js
// ==/UserScript==
var cfg = document.getElementById("application_config");
var userinfo = JSON.parse(cfg.getAttribute("data-userinfo"));
var arr = JSON.parse(cfg.getAttribute("data-doorinfo"));
if ( ! userinfo.logged_in ) return false;
var opened = 0;
arr.forEach((el) => {
if ( el.opened == 1 ) opened++;
});
if ( opened == arr.length ) return false;
var modal = ShowBlockingWaitDialog("Voting...", "Please wait");
function doCall(i){
if ( arr[i].opened == 1 ) {
console.log("door_index " + i + ": already opened");
i++;
if ( arr[i] ) {
doCall(i);
}
if ( i == arr.length ) {
modal.Dismiss();
ShowAlertDialog("All done!", "Enjoy.");
}
} else {
$J.post("//store.steampowered.com/saleaction/ajaxopendoor", {
sessionid: g_sessionID,
authwgtoken: userinfo.authwgtoken,
door_index: i
}, (res) => {
console.log("door_index " + i + ":", res);
i++;
if ( arr[i] ) {
doCall(i);
}
if ( i == arr.length ) {
modal.Dismiss();
ShowAlertDialog("All done!", "Enjoy.");
}
});
}
}
doCall(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment