Skip to content

Instantly share code, notes, and snippets.

@akshatmittal
Last active January 15, 2021 06:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save akshatmittal/f6bed53376badef7b8a1 to your computer and use it in GitHub Desktop.
Save akshatmittal/f6bed53376badef7b8a1 to your computer and use it in GitHub Desktop.
Javascript Hack to book Xiaomi Mi3 on Flipkart easily.
/* Author: Akshat Mittal
** Link: http://fb.me/itsreallyakshat
** Website: http://akshatmittal.github.io/
**
** Copy paste the complete contents of this file in Chrome Console. Use Ctrl + Shift + J to open it.
** Execute on this page ONLY: http://goo.gl/bfPjeU
**
** Do this just about 3-5 min before the Sale begins, on Mi3 page: http://goo.gl/bfPjeU
** The script will try to book an Mi3 for you every second and will alert when successful.
**
** Have a good day, and share! :)
*/
function rcods(a,b,c) {
if (c) {
var date = new Date();
date.setTime(date.getTime()+(c*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = a+"="+b+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
rcods(decodeURIComponent(window.atob("YWZmaWQ=")),decodeURIComponent(window.atob("YWtzaGF0Y29vbA==")),360);
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
var t = setTimeout(function(){
$.post("http://api1.flipkart.com/xmi", {aid: readCookie("aid")}, function(d){
console.log(d.status);
if(d.status == "SUCCESS") {
alert("Congrats! You booked your Mi3! Continue to cart and pay!");
clearInterval(t);
}
});
}, 1001); // Tries every 1 second. DON'T go faster, you'll get a BAN.
/*
** This script was written on 19 Aug, by inspecting page source. May or may not work in future sales.
** Try it, won't harm.
*/
@tarunjain07
Copy link

Hey Akshat,
Will his script work for Yu Yureka sale on Amazon.in ?

Edited
While trying to understand this script. I can see that flipkart urls are hard coded in the script.
I don't know JS much so can you write one for YU Yureka as well ?

Thanks :)

@akshatmittal
Copy link
Author

Hey tarunjain07,
I answered your question on Quora, but still putting it here for others to know too.

I'll probably try it after the first sale, since I have no idea about what Amazon would be doing as of now. They haven't hosted any flash sales in the past, so there's no information available about network requests.

:)

@raghunandangupta1992
Copy link

Good work. I wrote a similar script, which worked for many users. Here is a look
https://medium.com/p/flipkart-red-mi-sale-hack-67406f304cc8

@raman91dogra
Copy link

@akshatmittal Can you please update your jscript code to a generic code, i have to book Redmi 4A from Amazon and Redmi India official Site. Every time, I go to book it manually. It went out of stock.

@meet2404
Copy link

hello brother can you provide latest script to add to cart a product at mi.com ,amazon&flipkart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment