-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmassremove_demos.js
More file actions
71 lines (68 loc) · 2.79 KB
/
massremove_demos.js
File metadata and controls
71 lines (68 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// ==UserScript==
// @name Mass Remove Free License Steam
// @namespace Violentmonkey Scripts
// @match https://store.steampowered.com/account/licenses/*
// @grant none
// @version 1.0
// @author Nixos
// @description 09/09/2024, 10:04:03
// ==/UserScript==
// Thanks to https://gist.github.com/retvil/aa10748c31be44fe2b8b for the REGEX
// Thanks to TCNOco for the original version
var appIds = [];
var rows = document.getElementsByClassName("account_table")[0].rows;
i = 0;
for (let row of rows){
var cell = row.cells[1];
if (/\b(?:trailer|teaser|demo|cinematic|pegi|esrb)\b/i.test(cell.textContent)) {
packageId = /javascript:\s*RemoveFreeLicense\s*\(\s*(\d+)/.exec(cell.innerHTML);
if (packageId !== null) {
i++;
console.log(`[${i}] Removing: ${packageId[1]} - ${cell.innerHTML.split("</div>")[1].trim()}`);
if (!appIds.includes(packageId[1]))appIds.push(packageId[1]);
}
}
}
function removeNextPackage(appIds, i) {
if (i >= appIds.length) {
console.log("Removed all AppIds from account.");
return;
}
fetch("https://store.steampowered.com/account/removelicense", {
"headers": {
"accept": "*/*",
"accept-language": "en-US,en;q=0.9",
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"102\", \"Google Chrome\";v=\"102\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"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": "strict-origin-when-cross-origin",
"body": `sessionid=${encodeURIComponent(window.g_sessionID)}&packageid=${appIds[i]}`,
"method": "POST",
"mode": "cors",
"credentials": "include"
}).then(response => {
if (response.status !== 200) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
}).then(data => {
if (data && data.success === 84) {
console.log(`Rate limit exceeded. Retrying after delay...`);
setTimeout(() => removeNextPackage(appIds, i), 3600000); // Retry after 1 hr
} else {
console.log(`Removed: ${appIds[i]} (${i + 1}/${appIds.length})`);
removeNextPackage(appIds, i + 1);
}
}).catch(error => {
console.error(`Network or parsing error: ${error}`);
setTimeout(() => removeNextPackage(appIds, i), 60000); // Retry after 60 seconds on network error
});
}
removeNextPackage(appIds, 0);