Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (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, dummy. Go there 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();
- }
- // Kick off the first request
- if (idsToRemove.length > 0) {
- removePackageAndQueueNext(idsToRemove, 0);
- }
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement