1(() => { 2 "use strict"; 3 4 const BTN_CLASS = "awqaf-donate-btn"; 5 6 function injectIntoGrid(gridRoot) { 7 const cards = gridRoot.querySelectorAll(".give-campaigns-component-campaign"); 8 if (!cards.length) return; 9 10 cards.forEach((card) => { 11 if (card.querySelector("." + BTN_CLASS)) return; 12 13 // Ensure button can sit at bottom 14 card.style.display = "flex"; 15 card.style.flexDirection = "column"; 16 17 const btn = document.createElement("button"); 18 btn.type = "button"; 19 btn.className = BTN_CLASS; 20 btn.textContent = "Donate Now"; 21 22 // Discretionary -> /donate 23 const titleEl = card.querySelector(".give-campaigns-component-campaign-title"); 24 const title = titleEl ? titleEl.textContent.trim().toLowerCase() : ""; 25 const isDiscretionary = title.includes("discretionary"); 26 27 btn.addEventListener("click", (e) => { 28 e.preventDefault(); 29 e.stopPropagation(); 30 31 if (isDiscretionary) { 32 window.location.href = "/donate"; 33 return; 34 } 35 36 // card itself is clickable 37 card.click(); 38 }); 39 40 card.appendChild(btn); 41 }); 42 } 43 44 function injectAll() { 45 // wrapper exists in your HTML: [data-givewp-campaign-grid] 46 document.querySelectorAll("[data-givewp-campaign-grid]").forEach(injectIntoGrid); 47 } 48 49 // Run now + after short delays (covers async hydration) 50 function boot() { 51 injectAll(); 52 setTimeout(injectAll, 250); 53 setTimeout(injectAll, 1000); 54 setTimeout(injectAll, 2500); 55 } 56 57 // Observe DOM changes so we catch it whenever GiveWP renders 58 const observer = new MutationObserver(() => injectAll()); 59 observer.observe(document.body, { childList: true, subtree: true }); 60 61 document.addEventListener("DOMContentLoaded", boot); 62 window.addEventListener("load", boot); 63})();
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.