Skip to content

Instantly share code, notes, and snippets.

@moeiscool
Last active May 1, 2024 12:31
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moeiscool/b6cd0bfd9ad55556aa4e8a8f4640e30c to your computer and use it in GitHub Desktop.
Save moeiscool/b6cd0bfd9ad55556aa4e8a8f4640e30c to your computer and use it in GitHub Desktop.
Browser-Based Buy Bot for BestBuy Xbox Series X or PS5

Browser-Based Buy Bot for BestBuy Xbox Series X or PS5 (Tested on BestBuy.ca)

This is not made for scalping. It is made for people who just want a dang console.

I made this to run in my Google Chrome web browser. You will need to leave a tab open. When the console is seen as available it will be added to your cart, default confirmations will be selected then you will be brought to the payment information page. Once it makes it to the payment information page a sound will play and an alert popup will appear.

If it is out of stock it will just wait 2 minutes and refresh.

This script will not complete any checkout processes. It will not process any purchases against your payment information. It only gets you to the payment information input page.

You should already be logged in and you should add your payment details in the Account page before hand.

#How to use :

  1. Open Google Chrome
  2. Install a Browser Extension that allows you to run custom javascript on the website.
  1. Open a Tab at https://bestbuy.ca
  2. Once installed click the CJS icon in the top right of the browser window.
  3. Paste the code from the buyFromBestBuy.js file and press Save.
  4. Refresh and it will become active. You can see the log posts in the Developer Console of your web browser.

This can technically work in any browser. You just need a module to run the custom code each time page refreshes.

var audio;
function doSound() {
try{
audio.pause();
}catch(err){
}
audio = new Audio('https://www.soundhelix.com/examples/mp3/SoundHelix-Song-7.mp3');
audio.play();
}
var bestBuyTimer = parseInt(localStorage.getItem('best-buy-count'))
var secondsToRefresh = 1
bestBuyTimer = isNaN(bestBuyTimer) ? 1 : bestBuyTimer
setTimeout(() => {
var bestBuyXboxPath = '/en-ca/product/xbox-series-x-1tb-console-new-model-online-only/14964951'
var bestBuyPS5Path = '/en-ca/product/playstation-5-console-online-only/14962185'
var confirmNoWarranty = '/en-ca/required-parts'
var paymentChoice = '/en-ca/basket'
console.log('Checking Xbox Page...')
if(
location.pathname.indexOf(bestBuyXboxPath) > -1 ||
location.pathname.indexOf(bestBuyPS5Path) > -1
){
const el = document.querySelector('.addToCartButton');
console.log('Is Xbox Series X page')
if(el.disabled){
++bestBuyTimer
secondsToRefresh = (70 + bestBuyTimer)
console.log(`Out of Stock... Reloading in ${secondsToRefresh} seconds`)
localStorage.setItem('best-buy-count',`${bestBuyTimer}`)
setTimeout(() => {
location.reload();
if(bestBuyTimer > 9){
localStorage.setItem('best-buy-count',`1`)
}
},1000 * secondsToRefresh)
}else{
doSound()
el.click()
}
}else if(location.pathname.indexOf(confirmNoWarranty) > -1){
doSound()
const el = document.querySelector('[data-automation="go-to-cart"]');
console.log('Is Confirm Adding Page')
if(el.disabled){
console.log('Error on Page')
setTimeout(() => {
location.reload();
},1000 * 20)
}else{
console.log('Going to Cart!')
el.click()
}
}else if(location.pathname.indexOf(paymentChoice) > -1){
alert('BUY THE XBOX MAN!')
doSound()
}else{
console.log('Wrong Page : ' + location.href)
}
},5000)
@dev88jerry
Copy link

Hi, I tried to run your code but changed the path to an item in stock. The locations.pathname.indexOf never gets triggered so it isn't able to show me a cart with the in stock item.

@kkapuria3
Copy link

BestBuy Bot — Open Source GPU/PS5/Xbox Bot
https://github.com/kkapuria3/BestBuy-GPU-Bot

Hi, I tried to run your code but changed the path to an item in stock. The locations.pathname.indexOf never gets triggered so it isn't able to show me a cart with the in stock item.

@Helpmebuyaconsole
Copy link

Hello, I honestly have very little experience with coding, but I just want to buy a Xbox series X. I've tried for almost a year without luck, so I'm turning to bots. I cant seem to find anyone with a bot for microsoft.com which seems to be in stock most often. Do you know of any such bot that would monitor the status and auto buy from microsoft? If not, is there an adaptation for this code to autobuy? I do not have access to my phone or computer very often (nature of my job) and I don't want to miss an opportunity. I have tried hot stock, etc. and it doesn't help. Thank you!

@ovochase
Copy link

@Helpmebuyaconsole did you get a series x yet? I have one I’ll sell you for $550. That’s what you’d pay after tax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment