Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@vivekagr
Created March 16, 2016 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vivekagr/36b12fec06ab0c4b228e to your computer and use it in GitHub Desktop.
Save vivekagr/36b12fec06ab0c4b228e to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Amazon Add to Cart
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match *://www.amazon.in/*/dp/*
// @match *://www.amazon.in/dp/*
// @match *://www.amazon.in/gp/product*
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
// Your code here...
var buyNowButton = document.querySelector('#buy-now-button');
var addToCardButton = document.querySelector('#add-to-cart-button')
if (addToCardButton) {
addToCardButton.click();
console.log('clicking add to cart button');
} else if (buyNowButton) {
buyNowButton.click()
console.log('clicking buy now button');
} else {
location.reload();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment