This code is a JavaScript snippet meant to be executed...

August 29, 2025 at 01:33 AM

(function() { const delay1 = 500; // milliseconds const delay2 = 10; // minutes const licensesUrl = `https://store.steampowered.com/account/licenses/`; const removeLicensesUrl = `https://store.steampowered.com/account/removelicense`; const warningString = 'Code cannot be executed here. You will be automatically redirected to the correct page. Please run this code on Steam\'s account page details: store.steampowered.com/account/licenses'; const analysisHeader = 'Analyzing...'; const analysisText = 'Please wait until analysis is complete.'; const headerString = 'Games removing'; const okString = 'Remove'; const cancelString = 'Cancel'; const mainInfo = 'You have <b id="numberGames"></b> game(s) can be removed.<br/>Enter the number of games you want to remove.'; const errorMessage = 'Enter number from 0 to '; const removingHeader = 'In Progress...'; const removingText = 'Removed:'; const noGamesToRemoveMessage = 'There are no games available for removing.' const rateLimitedMessage1 = `You have been rate limited, trying next removal in `; const rateLimitedMessage2 = ` minutes.`; const errorMessage2 = 'An error was encountered while processing your request:' if (location.href != (licensesUrl)) { alert(warningString); window.location = (licensesUrl); return; } var freeLicensePackages = []; var modal = ShowBlockingWaitDialog(analysisHeader, analysisText); jQuery('.free_license_remove_link a').each(function(i, el) { var matched = decodeURI(el.href).match(/\d{4,}/); if (matched !== null) { freeLicensePackages.push(+matched); } }); if (modal) { modal.Dismiss(); } var total = freeLicensePackages.length; if (total == 0) { alert(noGamesToRemoveMessage); return; } var enteredNumber = total; var desc = jQuery(`<div class="newmodal_prompt_description">${mainInfo}</div><div><div class="newmodal_prompt_input gray_bevel for_text_input fullwidth"><input type="text" id="games_number" value="0"/><span style="display: none; color: rgb(255, 0, 0);"><small>${errorMessage}${total}</small></span></div></div>`); var main = jQuery(`<div class="newmodal" style="position: fixed; z-index: 1000; max-width: 900px; left: 300px; top: 95px;"><div class="newmodal_header_border"><div class="newmodal_header"><div class="ellipsis">${headerString}</div></div></div><div class="newmodal_content_border"><div class="newmodal_content" style="max-height: 205px;"><div id="mainDiv"></div><div class="newmodal_buttons"><div class="btn_green_white_innerfade btn_medium"><span id="okButton">${okString}</span></div><div class="btn_grey_white_innerfade btn_medium"><span id="cancelButton">${cancelString}</span></div></div></div></div></div><div class="newmodal_background" style="opacity: 0.8;"></div>`); jQuery('body').append(main); jQuery('#cancelButton').on('click', function (event) { jQuery('.newmodal').remove(); jQuery('.newmodal_background').remove(); }); jQuery('#mainDiv').html(desc); jQuery('#numberGames').text(total); jQuery('#games_number').val(total); jQuery('#games_number').on('change', function (event) { var input = jQuery(this); var value = +input.val(); if (!Number.isInteger(value) || value > total || value <= 0) { input.css('border-color', 'red'); input.next('span').show(); jQuery('#okButton').hide(); } else { enteredNumber = value; input.css('border-color', ''); input.next('span').hide(); jQuery('#okButton').show(); } }); var removed = 0; jQuery('#okButton').on('click', function (event) { jQuery('.newmodal').remove(); jQuery('.newmodal_background').remove(); proceed(0); // 0 = no delay }); const proceed = (countDown) => { if (modal) { modal.Dismiss(); } if (removed >= enteredNumber) { location.reload(); } else { if (countDown > 0) { modal = ShowBlockingWaitDialog(removingHeader, `${rateLimitedMessage1}${countDown}${rateLimitedMessage2}<br>${removingText} <b>${removed}</b>/${enteredNumber}.`); setTimeout(() => proceed(--countDown), 60000); // 1 minute } else { modal = ShowBlockingWaitDialog(removingHeader, `${removingText} <b>${removed}</b>/${enteredNumber}.`); if (countDown == 0) { deleteFunc(removed++); } else { setTimeout(() => deleteFunc(removed++), delay1); } } } } const deleteFunc = (index) => { jQuery.ajax({url: removeLicensesUrl, type: 'POST', data: { packageid: freeLicensePackages[index], sessionid: g_sessionID }, success: function ( response ) { if ( response.success == 1 ) { proceed(-1); // -1 = small delay (delay1) } else { if (response.success = 84) { removed--; proceed(delay2); } else { if (modal) { modal.Dismiss(); } ShowAlertDialog( 'Error', errorMessage2 + ' ' + response.success); } } } }); } }());

This code is a JavaScript snippet meant to be executed on the "Licenses and Subscriptions" page (https://store.steampowered.com/account/licenses) of a user's Steam account. Here's a detailed explanation of what it does:

Purpose

The code automates the process of analyzing and removing "free" licenses (such as beta tests, demo licenses, or other free package entitlements) from the user's Steam account.


How the Code Works

  1. Validation of the URL

    • The script checks if it is running on the correct page (https://store.steampowered.com/account/licenses).
    • If not, it alerts the user with a warning and redirects them to the correct page.
  2. Free License Discovery

    • It iterates over all the elements on the page that match the CSS class .free_license_remove_link to extract the packageids (unique identifiers for licenses) of free licenses available for removal.
  3. Prompt the User

    • If no free licenses are found, the script alerts the user with a message (There are no games available for removing) and exits.
    • If free licenses are found, it opens a dialog box displaying the total number of licenses that can be removed and prompts the user to specify how many games they would like to remove.
    • Validation ensures the user enters a valid number (e.g., an integer between 1 and the total number of licenses).
  4. Removal Process

    • After the user confirms the number of licenses to remove, the script begins removing the licenses by sending asynchronous POST requests to the Steam endpoint https://store.steampowered.com/account/removelicense.
    • Each request includes the packageid of the license to be removed and the user's sessionid (retrieved from the global variable g_sessionID).
  5. Rate Limiting Logic

    • If too many removal requests are made in a short period, Steam will temporarily rate-limit the requests (response code 84).
    • Upon detecting rate-limiting, the script waits for a configured delay (delay2, which is 10 minutes by default) before attempting the next removal.
    • If there is no rate-limiting, it proceeds to remove the next license after a short delay (delay1, which is 500 milliseconds by default).
  6. Completion

    • The script tracks how many licenses have been successfully removed. Once the specified number of licenses has been removed, the page reloads to reflect the changes.
  7. Error Handling

    • If an unexpected error occurs (e.g., the server returns a response other than success: 1), an error message is displayed to the user via a modal dialog box.

Key Features

  • Input Validation: Ensures the user specifies a valid number of licenses to remove.
  • Rate Limiting Handling: Handles Steam's rate-limiting by introducing 10-minute delays when necessary.
  • Modal Interface: Uses Steam's styles and modal dialogs to provide a user-friendly interface for viewing progress.
  • Safety Check: Prevents accidental execution on unintended pages by verifying the URL.

Usage Scenario

This code is likely to be used by users who want to clean up their Steam account by removing unneeded free licenses. These might include expired trials, demos, or other unnecessary packages cluttering their library.


Important Notes

  • Risk: This script interacts with a user's Steam account and performs license removal operations. Incorrect or excessive use might inadvertently remove licenses the user did not intend to remove.
  • Dependencies: The script relies on the presence of certain global variables (g_sessionID) and functions (ShowBlockingWaitDialog, ShowAlertDialog) provided by Steam's website.
  • Banned Usage: Automating account actions may violate Steam's terms of service, and misuse of this script could result in account restrictions or bans. Ensure compliance with Steam's policies before use.
Generate your own explanations
Download our vscode extension
Read other generated explanations

Built by @thebuilderjr
Sponsored by beam analytics
Read our terms and privacy policy
Forked from openai-quickstart-node