Created
April 16, 2022 20:24
-
-
Save prr21/2b074d16210e963282716244f5e24959 to your computer and use it in GitHub Desktop.
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
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