Skip to content

Option to use saved items list #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Spegs21 opened this issue Jan 21, 2022 · 6 comments
Open

Option to use saved items list #50

Spegs21 opened this issue Jan 21, 2022 · 6 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@Spegs21
Copy link

Spegs21 commented Jan 21, 2022

I've heard people may have better luck by adding to the cart from the saved items list.

This seemed like it should be a fairly easy implementation but the page is slow to load so the script runs before the button loads and can't find it.

if (pagetitle.includes(ITEM_KEYWORD) || pagetitle.includes("Saved")) {

         //Create Custom Badge
         //
         const $badge = createFloatingBadge("Auto Detecting Mode", "Initializing ..");
         console.log('BEGIN ')
         document.body.appendChild($badge);
         $badge.style.transform = "translate(0, 0)"
         //Out of Stock Button
         //
         var OOSButton;
         const OOSButton_SavedItems_L1 = "c-button c-button-outline c-button-sm c-button-block add-to-cart-button"
         //c-button c-button-outline c-button-sm c-button-block c-button-icon c-button-icon-leading add-to-cart-button
         const OOSButton_L1 = "c-button c-button-disabled c-button-lg c-button-block add-to-cart-button"
         const OOSButton_L2 = "btn btn-disabled btn-lg btn-block add-to-cart-button"
         console.log('BEGIN ')
         if (document.getElementsByClassName(OOSButton_L1).length == 1)
         {
             OOSButton = document.getElementsByClassName(OOSButton_L1);
             console.log('OOS Button Class 1 : ' + OOSButton_L1)
         }
         else if (document.getElementsByClassName(OOSButton_L2).length == 1)
         {
             OOSButton = document.getElementsByClassName(OOSButton_L2);
             console.log('OOS Button Class 2 : ' + OOSButton_L2)
         }
         else if (document.getElementsByClassName(OOSButton_SavedItems_L1).length == 1)
         {
             OOSButton = document.getElementsByClassName(OOSButton_SavedItems_L1);
             console.log('OOS Button Saved Items Class 1 : ' + OOSButton_SavedItems_L1)
         }

I tired adding event handlers to wait for the page to load but I could never get the window.onLoad event to fire for the popup, even if I attached an event handler to it.

@kkapuria3 kkapuria3 self-assigned this Jan 24, 2022
@kkapuria3 kkapuria3 added the good first issue Good for newcomers label Jan 24, 2022
@Spegs21
Copy link
Author

Spegs21 commented Jan 25, 2022

I added a separate check of the saved items list in the main loop and delay the code with a timeout. It's not great because it can still start too fast but we also don't want to delay too long. An even trigger would be better.

https://github.com/Spegs21/BestBuy-GPU-Bot/blob/be521ff572229963c37df34e84f82342c530a120/best-buy-tm.js#L724

I've also begun the framework to support multiple items in the item list but counting them and refreshing/proceeding to add to cart is as for as I've gotten.

@SebTota
Copy link

SebTota commented Jan 31, 2022

Hey @Spegs21, I can help take a look at this if you need a second pair of eyes on it. I've also noticed that the Add to Cart and Sold Out buttons do not load all at once so it may be best to track them individually as they are loaded in and take the first one that shows Add to Cart without waiting for the rest to finish rendering.

@Spegs21
Copy link
Author

Spegs21 commented Jan 31, 2022

@SebTota I'd welcome the help. I haven't done much with JS so it can take me a bit to figure out how to do some of this stuff.

@SebTota
Copy link

SebTota commented Feb 1, 2022

Do you want any item in the saved item list to be added to card, or does the name of the item still need to contain the keyword?

@Spegs21
Copy link
Author

Spegs21 commented Feb 3, 2022

I was planning on checking for the keyword still but we could just limit this to the first item if finds in stock for simplicity.

@SebTota
Copy link

SebTota commented Feb 3, 2022

I can add the extra check in the title. My code is very similar to yours, I just check the buttons when a change in the DOM has been made rather than using a timeout so it shouldn't be a problem. I did see @kkapuria3 assigned this to himself though so I'm not sure if I should still work on it or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants