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,51 +25,46 @@ 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"]
query AOS_fetchButtonStateData($zip: String!, $store: String!) {
productBySkuId(skuId: "6614151") { const queries = skuIds.map(skuId => ({
fulfillmentOptions( skuId,
input: { query: `
buttonState: {context: PDP, destinationZipCode: $zip, storeId: $store}, query AOS_fetchButtonStateData($zip: String!, $store: String!) {
shipping: {destinationZipCode: $zip}, productBySkuId(skuId: "${skuId}") {
inStorePickup: {storeId: $store} fulfillmentOptions(
} input: {
) { buttonState: {context: PDP, destinationZipCode: $zip, storeId: $store},
buttonStates { shipping: {destinationZipCode: $zip},
buttonState inStorePickup: {storeId: $store}
planButtonState }
displayText ) {
skuId buttonStates {
buttonState
planButtonState
displayText
skuId
}
} }
} }
} }
} `
`; }));
//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,31 +90,34 @@ 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) {
if ( const data = await fetchGraphQL(zip, store, query);
data && if (
data.data && data &&
data.data.productBySkuId && data.data &&
data.data.productBySkuId.fulfillmentOptions && data.data.productBySkuId &&
data.data.productBySkuId.fulfillmentOptions.buttonStates && data.data.productBySkuId.fulfillmentOptions &&
data.data.productBySkuId.fulfillmentOptions.buttonStates.length > 0 data.data.productBySkuId.fulfillmentOptions.buttonStates &&
) { data.data.productBySkuId.fulfillmentOptions.buttonStates.length > 0
const buttonState = data.data.productBySkuId.fulfillmentOptions.buttonStates[0].buttonState; ) {
console.log(`Store: ${store} Ship to: ${zip} -> buttonState: ${buttonState}`); const buttonState = data.data.productBySkuId.fulfillmentOptions.buttonStates[0].buttonState;
if (buttonState !== "SOLD_OUT") { console.log(`skuId: ${skuId} Store: ${store} Ship to: ${zip} -> buttonState: ${buttonState}`);
found = true; if (buttonState !== "SOLD_OUT") {
winningResult = { zip, store, buttonState, data }; found = true;
return winningResult; winningResult = { skuId, zip, store, buttonState, data };
playAlarm()
return winningResult;
}
} else {
console.log(`Incomplete data for zip ${zip}, store ${store}.`);
} }
} else { lines++
console.log(`Incomplete data for zip ${zip}, store ${store}.`); if(lines > 30) {
} lines = 0;
lines++ process.stdout.write('\x1B[3J\x1B[2J\x1B[H');
if(lines > 30) { }
lines = 0; await new Promise(resolve => setTimeout(resolve, 500));
process.stdout.write('\x1B[3J\x1B[2J\x1B[H');
} }
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