#NoEnv SetBatchLines -1 SetWorkingDir %A_ScriptDir% #Include Chrome.ahk if (Chromes := Chrome.FindInstances()) ChromeInst := {"base": Chrome, "DebugPort": 9224} else MsgBox That didn't work. Please check if Chrome is running in debug mode. if !(page := ChromeInst.GetPage()) MsgBox, Could not retrieve page! ; === CONFIGURE YOUR PRICE RANGE HERE === minPrice := 1.00 ; Minimum price to accept maxPrice := 61.00 ; Maximum price to accept ; Hotkey to start the sequence f1:: Loop { ; EBT white flare: https://www.target.com/p/pok-233-mon-scarlet-violet-s10-5-elite-trainer-box-1-trading-cards/-/A-94636860#lnk=sametab ; EBT Dark flare : https://www.target.com/p/pok-233-mon-scarlet-violet-s10-5-elite-trainer-box-2-trading-cards/-/A-94636862#lnk=sametab ; Booster Bundle white flare: https://www.target.com/p/pok-233-mon-scarlet-violet-s10-5-booster-bundle-box-v1-trading-cards/-/A-94681785#lnk=sametab ; Booster bundle Black flare: https://www.target.com/p/pok-233-mon-scarlet-violet-s10-5-booster-bundle-box-trading-cards/-/A-94681770#lnk=sametab ; Binder white flare: https://www.target.com/p/pok-233-mon-scarlet-violet-s10-5-binder-collection-2-trading-cards/-/A-94636851#lnk=sametab ; Binder Black flare https://www.target.com/p/pok-233-mon-scarlet-violet-s10-5-binder-collection-1-trading-cards/-/A-94636856#lnk=sametab ; Navigate to product page page.Call("Page.navigate", {"url": "https://www.target.com/p/pok-233-mon-scarlet-violet-s10-5-elite-trainer-box-2-trading-cards/-/A-94636862#lnk=sametab"}) page.WaitForLoad() Sleep, 1000 ; ======== PRICE CHECK SECTION ======== jsGetPrice = ( var priceElement = document.querySelector('span[data-test="product-price"]'); var priceText = priceElement ? priceElement.textContent.trim() : ""; priceText; ) result := page.Evaluate(jsGetPrice) priceText := result.value ; Clean and convert price if (priceText != "") { StringReplace, priceText, priceText, $, , All StringReplace, priceText, priceText, `,, , All StringReplace, priceText, priceText, /ea, , All StringReplace, priceText, priceText, ea, , All StringReplace, priceText, priceText, " ", , All priceValue := priceText + 0 ; Convert to number ; Debug: Uncomment to see price found ;MsgBox, Price found: %priceValue% ; Check price range if (priceValue < minPrice || priceValue > maxPrice) { ; Price out of range - skip to loop end ; MsgBox, Price %priceValue% is out of range (%minPrice%-%maxPrice%). Skipping. page.Call("Page.navigate", {"url": "https://www.google.com/"}) page.WaitForLoad() Sleep, 9000 continue } } else { ; Failed to get price - skip to loop end ; MsgBox, Could not find price. Skipping. page.Call("Page.navigate", {"url": "https://www.google.com/"}) page.WaitForLoad() Sleep, 9000 continue } ;Javascript dom manipulation pre order button while (true) { ; EBT white flare: id="addToCartButtonOrTextIdFor94636860" ; EBT Dark flare : id="addToCartButtonOrTextIdFor94636862" ; Booster Bundle white flare: id="addToCartButtonOrTextIdFor94681785" ; Booster bundle Black flare: id="addToCartButtonOrTextIdFor94681770" ; Binder white flare: id="addToCartButtonOrTextIdFor94636851" ; Binder Black flare id="addToCartButtonOrTextIdFor94636856" Sleep, 1000 jsCode := " ( (function checkAndClickPreorder() { var btn = document.getElementById('addToCartButtonOrTextIdFor94636862'); if (btn && !btn.disabled) { btn.scrollIntoView(); btn.click(); return true; // Clicked } return false; // Not clicked })() )" result := Page.Evaluate(jsCode) ;MsgBox, % "result.value: " result.value if (result.value == 0) { ; Exit the loop if button was not clicked break } else { Sleep, 2000 ;Click the View cart & check out when error jsCode := " ( (function clickViewCartIfErrorModal() { var btn = document.querySelector('a[data-test=""errorContent-viewCartButton""]'); if (btn) { btn.scrollIntoView(); btn.click(); return true; } return false; })() )" clicked := Page.Evaluate(jsCode) Sleep, 200 ;Click the View cart & check out when in stock in cart new code jsCode := " ( (function clickViewCartAndCheckout() { var btn = document.querySelector('a[href=""/cart""]'); if (btn) { btn.scrollIntoView(); btn.click(); return true; } return false; })() )" clicked := Page.Evaluate(jsCode) Sleep, 2000 ; Clicking the Checkout Button new code jsCode := " ( (function clickCheckoutButton() { var btn = document.querySelector('button[data-test=""checkout-button""]'); if (btn && !btn.disabled) { btn.scrollIntoView(); btn.click(); return true; } return false; })() )" clicked := Page.Evaluate(jsCode) Sleep, 3000 ; --- Step 1 --- place your oder button new code jsCode := " ( (function clickPlaceOrderButton() { var btn = document.querySelector('button[data-test=""placeOrderButton""]'); if (btn && !btn.disabled) { btn.scrollIntoView(); btn.click(); return true; } return false; })() )" clicked := Page.Evaluate(jsCode) Sleep, 2000 ; --- Step 2 --- cvv - pin if needed fall back ; new code cvv jsCode := " ( (function focusCVV() { var cvv = document.getElementById('enter-cvv'); if (cvv) { cvv.focus(); cvv.scrollIntoView(); return true; } return false; })() )" focused := Page.Evaluate(jsCode) if (focused) { Sleep, 300 ; Short pause to ensure focus } else { MsgBox, Could not focus CVV field! } Sleep, 200 ; new code pin jsCode := " ( (function focusPin() { var pin = document.getElementById('enter-pin'); if (pin) { pin.focus(); pin.scrollIntoView(); return true; } return false; })() )" focused := Page.Evaluate(jsCode) if (focused) { Sleep, 300 ; Short pause to ensure focus } else { MsgBox, Could not focus pin field! } ;type cvv - pin Send, 004 Sleep, 200 ; --- Step 3 --- confirm button new code jsCode := " ( (function clickConfirmButton() { var btn = document.querySelector('button[data-test=""confirm-button""]'); if (btn && !btn.disabled) { btn.scrollIntoView(); btn.click(); return true; } return false; })() )" clickedConfirm := Page.Evaluate(jsCode) ;MsgBox, % "clickedConfirm: " clickedConfirm.value if (clickedConfirm.value == 1) { ;Exit the loop if confirm button was break } break } ; end else } ; end while code Sleep, 5000 ; Go to google and loop page.Call("Page.navigate", {"url": "https://www.google.com/"}) page.WaitForLoad() Sleep, 6000 } ; Hotkey to exit the script f2::ExitApp