Last active
November 18, 2024 01:47
-
-
Save quat1024/dc003a1faf0c78643adfe5c2a38c40c8 to your computer and use it in GitHub Desktop.
Slowly block everyone in a Steam group
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
// USAGE | |
// 1. visit the steam group's "members" page | |
// 2. paste this janky js into the browser console | |
// 3. be patient; it has a fairly long delay between requests, since | |
// i'm not sure how touchy valve is (you can change the 1000 to a lower | |
// number if you're less scared about it | |
// (the script uses the memberslistxml endpoint, so each "page" has 1000 members) | |
(async () => { | |
function sendAsync(xhr) { | |
return new Promise(function (resolve, reject) { | |
xhr.onload = () => { | |
if (xhr.status >= 200 && xhr.status < 300) { | |
resolve(xhr); | |
} else { | |
reject({ xhr }); | |
} | |
}; | |
xhr.onerror = () => reject(xhr); | |
xhr.send(); | |
}); | |
} | |
function sleep() { | |
return new Promise((resolve) => setTimeout(resolve, 1000)); | |
} | |
let page = 2; | |
let baseurl = window.location.href.slice( | |
0, | |
window.location.href.lastIndexOf("members/"), | |
) + | |
"memberslistxml/?xml=1"; | |
do { | |
let xhr = new XMLHttpRequest(); | |
xhr.open("GET", baseurl + "&p=" + page); | |
await sendAsync(xhr); | |
let resp = xhr.responseXML; | |
let totalPages = parseInt(resp.querySelector("totalPages").textContent) || 1; | |
//console.log(resp); | |
console.log(`page ${page} of ${totalPages}`); | |
//get ids | |
let ids = Array.from(xhr.responseXML.querySelectorAll("steamID64")).map( | |
(sid) => sid.textContent, | |
); | |
//break; | |
await sleep(); | |
let i = 1; | |
for (let id of ids) { | |
let blockresp = await fetch( | |
"https://steamcommunity.com/actions/BlockUserAjax", | |
{ | |
"credentials": "include", | |
"headers": { | |
"User-Agent": navigator.userAgent + " (using janky mass-blocker javascript)", | |
"Accept": "*/*", | |
"Accept-Language": "en-US,en;q=0.5", | |
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", | |
}, | |
"body": `sessionID=${g_sessionID}&steamid=${id}&block=1`, | |
"method": "POST", | |
"mode": "cors", | |
}, | |
); | |
console.log(`(page ${page}/${totalPages}, usr ${i}) just blocked`, id, ", steam responded with", await blockresp.text()); | |
await sleep(); | |
i++; | |
} | |
await sleep(); | |
page++; | |
} while (page < totalPages); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment