ducklabs

PS5 Add to Saved For Later - Disc

Oct 3rd, 2020 (edited)
2,331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         TargetPS5AddToSavedForLaterDisc
  3. // @namespace    http://example.tld
  4. // @version      0.3
  5. // @description  TargetPS5AddToSavedForLaterDisc
  6. // @author       You
  7. // @match        https://www.target.com/p/playstation-5-console/-/A-81114595*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. var preOrderButtonLoop = setInterval(function(){
  12.   var preOrderButton = document.querySelectorAll("[data-test='preorderButton']");
  13.   if (preOrderButton.length) {
  14.     clearInterval(preOrderButtonLoop);
  15.     clearInterval(preOrderRefreshLoop);
  16.  
  17.     var spamPreorderButton = setInterval(function(){
  18.       var closeModalButton = document.querySelectorAll("[aria-label='close']");
  19.       if (closeModalButton.length) {
  20.         closeModalButton[0].click();
  21.         var protectionPlan = document.querySelectorAll("input#warranty-service");
  22.         if (protectionPlan.length) {
  23.           // protectionPlan[0].checked = true;
  24.         }
  25.       }
  26.       preOrderButton[0].click();
  27.       var ps5saved = document.querySelectorAll("[data-test='moveSFLToCartBtn']");
  28.       if (ps5saved.length) {
  29.         clearInterval(spamPreorderButton);
  30.         window.location = "https://www.target.com/co-cart";
  31.       }
  32.     }, 1000);
  33.   }
  34. }, 1000);
  35.  
  36. var preOrderRefreshLoop = setInterval(function(){
  37.     var content = document.body.textContent || document.body.innerText;
  38.     var hasText = content.indexOf("Preorders have sold out")!==-1;
  39.     var needRefresh = content.indexOf("Due to a temporary issue")!==-1;
  40.     var need2 = content.indexOf("Something went wrong")!==-1;
  41.     if(hasText || needRefresh || need2){
  42.         window.location = "https://www.target.com/p/playstation-5-console/-/A-81114595";
  43.     }
  44. }, 3400);
  45.  
Add Comment
Please, Sign In to add comment