Steam自动探索队列

Steam节庆活动用脚本,自动探索3次队列。

  1. // ==UserScript==
  2. // @name Steam自动探索队列
  3. // @namespace http://keylol.com/t157861-1-1
  4. // @version 1.0
  5. // @description Steam节庆活动用脚本,自动探索3次队列。
  6. // @author baodongsun
  7. // @match https://store.steampowered.com/
  8. // @license MIT
  9. // @grant SteamCN
  10. // ==/UserScript==
  11.  
  12. (function _exec() {
  13. var appids,
  14. running = true,
  15. queueNumber,
  16. progressDialog = ShowAlertDialog('探索中', $J('<div/>').append($J('<div/>', { 'class': 'waiting_dialog_throbber' })).append($J('<div/>', { 'id': 'progressContainer' }).text('获取进度...')), '停止').done(abort);
  17. function abort() {
  18. running = false;
  19. progressDialog.Dismiss();
  20. }
  21. function retry() {
  22. abort();
  23. ShowConfirmDialog('错误', '是否重试?', '重试', '放弃').done(_exec)
  24. }
  25. function clearApp() {
  26. if (!running)
  27. return;
  28. showProgress();
  29. var appid = appids.shift();
  30. !appid ? generateQueue() : $J.post(appids.length ? '/app/' + appid : '/explore/next/', { sessionid: g_sessionID, appid_to_clear_from_queue: appid }).done(clearApp).fail(retry);
  31. }
  32. function generateQueue() {
  33. running && $J.post('/explore/generatenewdiscoveryqueue', { sessionid: g_sessionID, queuetype: 0 }).done(beginQueue).fail(retry);
  34. }
  35. function beginQueue() {
  36. if (!running)
  37. return;
  38. $J.get('/explore/').done(function (htmlText) {
  39. var cardInfo = htmlText.match(/<div class="subtext">\D+(\d)\D+<\/div>/);
  40. if (!cardInfo) {
  41. abort();
  42. ShowAlertDialog('完成', '已完成全部3轮探索队列');
  43. return;
  44. }
  45. var matchedAppids = htmlText.match(/0,\s+(\[.*\])/);
  46. if (!matchedAppids) {
  47. retry();
  48. return;
  49. }
  50. appids = JSON.parse(matchedAppids[1]);
  51. queueNumber = cardInfo[1];
  52. appids.length == 0 ? generateQueue() : clearApp();
  53. showProgress();
  54. })
  55. }
  56. function showProgress() {
  57. $J('#progressContainer').html('<br>剩余' + queueNumber + '个待探索队列, 当前队列剩余' + appids.length + '个待探索游戏');
  58. }
  59. beginQueue();
  60. }())