/*! * Auto Mục Tiêu Cuối - v1.2.130916 * Tự động quay và nhận quà tại http://muctieu.vtcgame.vn * https://baivong.github.io * * Made by Zzbaivong * Under MIT License */ /* global jsConfig, cm */ (function() { 'use strict'; if (top.location.host !== 'muctieu.vtcgame.vn') return; if (!jsConfig.isLogin) { cm.ThongBao('Bạn chưa đăng nhập! Vui lòng đăng nhập để sử dụng chức năng này.'); return; } function spin() { $.post('/Home/GetSpin', { token: jsConfig._token }).done(function(data) { if (!data) { cm.ThongBao('Lỗi dữ liệu!'); return; } if (data.ResponseStatus < 0) { var thongbao = ''; switch (data.ResponseStatus) { case -55: thongbao = 'Bạn đã hết lượt quay.'; break; case -50: thongbao = 'Tài khoản không tồn tại.'; break; case -99: thongbao = 'Hệ thống bận. Vui lòng quay lại sau.'; break; case -600: thongbao = 'Đầu vào không hợp lệ. Hãy thử tải lại trang.'; break; case -83: thongbao = 'Tài khoản của bạn đã bị khóa do bị phát hiện hack, bug sự kiện. Chi tiết vui lòng liên hệ tổng đài 19001530.'; break; default: thongbao = 'Thông tin tài khoản không hợp lệ.'; } cm.ThongBao(thongbao); } else { var totalSpin = data.TotalSpin; if (!sessionStorage.spinCounter) sessionStorage.spinCounter = (totalSpin + 1); $currentPoint.text(data.ScoreCF); $currentSpin.text(totalSpin); var $item = $('<span/>', { text: (totalSpin + 1) + ': ' + data.ItemName }); if (data.ItemName.indexOf('điểm CF') !== -1) $item.css('color', 'gray'); $autoSpin.prepend($('<li/>').append($item)); if (totalSpin > 0) { spin(); } else { cm.ThongBao('Hoàn tất tự động quay. Trang sẽ được tải lại sau 3 giây.'); setTimeout(function() { top.location.reload(); }, 3000); } } }).fail(function() { cm.ThongBao('Lỗi kết nối!'); }); } var $currentSpin = $('#currentSpin'), $currentPoint = $('#currentPoint'), $autoSpin = $('<ol/>', { id: 'autoSpin', css: { overflow: 'auto', height: 130, color: '#006e83' } }), $marquee = $('.thong_bao1 marquee'); if ($marquee.length) { $('.thong_bao1 marquee').replaceWith($autoSpin); } else { $autoSpin = $('#autoSpin'); } if (sessionStorage.spinCounter) sessionStorage.removeItem('spinCounter'); spin(); })(jQuery); (function() { 'use strict'; if (top.location.host !== 'muctieu.vtcgame.vn') return; if (!jsConfig.isLogin) { cm.ThongBao('Bạn chưa đăng nhập! Vui lòng đăng nhập để sử dụng chức năng này.'); return; } function getItems() { if (!listId || max === 0 || current >= max) return; $.post('/Home/NhanQuaKhoDo', { id: listId[current], token: jsConfig._token }).done(function(response) { if (response.ResponseStatus < 0) { var thongbao = ''; switch (response.ResponseStatus) { case -600: thongbao = 'Đầu vào không hợp lệ. Hãy thử tải lại trang.'; break; case -2: thongbao = 'Vật phẩm không tồn tại.'; break; case -99: thongbao = 'Có lỗi trong quá trình xử lý. Vui lòng thử lại!'; break; case -5: case -202: thongbao = 'Hệ thống bận. Vui lòng quay lại sau.'; break; case -98: case -124: thongbao = 'Thông tin không hợp lệ.'; break; case -62: thongbao = 'Quỹ vcoin đã hết. Không đủ vcoin trả thưởng.'; break; case -999: case -1000: thongbao = 'Nhận quà thất bại.'; break; default: thongbao = 'Lỗi chưa biết.'; } cm.ThongBao(thongbao); } else { current++; if (current < max) { getItems(); } else { cm.ThongBao('Nhận quà thành công. Hãy kiểm tra kho đồ của bạn.'); if (sessionStorage.spinCounter) sessionStorage.removeItem('spinCounter'); setTimeout(function() { cm.ShowPopupKhoDo(); }, 1000); } } }).fail(function() { cm.ThongBao('Lỗi kết nối!'); }); } function getListId(pageIndex) { $.post('/Home/KhoDo', { page: pageIndex }).done(function(input) { var regex = /id="(\d{1,9})"/gi, matches = input.match(regex), output = []; if (!matches) { if (pageIndex < pageCounter) { getListId((pageIndex + 1)); } else { if (pageIndex === 1) cm.ThongBao('Kho đồ trống rỗng.'); } return; } $.each(matches, function(index, val) { output.push(val.match(/\d+/)[0]); }); listId = listId.concat(output); if (pageIndex < pageCounter) { getListId((pageIndex + 1)); } else { max = listId.length; if (!max) { cm.ThongBao('Kho đồ trống rỗng.'); } else { getItems(); } } }); } var listId = [], current = 0, max = 0, pageCounter = (!sessionStorage.spinCounter) ? 1 : Math.ceil(parseInt(sessionStorage.spinCounter, 10) / 10); getListId(1); })(jQuery);