Skip to content

Instantly share code, notes, and snippets.

@ViniciusFXavier
Last active June 17, 2020 16:36
Show Gist options
  • Save ViniciusFXavier/a230ddb3b6f13dad5759639b3e306704 to your computer and use it in GitHub Desktop.
Save ViniciusFXavier/a230ddb3b6f13dad5759639b3e306704 to your computer and use it in GitHub Desktop.
Remove demos from STEAM account
(function () {
if (!location.href.startsWith('https://store.steampowered.com/account/licenses')) {
alert('Please run this on Steam\'s account licenses page.');
return;
}
let toDelete = [];
[...document.querySelectorAll('tr td:nth-child(2)')].forEach((element) => {
const match = element.innerHTML.match(/( Demo)\W+/gi);
if (match) {
const id = element.innerHTML.match(/javascript:RemoveFreeLicense\( ([0-9]+), '/);
if (id) {
toDelete.push(id[1])
}
}
});
console.log('toDelete: ', toDelete);
let loaded = 0;
let sendFetch = (id) => {
fetch("https://store.steampowered.com/account/removelicense", {
"headers": {
"accept": "*/*",
"accept-language": "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7",
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-requested-with": "XMLHttpRequest"
},
"referrer": "https://store.steampowered.com/account/licenses/",
"referrerPolicy": "no-referrer-when-downgrade",
"body": "sessionid=" + window.g_sessionID + "&packageid=" + id,
"method": "POST",
"mode": "cors",
"credentials": "include"
}).then(function(response) {
console.log('response: ', response);
return response
}).then(function() {
requestNext();
});
};
let requestNext = () => {
if (loaded < toDelete.length) {
const element = toDelete[loaded];
console.log('element: ', element);
loaded++
sendFetch(element);
}
}
requestNext()
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment