Last active
August 7, 2019 03:26
-
-
Save nikhilatjumpcut/d273352f49921c7603ee244c3c6b10c0 to your computer and use it in GitHub Desktop.
replaceReleaseDatesAndWrapperLinks.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 getDate(timewaitValue) { | |
if (!timewaitValue || !spacetime) { | |
return 'soon'; | |
} | |
return spacetime(timewaitValue).format('{month-short} {date-ordinal}'); | |
} | |
function getDate(timewaitValue) { | |
if (!timewaitValue || !spacetime) { | |
return 'soon'; | |
} | |
return spacetime(timewaitValue).format('{month-short} {date-ordinal}'); | |
} | |
(function replaceReleaseDatesAndWrapperLinks() { | |
var URL_PREFIX = 'https://jumpcut.com/t'; | |
var funnelAccess = window.__TSUNAMI__.funnelAccess; | |
var funnelSlug = window.__TSUNAMI__.funnelSlug; | |
funnelAccess.forEach(access => { | |
var sourceUrl = access.page.sourceUrl; | |
const regex = new RegExp('^(https?://)?(www.)?'); | |
var finalSourceUrl = sourceUrl.replace(regex, ''); | |
var $imageLinkElement = $("[data-imagelink$='" + finalSourceUrl + "']"); | |
if (!$imageLinkElement) { | |
return; | |
} | |
// replace "Release Dates" | |
var $directParent = $imageLinkElement.parent(); | |
var $releasingDateElement = $directParent.find('.elHeadline b'); | |
// replace "Image Wrapper Links" | |
var hasAccess = access.hasAccess; | |
if (hasAccess) { | |
var stepURL = URL_PREFIX + '/' + funnelSlug + '/' + access.slug; | |
$imageLinkElement.attr('data-imagelink', stepURL); | |
$releasingDateElement.text('Released on ' + getDate(access.releaseTimestamp)); | |
return; | |
} | |
$imageLinkElement.attr('data-imagelink', ''); | |
$imageLinkElement.attr('style', 'filter: grayscale(100%);'); | |
$releasingDateElement.text('Releasing ' + getDate(access.releaseTimestamp)); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment