Skip to content

Instantly share code, notes, and snippets.

@retvil
Created August 16, 2014 09:00
Show Gist options
  • Save retvil/998a060b966feb68c627 to your computer and use it in GitHub Desktop.
Save retvil/998a060b966feb68c627 to your computer and use it in GitHub Desktop.
[IOC] Free Steam (Remove Program)
///Workerd on Script: lunboks
///Editor: Nod33Eset
///Tester:
(function () {
var NUKE_REGEX = /\b(?:trailer|teaser|demo|cinematic|pegi|esrb)\b/i;
var PACKAGE_ID_REGEX = /javascript:\s*RemoveFreeLicense\s*\(\s*(\d+)/;
var REMOVE_LICENSE_API = "/account/removelicense";
var RUN_ON_PAGE = "https://store.steampowered.com/account/";
if (location.href !== RUN_ON_PAGE) {
if (confirm("You're not on your licenses page. Go now?")) {
location.assign(RUN_ON_PAGE);
}
return;
}
var idsToRemove = [
13601, // Source Filmmaker
21349, // Construct 2
21403, // iPi Recorder 2
21419, // Ohm Studio
28242, // Ohm Studio
35063, // Star Swarm Benchmark
35064, // Star Swarm Benchmark for Beta Testing
];
var rows;
var licensesTable = document.getElementById("licenses");
var packageId;
if (licensesTable && window.g_sessionID) {
licensesTable = licensesTable.getElementsByClassName("account_table")[0];
rows = licensesTable.rows;
for (var i = 0, l = rows.length; i < l; i++) {
if (NUKE_REGEX.test(rows[i].cells[0].textContent)) {
packageId = PACKAGE_ID_REGEX.exec(rows[i].cells[1].innerHTML);
if (packageId !== null) {
idsToRemove.push(packageId[1]);
}
}
}
function removePackageAndQueueNext(packages, index) {
if (index >= packages.length) {
console.log("Packages Removed.");
return; // done
}
var parameters = "?sessionid=" + encodeURIComponent(g_sessionID) + "&packageid=" + encodeURIComponent(packages[index]);
var xhr = new XMLHttpRequest();
xhr.open("HEAD", REMOVE_LICENSE_API + parameters, true);
xhr.onreadystatechange = function () {
if (this.readyState === 4) {
console.log("Removed Package %d/%d", index + 1, packages.length);
removePackageAndQueueNext(packages, index + 1);
}
};
xhr.send();
}
if (idsToRemove.length > 0) {
removePackageAndQueueNext(idsToRemove, 0);
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment