1jQuery( document ).ready(function() { 2 3 const automatoOptinMonsterCookie = 'ua_show_campaign'; 4 const linkId = 'automator-manual-optin-trigger'; 5 6 // Create a hidden campaign link 7 let link = createLink( linkId ); 8 9 // Wait for the cookie from PHP 10 const automatorTimeout = setInterval( checkCookie, 250 ); 11 12 function createLink( id ) { 13 14 var a = document.createElement('a'); 15 16 a.id = id; 17 a.target = '_blank'; 18 a.style.display = 'none'; 19 20 // Set the href property. 21 a.href = "https://app.monstercampaigns.com/c/"; 22 23 // Append the anchor element to the body. 24 return document.body.appendChild(a); 25 26 } 27 28 function checkCookie() { 29 30 // Only check cookie on an active tab 31 if ( document.hidden ) { 32 return; 33 } 34 35 let campaign = getCookie( automatoOptinMonsterCookie ); 36 37 if ( campaign ) { 38 39 console.log( 'Automator will now show the OptinMonster campaign ' + campaign ); 40 41 // Delete the cookie 42 deleteCookie( automatoOptinMonsterCookie ); 43 44 // Set the hidden link url to the campaign-specific url 45 link.href = "https://app.monstercampaigns.com/c/" + campaign; 46 47 // Click the link 48 link.click(); 49 } 50 51 } 52 53 function getCookie( cname ) { 54 let name = cname + "="; 55 let decodedCookie = decodeURIComponent( document.cookie ); 56 let ca = decodedCookie.split( ';' ); 57 for( let i = 0; i < ca.length; i++ ) { 58 let c = ca[i]; 59 while ( c.charAt( 0 ) == ' ' ) { 60 c = c.substring( 1 ); 61 } 62 if ( c.indexOf( name ) == 0 ) { 63 return c.substring( name.length, c.length ); 64 } 65 } 66 return false; 67 } 68 69 function deleteCookie( cname ) { 70 document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; 71 } 72 73}); 74 75
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.