kkapuria3/BestBuy-GPU-Bot

Add capabilities/refactor

spearmootz opened this issue · 3 comments

I was reviewing the code and while it looks fairly good i think this can be improved by using webpack and separating things into their own files.

I took this program and modified it to buy open box items and i am testing it now. i would like to contribute it back but it was kind of a hack. so not sure if it would be accepted buy i might take a stab at refactoring to a more OOP style, where the state is determined in some central index file but then the logic in other files actually do the work. i also found room to improve upon the setTimeout situation by using promises and having smaller timeouts. so for example

const clickButton = (selector) => new Promise(resolve => {
  setTimeout(() => {
    const button = document.querySelector(selector);
    if (button) {
      button.click();
    } else {
      resolve(clickButton(selector));
    }
  }, 100)
});

await clickButton("someSelector");

// move on to subsequent click

please let me know if this would be accepted so i can start, obviously this would need to be compiled, so a couple of more steps for noobs but more extensible, maintainable

i also added in my version the ability to add a list of skus to look for in a search page. which is not as useful due to timing in drops but probably fine in open box

code needs refactor. do you have a working version open source ?