Skip to content

Instantly share code, notes, and snippets.

@DickyT
Last active April 11, 2020 22:20
Show Gist options
  • Save DickyT/7ae1c4fc4494be5afa351cadb823ed4f to your computer and use it in GitHub Desktop.
Save DickyT/7ae1c4fc4494be5afa351cadb823ed4f to your computer and use it in GitHub Desktop.
auto_add.bestbuy.js
function tryToAdd(sku) {
const audio = new Audio('https://interactive-examples.mdn.mozilla.net/media/examples/t-rex-roar.mp3');
const intId = setInterval(() => {
fetch("https://www.bestbuy.com/cart/api/v1/addToCart", {
"credentials": "include",
"headers": {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0",
"Accept": "application/json",
"Accept-Language": "en-US,en;q=0.5",
"Content-Type": "application/json; charset=UTF-8"
},
"referrer": `https://www.bestbuy.com/site/apple-airpods-with-charging-case-latest-model-white/${sku}.p?skuId=${sku}`,
"body": `{\"items\":[{\"skuId\":\"${sku}\"}]}`,
"method": "POST",
"mode": "cors"
}).then(res => {
if (res.ok) {
clearInterval(intId);
audio.play();
location.href = 'https://www.bestbuy.com/checkout/r/fulfillment';
} else {
console.log('NO LUCK');
}
});
}, 200);
}
tryToAdd(6364255);
tryToAdd(6364253);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment