Tuesday, February 11, 2014

AutoCart Script - Sneaker Bot



Greetings Earthlings, I am a sneaker bot. I lurk deep within your browser; a behind the scenes master of stomping humanoid booty in the art of online shopping. I'm deceptive. I'm silent (when implemented right). I'm quick. I WIN. 




Mehhhhh. Maybe I talked myself up a bit, but I merely relay the facts. In short, I'm a simple script, packaged as a browser extension (Chrome in this case), that helps automate the process of selecting a shoe size, quantity, and hitting 'add to cart', specifically fashioned for use with sneaker purchases. I can be manually used on direct links, or I can also be directed from outside links such as twitter, search results, etc. etc. 


In order to be packaged as a chrome extension, I require a 'manifest.json' file. 


{
  "name": "sneaker_sniper_dood",
  "manifest_version": 2,
  "version": "1",
  "content_scripts": [
    {
      "matches": ["http://store.nike.com/*"],
      "js": ["autocart.js"]
    }
  ], "permissions": [
    "tabs", "http://store.nike.com/*"
  ]

}

An example of my contents are above. I'm a sneaker sniper dood. This files contains some required info for me to work. It also list the specific sites I'm built for, as well as points to the java script file (autocart.js in this case), that contains the bulk of my inner workings. More info on what all can be placed in the file can be found here: http://developer.chrome.com/extensions/manifest.html  

As for the bulk of my beauty (autocart.js), reference below:


var size = "10";
var amount = 2;

function addToCart() {
var sizesList=document.getElementsByName("skuAndSize")[0];
function setQuantity() {
   document.getElementsByName("qty")[0].selectedIndex = amount-1;
}
function setSizeValue() {
  for (var i=0; i
    if(sizesList.options[i].text == size) {
      document.getElementsByName("skuAndSize")[0].selectedIndex = i;
      setQuantity();
      }
   }
}
if(sizesList != undefined) {
  setSizeValue();
  document.getElementsByClassName("add-to-cart nsg-button--nike-orange")[0].click();
        else {
  setTimeout("addToCart()", 90);
}
}
setTimeout("addToCart()", 90);


The majority is simple functions that automate what a humanoid would do if they were selecting a size, a quantity to purchase, as well as clicking the 'add to cart' button. These functions may need a bit of periodic maintenance, but for the most part should work with ease. The only humanoid updates needed before my implementation would be an update to the size and amount variables.


Quick. Simple. Elegant. 

Want to see me in action. Yeah.... I thought so :)




1 comment:

  1. I have read all the comments and suggestions posted by the visitors for this article are very fine,We will wait for your next article so only.Thanks! Snkrs bot

    ReplyDelete