-
Notifications
You must be signed in to change notification settings - Fork 2
/
SteamLicenseRemover.js
76 lines (65 loc) · 2.66 KB
/
SteamLicenseRemover.js
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
72
73
74
75
// ==UserScript==
// @name Steam License Remover
// @namespace
// @version 2.0
// @description Remove any "Free" games from your Steam Library by removing the game's license from your account.
// @author IroN404
// @fork_comission Beardox
// @match https://store.steampowered.com/account/licenses/
let removedCount = 0;
async function removeGame(id) {
console.log(`Removing game with ID ${id}...`);
try {
const response = await fetch('https://store.steampowered.com/account/removelicense', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded' // Alterado o Content-Type
},
body: `sessionid=${encodeURIComponent(g_sessionID)}&packageid=${encodeURIComponent(id)}` // Corrigido o objeto body
});
if (response.ok) {
const data = await response.json();
if (data.success) {
removedCount++;
console.log(`Game with ID ${id} removed successfully. Total games removed: ${removedCount}`);
} else {
console.log(`Failed to remove game with ID ${id}.`);
}
} else {
console.log(`Failed to remove game with ID ${id}. Status: ${response.status} - ${response.statusText}`);
}
} catch (error) {
console.error(`Error while removing game with ID ${id}:`, error);
}
}
function extractIdFromLink(link) {
const match = link.match(/RemoveFreeLicense\(\s*(\d+)\s*,/);
return match ? match[1] : null;
}
function countRemovableGames() {
const removeLinks = document.querySelectorAll('a[href^="javascript:RemoveFreeLicense"]');
const totalGames = removeLinks.length;
console.log(`Total removable games: ${totalGames}`);
return totalGames;
}
async function removeGames() {
const totalGames = countRemovableGames();
const intervalID = setInterval(() => {
console.log(`Games removed: ${removedCount} of ${totalGames}`);
if (removedCount >= totalGames) {
clearInterval(intervalID);
}
}, 1000);
const removeLinks = document.querySelectorAll('a[href^="javascript:RemoveFreeLicense"]');
for (const link of removeLinks) {
const id = extractIdFromLink(link.href);
if (id) {
await removeGame(id);
await new Promise(resolve => setTimeout(resolve, 2000)); // Aguarda 2 segundos antes de processar o próximo link
} else {
console.log(`Failed to extract ID from link: ${link.href}`);
}
}
console.log(`All games removed. Total games removed: ${removedCount}`);
}
removeGames();