1document.addEventListener('DOMContentLoaded', function() { 2 const targetNode = document.body; 3 const config = { childList: true, subtree: true }; 4 5 const callback = function(mutationsList, observer) { 6 for (let mutation of mutationsList) { 7 if (mutation.type === 'childList') { 8 const modalElement = document.querySelector('#pelcro-view-meter-modal'); 9 if (modalElement) { 10 const event = new CustomEvent('CallPelcroPaywallDisplayed'); 11 document.dispatchEvent(event); 12 13 observer.disconnect(); 14 break; 15 } 16 } 17 } 18 }; 19 20 const observer = new MutationObserver(callback); 21 observer.observe(targetNode, config); 22 23 function handlePelcroPaywallEvent() { 24 const paywallType = (() => { 25 if (document.querySelector('#pelcro-view-meter-modal')) { 26 return 'metered'; 27 } else if (document.querySelector('.pelcro-embedded-paywall')) { 28 return 'premium'; 29 } else { 30 return 'regwall'; 31 } 32 })(); 33 34 switch (paywallType) { 35 case 'metered': 36 pushPaywallEvent('paywall', 'soft', 'modal'); 37 break; 38 case 'premium': 39 pushPaywallEvent('paywall', 'block', 'stop'); 40 break; 41 case 'regwall': 42 pushPaywallEvent('paywall', 'regwall', 'modal'); 43 break; 44 default: 45 console.log('No matching paywall type found.'); 46 } 47 } 48 49 document.addEventListener('PelcroPaywallDisplayed', handlePelcroPaywallEvent); 50 document.addEventListener('CallPelcroPaywallDisplayed', handlePelcroPaywallEvent); 51 52 function pushPaywallEvent(type, category, action) { 53 (window._matherq = window._matherq || []).push([ 54 'paywallEvent', 55 { 56 type: type, 57 category: category, 58 action: action, 59 } 60 ]); 61 62 console.log(`${category} paywall event pushed:`, { 63 type: type, 64 category: category, 65 action: action 66 }); 67 } 68 69 document.addEventListener('PelcroUserRegister', function(event) { 70 (window._matherq = window._matherq || []).push(['paywallEvent', { 71 category: 'registration', 72 action: 'created' 73 }]); 74 75 console.log('Registration event pushed:', { 76 category: 'registration', 77 action: 'created' 78 }); 79 }); 80 81 document.addEventListener('PelcroSubscriptionCreate', function(event) { 82 (window._matherq = window._matherq || []).push(['paywallEvent', { 83 category: 'payment', 84 action: 'completed' 85 }]); 86 87 console.log('Payment event pushed:', { 88 category: 'payment', 89 action: 'completed' 90 }); 91 }); 92});
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.