WMT-AddPlanInCart

try to take over the world!

  1. // ==UserScript==
  2. // @name WMT-AddPlanInCart
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://www.walmart.com/*
  8. // @grant none
  9. // @locale en-us
  10. // ==/UserScript==
  11.  
  12. (function(modalOuter) {
  13. 'use strict';
  14. setTimeout(() =>
  15. {
  16. var cartItems = document.querySelectorAll('.Cart-Item-CarePlan.Cart-Item-CarePlan-NoCarePlan');
  17. console.log(cartItems);
  18. cartItems.forEach(
  19. (el) => {
  20. console.log('help!');
  21. let asurionPlan = document.createElement('div');
  22. asurionPlan.innerHTML = `
  23. <div class="radio-accessible" data-automation-id="cart-item-0-care-plan-options-1" data-tl-id="radio-button">
  24. <input type="radio" id="radio-1" name="item-warranties-a92c2862-db82-419f-b7a4-6b805a2099db" value="on">
  25. <label for="radio-1">
  26. <span aria-hidden="true">
  27. <span>Protection on this and all future devices</span><!-- react-text: 851 --> (<!-- /react-text --><span>+<strong>$3/month</strong></span><!-- react-text: 853 -->)<!-- /react-text -->
  28. </span>
  29. </label>
  30. </div>`;
  31. let planFlyout = document.createElement('span');
  32. planFlyout.innerHTML = `
  33. <div class="flyout flyout-left flyout-align-null flyout-animate inline-block-xs help-flyout CarePlan-help">
  34. <div class="flyout-backdrop"></div>
  35. <span class="HelpFlyout-trigger flyout-trigger" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-label="More info" role="button"><i class="elc-icon elc-icon-help"></i></span>
  36. <div class="flyout-modal flyout-basic flyout-modal-wide">
  37. <p class="no-margin CarePlan-help-text copy-small"><span class="CarePlan-bubble-text">
  38. Provides an ongoing care plan on this and all future purchases you buy on Walmart.com for a low monthly cost. Cancel any time.
  39. </span>
  40. </p>
  41. </div>
  42. </div>`;
  43. planFlyout.onclick = (ev) => {
  44. planFlyout.firstChild.nextSibling.classList.toggle('active');
  45. };
  46. asurionPlan.querySelector('label').appendChild(planFlyout);
  47. el.querySelector('form').appendChild(asurionPlan);
  48. }
  49. );
  50. }, 2000);
  51.  
  52. })(document.querySelector('.modal_outer'));