Last active
August 7, 2019 03:25
-
-
Save nikhilatjumpcut/862813dfc644e28714bebb4c19f12770 to your computer and use it in GitHub Desktop.
replaceCTAAction.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function replaceCTAAction() { | |
var FUNNEL_URL = 'https://jumpcut.com/t'; | |
var funnelAccess = window.__TSUNAMI__.funnelAccess; | |
var funnelSlug = window.__TSUNAMI__.funnelSlug; | |
var currentStepIndex = funnelAccess.findIndex(function(access) { | |
if (access.isCurrentStep) { | |
return true; | |
} | |
return false; | |
}); | |
var closestSalesStep = funnelAccess.find(function(access, index) { | |
if (access.page.type === 'SALES' && index > currentStepIndex) { | |
return true; | |
} | |
return false; | |
}); | |
var $ctaLinkButtons = $('a[href*="enroll"]'); | |
if (!closestSalesStep) { | |
$ctaLinkButtons.attr('href', '#'); | |
return; | |
} | |
var url = FUNNEL_URL + '/' + funnelSlug + '/' + closestSalesStep.slug; | |
$ctaLinkButtons.attr('href', url); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment