Update for alarm playing

Ibraheem Saleh 10 months ago
parent 276d74fac7
commit 50ebc2f786

2
.gitignore vendored

@ -0,0 +1,2 @@
node_modules

@ -0,0 +1,10 @@
# 5090 Bot from wbuffetsukdik reddit user
Here's the github repository. It requires a bit of technical knowledge to set up, but not too hard.
#Install nodeJS and NPM.
#Move the files in the repository into a folder on your computer named "GPUMonitor".
#Open the command line, navigate to the folder using "cd" to move to the file path
#When you are in the correct folder in the terminal, run the command "npm i". This installs a HTTP library that is required for the bot.
#Once installed, navigate to the parent directory of your folder. "cd.." if you are inside your folder.
#Run the command "node GPUMonitor" and the bot will begin running.

Binary file not shown.

@ -1,5 +1,8 @@
import fetch from 'node-fetch'; import fetch from 'node-fetch';
import Aplay from 'node-aplay';
const url = 'https://www.bestbuy.com/gateway/graphql'; const url = 'https://www.bestbuy.com/gateway/graphql';
const headers = { const headers = {
@ -22,9 +25,13 @@ const headers = {
'TE': 'trailers' 'TE': 'trailers'
}; };
const query = ` const skuIds = ["6614151","6578810","6616096","6617487","6614119","6614120","6616095","6616092","6616096","6614122","6616093","6616090","6616091","6615930","6615929","6615931"]
const queries = skuIds.map(skuId => ({
skuId,
query: `
query AOS_fetchButtonStateData($zip: String!, $store: String!) { query AOS_fetchButtonStateData($zip: String!, $store: String!) {
productBySkuId(skuId: "6614151") { productBySkuId(skuId: "${skuId}") {
fulfillmentOptions( fulfillmentOptions(
input: { input: {
buttonState: {context: PDP, destinationZipCode: $zip, storeId: $store}, buttonState: {context: PDP, destinationZipCode: $zip, storeId: $store},
@ -41,32 +48,23 @@ const query = `
} }
} }
} }
`; `
}));
//CHANGE YOUR STORES HERE //CHANGE YOUR STORES HERE
const params = [ const params = [
{ zip: "80487", store: "382" }, { zip: "97504", store: "2517" },
{ zip: "80487", store: "1079" },
{ zip: "80487", store: "693" },
{ zip: "80487", store: "164" },
{ zip: "80487", store: "1224" },
{ zip: "80487", store: "210" },
{ zip: "80487", store: "1416" },
{ zip: "80487", store: "211" },
{ zip: "80487", store: "225" },
{ zip: "80487", store: "1124" },
{ zip: "80487", store: "1194" },
{ zip: "80487", store: "298" },
{ zip: "80487", store: "212" },
{ zip: "80487", store: "1171" },
{ zip: "80487", store: "1031" },
]; ];
let lines = 0; let lines = 0;
let found = false; let found = false;
let winningResult = null; let winningResult = null;
async function fetchGraphQL(zip, store) { function playAlarm() {
new Aplay('alarm.wav').play();
}
async function fetchGraphQL(zip, store, query) {
const body = { const body = {
query, query,
variables: { zip, store }, variables: { zip, store },
@ -84,7 +82,7 @@ async function fetchGraphQL(zip, store) {
} }
return await response.json(); return await response.json();
} catch (err) { } catch (err) {
console.error(`Error fetching for zip ${zip}, store ${store}:`, err); console.error(`Error fetching for zip ${zip}, store ${store} query ${query}:`, err);
return null; return null;
} }
} }
@ -92,7 +90,8 @@ async function fetchGraphQL(zip, store) {
async function pollStore(zip, store) { async function pollStore(zip, store) {
console.log(`Starting poll for zip ${zip} and store ${store}...`); console.log(`Starting poll for zip ${zip} and store ${store}...`);
while (!found) { while (!found) {
const data = await fetchGraphQL(zip, store); for (const { skuId, query } of queries) {
const data = await fetchGraphQL(zip, store, query);
if ( if (
data && data &&
data.data && data.data &&
@ -102,10 +101,11 @@ async function pollStore(zip, store) {
data.data.productBySkuId.fulfillmentOptions.buttonStates.length > 0 data.data.productBySkuId.fulfillmentOptions.buttonStates.length > 0
) { ) {
const buttonState = data.data.productBySkuId.fulfillmentOptions.buttonStates[0].buttonState; const buttonState = data.data.productBySkuId.fulfillmentOptions.buttonStates[0].buttonState;
console.log(`Store: ${store} Ship to: ${zip} -> buttonState: ${buttonState}`); console.log(`skuId: ${skuId} Store: ${store} Ship to: ${zip} -> buttonState: ${buttonState}`);
if (buttonState !== "SOLD_OUT") { if (buttonState !== "SOLD_OUT") {
found = true; found = true;
winningResult = { zip, store, buttonState, data }; winningResult = { skuId, zip, store, buttonState, data };
playAlarm()
return winningResult; return winningResult;
} }
} else { } else {
@ -118,6 +118,7 @@ async function pollStore(zip, store) {
} }
await new Promise(resolve => setTimeout(resolve, 500)); await new Promise(resolve => setTimeout(resolve, 500));
} }
}
return null; return null;
} }

7
package-lock.json generated

@ -9,6 +9,7 @@
"version": "1.0.0", "version": "1.0.0",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"node-aplay": "^1.0.3",
"node-fetch": "^3.3.2" "node-fetch": "^3.3.2"
} }
}, },
@ -56,6 +57,12 @@
"node": ">=12.20.0" "node": ">=12.20.0"
} }
}, },
"node_modules/node-aplay": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/node-aplay/-/node-aplay-1.0.3.tgz",
"integrity": "sha512-sZmdPpIxHeAjOdP4lQy7hRfUQYdAabodx4+zedSf5Slpm36yWdnpNTLP3jZEsKBZfIIyvzZlCpRvP32skKjHnw==",
"license": "MIT"
},
"node_modules/node-domexception": { "node_modules/node-domexception": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",

@ -11,6 +11,7 @@
"license": "ISC", "license": "ISC",
"description": "", "description": "",
"dependencies": { "dependencies": {
"node-aplay": "^1.0.3",
"node-fetch": "^3.3.2" "node-fetch": "^3.3.2"
} }
} }

Loading…
Cancel
Save