Skip to content

Instantly share code, notes, and snippets.

@prr21
Created April 16, 2022 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prr21/2b074d16210e963282716244f5e24959 to your computer and use it in GitHub Desktop.
Save prr21/2b074d16210e963282716244f5e24959 to your computer and use it in GitHub Desktop.
const getIds = selector => {
selector = selector || `[src= "https://community.akamai.steamstatic.com/economy/image/-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXU5A1PIYQNqhpOSV-fRPasw8rsUFJ5KBFZv668FFUxnaPLJz5H74y1xtTcz6etNumIx29U6Zd3j7yQoYih3lG1-UJqY27xJIeLMlhpaD9Aclo/96fx96f"]`
const arr = document.querySelectorAll(selector)
const ASSETID_RE = /(?<=\d+\_\d+\_)\d+/
return Array
.from(arr, a => a.parentElement?.id?.match(ASSETID_RE)?.[0])
.filter(Boolean)
}
const sellItem = id => {
return fetch("https://steamcommunity.com/market/sellitem/", {
"referrerPolicy": "strict-origin-when-cross-origin",
"body": `sessionid=${document.cookie.match(/(?<=sessionid=)\w+/)[0]}&appid=730&contextid=2&assetid=${id}&amount=1&price=${price}`,
"method": "POST",
"mode": "cors",
"credentials": "include"
}).then(a => a.json())
}
const sellItemsById = async (ids = getIds(), price = 800) => {
const res = []
for (const id of ids){
res.push(await sellItem(id))
}
return res
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment