1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
(function () { 'use strict'; var butt = $J('<a/>', { 'class': 'header_installsteam_btn_content ', 'id': 'auto_exploration', 'href': 'javascript:void(0);', 'onclick': 'auto_exploration()' }).text('自动探索'); $J('div[id="header_notification_area"]').prepend(butt); unsafeWindow.auto_exploration = function auto_exploration() { var appids, running = true, queueNumber, progressDialog = ShowAlertDialog('探索中', $J('<div/>').append($J('<div/>', { 'class': 'waiting_dialog_throbber' })).append($J('<div/>', { 'id': 'progressContainer' }).text('获取进度...')), '停止').done(abort);
function abort() { running = false; progressDialog.Dismiss(); }
function retry() { abort(); ShowConfirmDialog('错误', '是否重试?', '重试', '放弃').done(auto_exploration) }
function clearApp() { if (!running) return; showProgress(); var appid = appids.shift(); !appid ? generateQueue() : $J.post(appids.length ? '/app/' + appid : '/explore/next/', { sessionid: g_sessionID, appid_to_clear_from_queue: appid }).done(clearApp).fail(retry); }
function generateQueue() { running && $J.post('/explore/generatenewdiscoveryqueue', { sessionid: g_sessionID, queuetype: 0 }).done(beginQueue).fail(retry); }
function beginQueue() { if (!running) return; $J.get('/explore/').done(function (htmlText) { var cardInfo = htmlText.match(/<div class="subtext">\D+(\d)\D+<\/div>/); if (!cardInfo) { abort(); ShowAlertDialog('完成', '已完成全部探索队列'); return; } var matchedAppids = htmlText.match(/0,\s+(\[.*\])/); if (!matchedAppids) { retry(); return; } appids = JSON.parse(matchedAppids[1]); queueNumber = cardInfo[1]; appids.length == 0 ? generateQueue() : clearApp(); showProgress(); }) }
function showProgress() { $J('#progressContainer').html('<br>剩余' + queueNumber + '个待探索队列, 当前队列剩余' + appids.length + '个待探索游戏'); } beginQueue(); } })();
|