1document.addEventListener("DOMContentLoaded", () => { 2 console.log("ro179 loaded"); 3 4 document.querySelector("body").classList.add("RO179"); 5 function waitForElement(selector, callback) { 6 //immediate check 7 const element = document.querySelector(selector); 8 if (element) { 9 callback(element); 10 return; 11 } 12 //observe DOM mutations 13 const observer = new MutationObserver(() => { 14 const el = document.querySelector(selector); 15 if (el) { 16 observer.disconnect(); 17 callback(el); 18 } 19 }); 20 21 observer.observe(document.body, { 22 childList: true, 23 subtree: true, 24 }); 25 } 26 27 waitForElement(".woocommerce-success-wrapper .custom-message-text", (element) => { 28 console.log("wrapper found.."); 29 document.body.classList.add("RO179"); 30 init(); 31 }); 32 33 function init() { 34 //replace the text to be BOLD and add icon. 35 const el = document.querySelector('.custom-message-text'); 36 const text = el.innerHTML; 37 38 const splitPattern = /(.*?)\s*has been added to your cart\./i; 39 40 const match = text.match(splitPattern); 41 42 if (match) { 43 const productName = match[1].trim(); 44 const rest = text.replace(splitPattern, ''); 45 el.innerHTML = 46 `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none"> 47 <path d="M18 10C18 14.4184 14.4184 18 10 18C5.58176 18 2 14.4184 2 10C2 5.58177 5.58176 2.00002 10 2.00002C14.4184 2.00002 18 5.58177 18 10Z" fill="#008001"/> 48 <path d="M13.2 6.00002L8.40001 10.8L6.40001 8.80001L4.70001 10.48L6.70001 12.48L8.30001 14.08L8.40001 14.16L14.9 7.67999L13.2 6.00002Z" fill="white"/> 49 </svg><div><strong>${productName}</strong> has been added to your cart.</div>` + 50 (rest ? `<div class="sp-full">${rest.trim()}</div>` : ''); 51 } 52 const messages = document.querySelectorAll(".woocommerce-message"); 53 54 messages.forEach(msg => { 55 if (msg.querySelector(".custom-message-inner")) return; 56 57 // CASE 1: <div class="woocommerce-message">Textâ¦</div> 58 if (msg.tagName.toLowerCase() === "div") { 59 msg.innerHTML = `<div class="sp-inner"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none"> 60 <path d="M18 10C18 14.4184 14.4184 18 10 18C5.58176 18 2 14.4184 2 10C2 5.58177 5.58176 2.00002 10 2.00002C14.4184 2.00002 18 5.58177 18 10Z" fill="#008001"/> 61 <path d="M13.2 6.00002L8.40001 10.8L6.40001 8.80001L4.70001 10.48L6.70001 12.48L8.30001 14.08L8.40001 14.16L14.9 7.67999L13.2 6.00002Z" fill="white"/> 62 </svg><div>${msg.innerHTML}</div></div>`; 63 return; 64 } 65 66 // CASE 2: <ul class="woocommerce-message"><li>Textâ¦</li></ul> 67 if (msg.tagName.toLowerCase() === "ul") { 68 const li = msg.querySelector("li"); 69 if (li) { 70 li.innerHTML = `<div class="sp-inner"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none"> 71 <path d="M18 10C18 14.4184 14.4184 18 10 18C5.58176 18 2 14.4184 2 10C2 5.58177 5.58176 2.00002 10 2.00002C14.4184 2.00002 18 5.58177 18 10Z" fill="#008001"/> 72 <path d="M13.2 6.00002L8.40001 10.8L6.40001 8.80001L4.70001 10.48L6.70001 12.48L8.30001 14.08L8.40001 14.16L14.9 7.67999L13.2 6.00002Z" fill="white"/> 73 </svg><div>${li.innerHTML}</div></div>`; 74 } 75 } 76 }); 77 } 78 79 waitForElement(".checkout-button.button.alt.wc-forward.cart-checkout-added-button", () => { 80 console.log("added button found.."); 81 btns(); 82 }); 83 84 function btns() { 85 let checkOutBtn = document.querySelector(".checkout-button.button.alt.wc-forward.cart-checkout-added-button"); 86 console.log("ro179 btns"); 87 console.log(checkOutBtn); 88 let newWrap = document.createElement("div"); 89 newWrap.classList.add("btn-wrap"); 90 newWrap.append(checkOutBtn); 91 92 let sib = document.querySelector(".xxlarge-9.xlarge-10.large-12.large-centered.columns > div.row"); 93 sib.parentNode.insertBefore(newWrap, sib); 94 95 let shopBtn = document.createElement("a"); 96 shopBtn.href= "/shop/"; 97 shopBtn.textContent= "Continue Shopping"; 98 shopBtn.classList.add("sp-btn", "checkout-button", "button", "alt", "wc-forward", "cart-checkout-added-button"); 99 document.querySelector(".btn-wrap").prepend(shopBtn); 100 } 101 102 waitForElement(".woocommerce-message.messsages-1 li", (element) => { 103 element.innerHTML = `<div class="sp-inner"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none"> 104 <path d="M18 10C18 14.4184 14.4184 18 10 18C5.58176 18 2 14.4184 2 10C2 5.58177 5.58176 2.00002 10 2.00002C14.4184 2.00002 18 5.58177 18 10Z" fill="#008001"/> 105 <path d="M13.2 6.00002L8.40001 10.8L6.40001 8.80001L4.70001 10.48L6.70001 12.48L8.30001 14.08L8.40001 14.16L14.9 7.67999L13.2 6.00002Z" fill="white"/> 106 </svg><div>${element.innerHTML}</div></div>`; 107 document.body.classList.add("RO179"); 108 }); 109 });
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.