Created
August 16, 2014 08:09
-
-
Save retvil/e93f2afa9b998b960b96 to your computer and use it in GitHub Desktop.
[IOC] Free Steam (Remove Script)
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
///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 = []; | |
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