Batch removal of Complimentary steam games/apps

If you were a dumbass, like me, and you ran the Free Packages script from SteamDB, you probably have thousands of free packages added to your steam account, including Demos and Trailers. Doh.

Removing each package one at a time from your Steam licenses page would take literally days, since you would click the ‘Remove’ link, click the confirm dialog, and wait while the page refreshed. FOR EACH ITEM.

So I got clever. Firstly, I bastardized SteamDB’s “add” script and changed it in to a “remove” script. I manually processed the html of the license page and pulled all the app ids out of the page to use in my script, and I cleaned up all the demos, etc.

I figured it would be useful if I posted it here, as I’m sure I’m not the only dumbass out there. I also realized that it’s a royal pain in the backside to manually parse all the app ids out of the license page html, so I spent some time and wrote this javascript that you can paste in to your browser console while on your license page, and it will output a neat list that you can then paste in to the removal script. This will only add the appids of removable items on your license page. Remember to edit out the appids you want to keep (although you can always go add them again later from the store).

I’ve only tested this in Chrome, but it should work in Firefox too. Remember, open up the Steam licenses page, open your browser console while on that page, and paste this script in to the console. Copy the output from the console log, clean it up in a text editor, and paste it in to the removal script below, and then paste the removal script with your own appids list in to the console on your steam license page:

STEAM LICENSE PARSER

(function()
{
  var links = [];
  $J('div.free_license_remove_link').find('a').each(function(i, el){
	  var match = el.href.match( /javascript:RemoveFreeLicense\( ([0-9]+), '/ );
	  if( match !== null ) { links.push(el); }
  });
  for (var i = 0, l = links.length; i < l; i++)
  {
	var rgx = /\(.(\d+),.*\'(.+)\'/
	var matches = links[i].href.match(rgx);
    console.log(matches[1] + ', // ' + atob(matches[2]));
  }}());

Take the output from above, and paste it in to the deletePackages var below:

Note that depending on how many apps you’re removing, the script can take quite a while to run.

REMOVAL SCRIPT

(function()
{
  var deletePackages = 
  [
    76757, // Paste the output of the other script here (cleaned up as necessary)
	76556, // These ids are just samples, REPLACE THEM with your own list.
  ];
  
  var i = 0,
      done = 0,
	  package = 0,
	  total = deletePackages.length,
	  modal = ShowBlockingWaitDialog( 'Removing...',
	    	'Please wait until all requests finish.' ); 
  var ExecuteRequest = function()
  {
	  package = deletePackages[i];
	  jQuery.ajax(
		{
			url: 'https://store.steampowered.com/account/removelicense',
			type: 'POST',
			data:
			{
				sessionid : g_sessionID,
				packageid : package
			}
		}
	  ).always(function()
		{
			done++;
			modal.Dismiss();
			if( done >= total )
			{
				ShowAlertDialog( 'Complete!', done + ' packages have been removed.' );
			}
			else
			{
				modal = ShowBlockingWaitDialog( 'Removing Packages...',
					'Removed ' + done + '/' + total + '. Do not navigate away or refresh this page.' );
				i++;
				ExecuteRequest();
			}
		});
  };
  setTimeout( ExecuteRequest, 1500 );
}());
3 Likes

i am a dumbass too :smiley: this is working thanks

1 Like

Hello if you’re visiting this page from some Russian video on youtube. :wave:

3 Likes

I haven’t a clue. I haven’t looked at this stuff in a few years. You could always look at the install script and see what it does.