Skip to content

Instantly share code, notes, and snippets.

@minhanhhere
Last active January 27, 2016 08:05
Show Gist options
  • Save minhanhhere/65c41125b2c221c69edb to your computer and use it in GitHub Desktop.
Save minhanhhere/65c41125b2c221c69edb to your computer and use it in GitHub Desktop.
Lazada lucky draw
/*
* http://www.lazada.vn/le-hoi-mua-sam-tet-nguyen-dan-vong-quay
* voucher sector: 3, 7, 9, 14
*/
var mar_timeout;
var mar_count = 0;
function marspin() {
scroll(0, 0);
mar_count++;
$('.spin-the-wheel__wheel-wrapper').click();
mar_timeout = window.setTimeout(marspin, 15000);
}
function marstop() {
clearTimeout(mar_timeout);
}
$(document).ajaxComplete(function( event, xhr, settings) {
if (settings.url.indexOf('/ajax/lottery/spinTheWheel') === 0) {
try {
var json = JSON.parse(xhr.responseText);
var voucher_found = json.data.sector == 3 || json.data.sector == 7 || json.data.sector == 9 || json.data.sector == 14;
console.log('n = ' + mar_count + ': ' + json.data.sector + ' (' + voucher_found + ') | ' + settings.url);
if (voucher_found) {
marstop();
console.log('Voucher found!!!!!!!!!');
}
} catch(e) {
}
}
});
marspin();
/*
* http://www.lazada.vn/le-hoi-mua-sam-tet-nguyen-dan-vong-quay
* voucher sector: 3, 7, 9, 14
*/
var mar_timeout;
var mar_count = 0;
var url = '';
function marspin() {
mar_count++;
$.get(url, function(json) {})
.done(function(json) {
var voucher_found = json.data.sector == 3 || json.data.sector == 7 || json.data.sector == 9 || json.data.sector == 14;
console.log('n = ' + mar_count + ': ' + json.data.sector + ' (' + voucher_found + ')');
if (voucher_found) {
console.log('Voucher found!!!!!!!!!');
console.log(JSON.stringify(json));
alert('Voucher found!!!!!!!!!');
} else {
mar_timeout = window.setTimeout(marspin, 800);
}
})
.fail( function() {
console.log('fail, retry');
mar_timeout = window.setTimeout(marspin, 800);
});
}
$(document).ajaxComplete(function( event, xhr, settings) {
if (settings.url.indexOf('/ajax/lottery/spinTheWheel') === 0) {
url = 'http://www.lazada.vn' + settings.url;
console.log('Found url: ' + url);
marspin();
}
});
$('.spin-the-wheel__wheel-wrapper').click();
/*
* http://www.lazada.vn/le-hoi-mua-sam-tet-nguyen-dan-vong-quay
* voucher sector: 3, 7, 9, 14
*/
var mar_timeout;
var mar_count = 0;
var url = '';
var mar_vouchers = [];
function marspin() {
mar_count++;
$.get(url, function(json) {})
.done(function(json) {
var voucher_found = json.data.sector == 3 || json.data.sector == 7 || json.data.sector == 9 || json.data.sector == 14;
console.log('n = ' + mar_count + ': ' + json.data.sector + ' (' + voucher_found + ')');
if (voucher_found) {
mar_vouchers.push(json);
console.log('Voucher found!!!!!!!!!');
console.log(JSON.stringify(json));
alert('Voucher found!!!!!!!!!');
$('#mar_vouchers').empty();
$('#mar_vouchers').append(JSON.stringify(mar_vouchers));
}
mar_timeout = window.setTimeout(marspin, 800);
})
.fail( function() {
console.log('fail, retry');
mar_timeout = window.setTimeout(marspin, 800);
});
}
$(document).ajaxComplete(function( event, xhr, settings) {
if (settings.url.indexOf('/ajax/lottery/spinTheWheel') === 0) {
url = 'http://www.lazada.vn' + settings.url;
console.log('Found url: ' + url);
marspin();
}
});
$('body').prepend('<div id="mar_vouchers" style="padding: 15px; position:absolute; top: 0; left: 0; z-index: 9999; background: white; height: 500px; width: 100%; overflow: auto; display: block; font-size:1.3em;"></div>');
$('#mar_vouchers').append('[Result will show here]');
$('.spin-the-wheel__wheel-wrapper').click();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment