Randall's - Add Links Inside Cart

fixes lack of href tag on <a /> tag for products in cart

  1. // ==UserScript==
  2. // @name Randall's - Add Links Inside Cart
  3. // @namespace https://openuserjs.org/users/zachhardesty7
  4. // @author Zach Hardesty <zachhardesty7@users.noreply.github.com> (https://github.com/zachhardesty7)
  5. // @description fixes lack of href tag on <a /> tag for products in cart
  6. // @copyright 2019, Zach Hardesty (https://zachhardesty.com/)
  7. // @license GPL-3.0-only; http://www.gnu.org/licenses/gpl-3.0.txt
  8. // @version 1.1.3
  9.  
  10. // @homepageURL https://github.com/zachhardesty7/tamper-monkey-scripts-collection/raw/master/randalls-add-links-inside-cart.user.js
  11. // @homepageURL https://openuserjs.org/scripts/zachhardesty7/Randalls_-_Add_Links_Inside_Cart
  12. // @supportURL https://github.com/zachhardesty7/tamper-monkey-scripts-collection/issues
  13.  
  14.  
  15. // @include https://shop.randalls.com/ecom/modern1/my-cart*
  16. // @require https://greasyfork.org/scripts/419640-onelementready/code/onElementReady.js?version=887637
  17. // ==/UserScript==
  18. /* global onElementReady */
  19.  
  20. // IT'S SUCH BAD UX TO NOT INCLUDE AN
  21. // HREF ON ALL <a /> TAGS
  22.  
  23. onElementReady(".cartdesc", { findOnce: false }, (el) => {
  24. const link = el.querySelector("a")
  25. link.href = `http://shop.randalls.com${link.onclick
  26. .toString()
  27. .match(/\/product-details\.\d+\.html/gm)}`
  28. })