Skip to content

Instantly share code, notes, and snippets.

@nikhilatjumpcut
Last active August 8, 2019 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikhilatjumpcut/cb521f9f989ace38239a5483a46b1694 to your computer and use it in GitHub Desktop.
Save nikhilatjumpcut/cb521f9f989ace38239a5483a46b1694 to your computer and use it in GitHub Desktop.
replaceEnrollmentEnds.js
function getExpiryDate(timewaitValue) {
if (!timewaitValue || !spacetime) {
return 'soon';
}
return spacetime(timewaitValue)
.subtract(1, 'day')
.format('{month-short} {date-ordinal}');
}
(function replaceEnrollmentEndsAndDOMTimer() {
var funnelAccess = window.__TSUNAMI__.funnelAccess;
var currentStep = funnelAccess.find(function(access) {
if (access.isCurrentStep) {
return true;
}
return false;
});
var expiryTimestamp = currentStep.expiryTimestamp;
// replace "Enrollment Ends"
var $nodes = $(
"div.ne.elHeadline.hsSize3.lh4.elMargin0.elBGStyle0.hsTextShadow0:contains('{enrollment-end}')",
);
$nodes.text(
'(This special enrollment period ends ' + getExpiryDate(expiryTimestamp) + ' at 11:59pm PST.)',
);
// replace "DOM Timers"
var $timers = $('.elCountdown');
$timers.each(function() {
$rollingTimer = $('<iframe></iframe>');
$rollingTimer.attr('src', 'https://jumpcut.com/countdown?time=' + expiryTimestamp);
$rollingTimer.attr('style', 'display:block;margin: auto;border: 0 none;width: 100%;');
$(this).replaceWith($rollingTimer);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment