Forked from Kowiz/steam_discovery_queue.user.js
Last active
December 24, 2017 23:20
-
-
Save Xinayder/eeac9118a3e33eb5c046 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Auto Steam Discovery Queue | |
// @namespace RockyTV | |
// @description Go to next game queued as soon as page is done loading. | |
// @version 1.5 | |
// @include http://store.steampowered.com/explore/* | |
// @match *://store.steampowered.com/explore* | |
// @match *://store.steampowered.com//explore* | |
// @run-at document-end | |
// @grant none | |
// @description Automatically goes through your Steam Discovery Queue to get the Steam Sale Cards | |
// @updateURL https://gist.githubusercontent.com/RockyTV/eeac9118a3e33eb5c046/raw/steam_discovery_queue.user.js | |
// @downloadURL https://gist.githubusercontent.com/RockyTV/eeac9118a3e33eb5c046/raw/steam_discovery_queue.user.js | |
// ==/UserScript== | |
(function(window) { | |
var updateTimer = null; | |
var DiscoveryQueueModal, GenerateQueue = function( queueNumber ) | |
{ | |
DiscoveryQueueModal = ShowBlockingWaitDialog( 'Exploring queue...', 'Generating new discovery queue #' + ++queueNumber ); | |
jQuery.post( 'http://store.steampowered.com/explore/generatenewdiscoveryqueue', { sessionid: g_sessionID, queuetype: 0 } ).done( function( data ) | |
{ | |
var requests = [], done = 0, errorShown; | |
for( var i = 0; i < data.queue.length; i++ ) | |
{ | |
var request = jQuery.post( 'http://store.steampowered.com/app/10', { appid_to_clear_from_queue: data.queue[ i ], sessionid: g_sessionID } ); | |
request.done( function() | |
{ | |
if( errorShown ) | |
{ | |
return; | |
} | |
DiscoveryQueueModal.Dismiss(); | |
DiscoveryQueueModal = ShowBlockingWaitDialog( 'Exploring the queue...', 'Request ' + ++done + ' of ' + data.queue.length ); | |
} ); | |
request.fail( function() | |
{ | |
errorShown = true; | |
DiscoveryQueueModal.Dismiss(); | |
DiscoveryQueueModal = ShowConfirmDialog( 'Error', 'Failed to clear queue item #' + ++done, 'Try again' ).done( function() { | |
GenerateQueue( queueNumber - 1 ); | |
}); | |
} ); | |
requests.push( request ); | |
} | |
jQuery.when.apply( jQuery, requests ).done( function() | |
{ | |
DiscoveryQueueModal.Dismiss(); | |
if( queueNumber < 3 ) | |
{ | |
GenerateQueue( queueNumber ); | |
} | |
else | |
{ | |
DiscoveryQueueModal = ShowConfirmDialog( 'Done', 'Queue has been explored ' + queueNumber + ' times', 'Reload the page' ).done( function() { | |
ShowBlockingWaitDialog( 'Reloading the page' ); | |
window.location.reload(); | |
}); | |
} | |
} ); | |
} ).fail( function() | |
{ | |
DiscoveryQueueModal.Dismiss(); | |
DiscoveryQueueModal = ShowConfirmDialog( 'Error', 'Failed to generate new queue #' + queueNumber, 'Try again' ).done( function() { | |
GenerateQueue( queueNumber - 1 ); | |
}); | |
} ); | |
}; | |
var pageContent = document.querySelector('.discovery_queue_customize_ctn'); | |
var startButton = document.createElement('div'); | |
startButton.className = 'btnv6_blue_hoverfade btn_medium'; | |
startButton.onclick = function() { GenerateQueue(0) }; | |
var startSpan = document.createElement('span'); | |
startSpan.textContent = 'Obtain cards!'; | |
startButton.appendChild(startSpan); | |
var timerSpan = document.createElement('span'); | |
timerSpan.id = 'discovery_timer'; | |
timerSpan.className = 'new_feature'; | |
timerSpan.textContent = 'Unlock more cards in'; | |
pageContent.appendChild(document.createElement('br')); | |
pageContent.appendChild(document.createElement('br')); | |
pageContent.appendChild(startButton); | |
pageContent.appendChild(timerSpan); | |
updateTimer = window.setInterval(function() { | |
var today = new Date(); | |
var resetDate = new Date(Date.UTC(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate() + 1, 18, 0, 0)); | |
var diff = new Date(resetDate - new Date()); | |
var hours = diff.getUTCHours(); | |
if (hours < 10) hours = '0' + hours; | |
var minutes = diff.getUTCMinutes(); | |
if (minutes < 10) minutes = '0' + minutes; | |
var seconds = diff.getUTCSeconds(); | |
if (seconds < 10) seconds = '0' + seconds; | |
var dateTimer = document.querySelector('#discovery_timer'); | |
if (dateTimer) { | |
dateTimer.textContent = 'Unlock more cards in ' + hours + ':' + minutes + ':' + seconds; | |
} | |
}, 1000); | |
}(window)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment