Liniuss

Untitled

Jun 24th, 2018
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. var DiscoveryQueueModal, GenerateQueue = function( queueNumber )
  2. {
  3. if( DiscoveryQueueModal )
  4. {
  5. DiscoveryQueueModal.Dismiss();
  6. }
  7. DiscoveryQueueModal = ShowBlockingWaitDialog( 'Generating the queue...', 'Generating new discovery queue #' + ++queueNumber );
  8. jQuery.post( 'https://store.steampowered.com/explore/generatenewdiscoveryqueue', { sessionid: g_sessionID, queuetype: 0 } ).done( function( data )
  9. {
  10. var requests = [], done = 0, errorShown;
  11.  
  12. for( var i = 0; i < data.queue.length; i++ )
  13. {
  14. var request = jQuery.post( 'https://store.steampowered.com/app/10', { appid_to_clear_from_queue: data.queue[ i ], sessionid: g_sessionID } );
  15.  
  16. request.done( function()
  17. {
  18. if( errorShown )
  19. {
  20. return;
  21. }
  22.  
  23. DiscoveryQueueModal.Dismiss();
  24. DiscoveryQueueModal = ShowBlockingWaitDialog( 'Exploring the queue...', 'Request ' + ++done + ' of ' + data.queue.length );
  25. } );
  26.  
  27. request.fail( function()
  28. {
  29. errorShown = true;
  30.  
  31. setTimeout( () => GenerateQueue( queueNumber - 1 ), 1000 );
  32.  
  33. DiscoveryQueueModal.Dismiss();
  34. DiscoveryQueueModal = ShowConfirmDialog( 'Error', 'Failed to clear queue item #' + ++done + '. Trying again in a second.', 'Try again' );
  35. } );
  36.  
  37. requests.push( request );
  38. }
  39.  
  40. jQuery.when.apply( jQuery, requests ).done( function()
  41. {
  42. DiscoveryQueueModal.Dismiss();
  43.  
  44. if( queueNumber < 3 )
  45. {
  46. GenerateQueue( queueNumber );
  47. }
  48. else
  49. {
  50. DiscoveryQueueModal = ShowConfirmDialog( 'Done', 'Queue has been explored ' + queueNumber + ' times', 'Reload the page' ).done( function() {
  51. ShowBlockingWaitDialog( 'Reloading the page' );
  52. window.location.reload();
  53. });
  54. }
  55. } );
  56. } ).fail( function()
  57. {
  58. setTimeout( () => GenerateQueue( queueNumber - 1 ), 1000 );
  59.  
  60. DiscoveryQueueModal.Dismiss();
  61. DiscoveryQueueModal = ShowBlockingWaitDialog( 'Error', 'Failed to generate new queue #' + queueNumber + '. Trying again in a second.' );
  62. } );
  63. };
  64. var buttonContainer = document.createElement( 'div' );
  65. buttonContainer.className = 'discovery_queue_customize_ctn';
  66. buttonContainer.innerHTML = '<div class="btnv6_blue_hoverfade btn_medium" id="js-cheat-queue"><span>Cheat the queue</span></div><span>Discover the queue three times to get the sale cards</span>';
  67. var container = document.querySelector( '.discovery_queue_customize_ctn' );
  68. container.parentNode.insertBefore( buttonContainer, container );
  69. var button = document.getElementById( 'js-cheat-queue' );
  70. button.addEventListener( 'click', function( )
  71. {
  72. GenerateQueue( 0 );
  73. }, false );
Advertisement
Add Comment
Please, Sign In to add comment