|
17 | 17 | * |
18 | 18 | * ENGRID PAGE TEMPLATE ASSETS |
19 | 19 | * |
20 | | - * Date: Thursday, November 13, 2025 @ 08:00:35 ET |
21 | | - * By: michael |
| 20 | + * Date: Monday, December 1, 2025 @ 16:32:12 ET |
| 21 | + * By: fernando |
22 | 22 | * ENGrid styles: v0.23.0 |
23 | 23 | * ENGrid scripts: v0.23.2 |
24 | 24 | * |
@@ -24254,39 +24254,73 @@ const AppVersion = "0.23.2"; |
24254 | 24254 |
|
24255 | 24255 | ;// CONCATENATED MODULE: ./src/scripts/main.js |
24256 | 24256 | const customScript = function (App, DonationFrequency) { |
24257 | | - console.log("ENGrid client scripts are executing"); // Listen to the message PayPal sends to the parent window when Venmo is enabled |
24258 | | - |
24259 | | - const VENMO_IDENTIFIER = "venmo"; // Print to the console ALL messages from iFrames |
24260 | | - |
24261 | | - window.addEventListener("message", function (event) { |
24262 | | - // Check the origin of the message |
24263 | | - if (event.origin === "https://www.paypal.com") { |
24264 | | - const data = JSON.parse(event.data); // Get the content from the first item of the data object |
24265 | | - |
24266 | | - const firstKey = Object.keys(data)[0]; |
24267 | | - const content = data[firstKey][0]; |
24268 | | - const hasData = ("data" in content); |
24269 | | - const hasName = hasData && "name" in content.data; |
24270 | | - const isRemember = hasName && content.data.name === "remember"; |
24271 | | - const hasArgs = isRemember && "args" in content.data; |
24272 | | - const isVenmo = hasArgs && Array.isArray(content.data.args) && content.data.args.length > 0 && Array.isArray(content.data.args[0]) && content.data.args[0].length > 0 && content.data.args[0][0] === VENMO_IDENTIFIER; |
24273 | | - |
24274 | | - if (isVenmo) { |
24275 | | - // Venmo is Enabled |
24276 | | - // If you are on iPhone, only enable Venmo if using Safari |
24277 | | - const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent); |
24278 | | - const isSafari = navigator.userAgent.includes("Safari") && !navigator.userAgent.includes("CriOS") && !navigator.userAgent.includes("FxiOS"); |
24279 | | - |
24280 | | - if (isIOS && !isSafari) { |
24281 | | - App.log("Venmo is not enabled on non-Safari iOS"); |
24282 | | - return; |
24283 | | - } |
| 24257 | + console.log("ENGrid client scripts are executing"); // Venmo Detection |
| 24258 | + |
| 24259 | + const paypalTouchContainer = document.getElementById("en__digitalWallet__paypalTouch__container"); |
| 24260 | + |
| 24261 | + if (paypalTouchContainer) { |
| 24262 | + App.log("Venmo Detection: Container found"); |
| 24263 | + let isChecking = false; |
| 24264 | + |
| 24265 | + const checkVenmo = function () { |
| 24266 | + let observer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; |
| 24267 | + if (isChecking) return; |
| 24268 | + isChecking = true; |
| 24269 | + App.log("Venmo Detection: Checking..."); // Temporarily make the container visible to check its height |
| 24270 | + |
| 24271 | + const originalDisplay = paypalTouchContainer.style.display; |
| 24272 | + const originalVisibility = paypalTouchContainer.style.visibility; |
| 24273 | + const originalPosition = paypalTouchContainer.style.position; |
| 24274 | + paypalTouchContainer.style.visibility = "hidden"; |
| 24275 | + paypalTouchContainer.style.position = "absolute"; |
| 24276 | + paypalTouchContainer.style.display = "block"; |
| 24277 | + setTimeout(() => { |
| 24278 | + const height = paypalTouchContainer.offsetHeight; |
| 24279 | + App.log(`Venmo Detection: Height is ${height}`); // Restore original styles |
| 24280 | + |
| 24281 | + paypalTouchContainer.style.display = originalDisplay; |
| 24282 | + paypalTouchContainer.style.visibility = originalVisibility; |
| 24283 | + paypalTouchContainer.style.position = originalPosition; |
| 24284 | + |
| 24285 | + if (height > 70) { |
| 24286 | + // Venmo is Enabled |
| 24287 | + // If you are on iPhone, only enable Venmo if using Safari |
| 24288 | + const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent); |
| 24289 | + const isSafari = navigator.userAgent.includes("Safari") && !navigator.userAgent.includes("CriOS") && !navigator.userAgent.includes("FxiOS"); |
| 24290 | + |
| 24291 | + if (isIOS && !isSafari) { |
| 24292 | + App.log("Venmo is not enabled on non-Safari iOS"); |
| 24293 | + } else { |
| 24294 | + App.setBodyData("venmo-enabled", "true"); |
| 24295 | + App.log("Venmo is enabled"); |
| 24296 | + } |
| 24297 | + } // Stop observing once checked |
| 24298 | + |
24284 | 24299 |
|
24285 | | - App.setBodyData("venmo-enabled", "true"); |
24286 | | - App.log("Venmo is enabled"); |
| 24300 | + if (observer) observer.disconnect(); |
| 24301 | + isChecking = false; |
| 24302 | + }, 500); |
| 24303 | + }; |
| 24304 | + |
| 24305 | + const venmoObserver = new MutationObserver(mutationsList => { |
| 24306 | + for (const mutation of mutationsList) { |
| 24307 | + if (mutation.type === "childList" && mutation.addedNodes.length > 0) { |
| 24308 | + App.log("Venmo Detection: Mutation detected"); |
| 24309 | + checkVenmo(venmoObserver); |
| 24310 | + } |
24287 | 24311 | } |
| 24312 | + }); |
| 24313 | + venmoObserver.observe(paypalTouchContainer, { |
| 24314 | + childList: true, |
| 24315 | + subtree: true |
| 24316 | + }); // Check immediately in case it's already loaded |
| 24317 | + |
| 24318 | + if (paypalTouchContainer.childNodes.length > 0) { |
| 24319 | + App.log("Venmo Detection: Immediate check triggered"); |
| 24320 | + checkVenmo(venmoObserver); |
24288 | 24321 | } |
24289 | | - }); // Add Images to the transaction.giveBySelect labels |
| 24322 | + } // Add Images to the transaction.giveBySelect labels |
| 24323 | + |
24290 | 24324 |
|
24291 | 24325 | const paymentMethods = document.querySelectorAll("[name='transaction.giveBySelect'] + label"); |
24292 | 24326 | paymentMethods.forEach(label => { |
|
0 commit comments