Guest User

Untitled

a guest
Feb 20th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function()
  2. {
  3.     var wishlist = [];
  4.     var wishlisted = [];
  5.    
  6.     jQuery.ajax({
  7.         type: 'GET',
  8.         url: '//api.steampowered.com/ISteamApps/GetAppList/v2',
  9.         dataType: 'jsonp',
  10.         success: function(result){
  11.             jQuery.each(result['applist']['apps'], function(key, value){
  12.                 wishlist.push(value['appid']);
  13.             })
  14.            
  15.             jQuery.ajax({
  16.                 type: 'GET',
  17.                 url: 'http://store.steampowered.com/dynamicstore/userdata/',
  18.                 dataType: 'json',
  19.                 success: function(result) {
  20.                     jQuery.each(result['rgWishlist'], function (index, value) {
  21.                         wishlisted.push(value);
  22.                     });
  23.                    
  24.                     var Index;
  25.                     for (var i=0; i<wishlisted.length; i++) {
  26.                         Index = wishlist.indexOf(wishlisted);
  27.                         if (Index > -1) {
  28.                             wishlist.splice(Index, 1);
  29.                         }
  30.                     }
  31.                    
  32.                     var i = 0,
  33.                     loaded = 0,
  34.                     total = wishlist.length,
  35.                     modal = ShowBlockingWaitDialog( 'Executing...',
  36.                         'Please wait until all requests finish. Ignore all the errors, let it finish.' );
  37.  
  38.                     var ExecuteRequest = function( )
  39.                     {
  40.                         jQuery.ajax(
  41.                         {
  42.                             type: 'POST',
  43.                             dataType: 'text',
  44.                             url: '//store.steampowered.com/api/addtowishlist',
  45.                             data:
  46.                             {
  47.                                 appid: wishlist[ i ],
  48.                                 sessionid: g_sessionID,
  49.                             }
  50.                         }
  51.                         ).always( function( )
  52.                             {
  53.                                 loaded++;
  54.                                
  55.                                 modal.Dismiss();
  56.                                
  57.                                 if( loaded >= total )
  58.                                 {
  59.                                     ShowAlertDialog( 'All done!', 'Enjoy.' );
  60.                                 }
  61.                                 else
  62.                                 {
  63.                                     modal = ShowBlockingWaitDialog( 'Executing...',
  64.                                         'Loaded ' + loaded + '/' + total + '. Ignore all the errors, let it finish.' );
  65.                                    
  66.                                     i++;
  67.                                    
  68.                                     ExecuteRequest();
  69.                                 }
  70.                             }
  71.                         );
  72.                     };
  73.  
  74.                     setTimeout( ExecuteRequest, 1500 );
  75.                 },
  76.                 error : function(httpReq,status,exception){
  77.                     ShowAlertDialog( status, 'Uh Oh!' );
  78.                 }
  79.             })
  80.         },
  81.         error : function(httpReq,status,exception){
  82.             ShowAlertDialog( status, 'Uh Oh!' );
  83.         },
  84.         jsonp: 'jsonp'
  85.     })
  86. }());
Add Comment
Please, Sign In to add comment