Created
March 16, 2016 08:10
-
-
Save vivekagr/36b12fec06ab0c4b228e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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