Any trick to add Redmi Note 3 during flash sell?

Below is a Java Script that you can run on the order page a few seconds prior to sale by pasting and executing it via JavaScript console.

This is totally untested, so use completely at your own risk.
Note that I have not made my purchase using this script.

PHP:
setInterval(function() {
    var buttonItems = document.getElementsByTagName('button');

    for (var i = 0; i < buttonItems.length; i++) {
        var buttonItem = buttonItems[i];

        if (buttonItem.textContent.includes("Add") && buttonItem.textContent.includes("Cart")) {
            buttonItem.click();
        }
    }

}, 10);

What it does...

1. Start a 10 millisecond timer in the page.
2. On each timer hit, get the list of buttons in the HTML page.
3. Iterate through the list of buttons and if any of them have Add and Cart in the button text, then invoke that button.

The idea is that this script will try to invoke all the Add Cart buttons with a 10 ms gap. Once the items get added to cart, you can navigate to cart, remove the stuff you don't need and complete the purchase.

Things to note,

1. JavaScript timers do not have a lot of precision and can also drift over time.
2. The entire script is based on assumption that the "Add cart" will be a button type element and the text content contains the words "Add" and "Cart". Presently, The Add to Cart buttons on Amazon satisfy these assumptions.
3. Navigating away from the page will kill the timers as well. So if you click on something that causes a navigation and to come back afterwards, the script is no longer running.
4. Once items get added to cart, navigate to cart or some place else and the timer will get killed.
5. If you know before hand the order of the items and consequently the the order of the buttons, you can tweak the code to selectively try to add your item of interest only.

Again, this is totally untested, so use at your own risk.
 
Verified that my script is working. Also, amended it to click the Join Waitlist item as well.

PHP:
setInterval(function () {
    var buttonItems = document.getElementsByTagName('button');

    for (var i = 0; i < buttonItems.length; i++) {
        var buttonItem = buttonItems[i];
        var buttonText = buttonItem.textContent

        if ((buttonText.includes("Add") && buttonText.includes("Cart"))
                || (buttonText.includes("Join") && buttonText.includes("Waitlist"))) {
            buttonItem.click();
        }
    }

}, 10);


BTW, I also came across another implementation of a similar script that people apparently have been using already. It should work just all well though I don't understand the obsession with using jQuery for something so trivial as this.

http://www.coupenyaari.in/2016/04/script-trick-how-to-buy-redmi-note-3.html

PHP:
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);

setInterval(function(){ if(jQuery('button').length >= 5){ jQuery('button:eq(0)').trigger('click'); } },10);

The programmer first creates a script element, sets source jquery library and added it to DOM so that jquery is downloaded, then he proceeds to use it to do the trivial task of getting a button by index and triggering the click event. Too roundabout method.
 
Last edited:
Yeah, pointless to use jquery for something like this when you can use pure javascript in a much simpler and more efficient way. Even worse is that he use the getElementsByTagName() to get the head element to append the script node when he could just as easily use the same interface to get the buttons and index into the array and trigger the button. The script is also missing the interval timer in the link that I posted. I guess that is an accidental omission. Corrected the code block in my last post.

Anyways, my script can be used to attempt adding all models while this one is meant to try for a specific one based on index. I was able to get all 3 color variants of the 2GB model of the phone in the cart today.
 
Back
Top