Created
September 14, 2017 21:11
-
-
Save panphora/708bf49c43c72b28f555a2149436b9e2 to your computer and use it in GitHub Desktop.
Modifying overcast.fm to make it more like the app
This file contains hidden or 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
var $activeEpisodes = $(".episodecell"); | |
var episodesReversedElements = $activeEpisodes.toArray().reverse(); | |
var lastPodcastName; | |
episodesReversedElements.forEach(function (elem) { | |
var $activeEpisode = $(elem); | |
var podcastName = $activeEpisode.find(".titlestack div:first-child").text(); | |
var podcastImgSrc = $activeEpisode.find(".art").attr("src"); | |
if (podcastName !== lastPodcastName) { | |
makeActivePodcastCell(podcastName, podcastImgSrc); | |
} | |
lastPodcastName = podcastName; | |
}); | |
function makeActivePodcastCell (podcastName, imgSrc) { | |
var $episodeCell = $activeEpisodes.first(); | |
var $cell = $episodeCell.clone(); | |
$cell.find(".art").attr("src", imgSrc); | |
$cell.find(".caption2.singleline").text(""); | |
$cell.find(".title.singleline").text(podcastName); | |
$cell.insertAfter(".ocseparatorbar:first"); | |
$cell.on("click", function (event) { | |
event.preventDefault(); | |
replaceWithEpisodes($cell, podcastName); | |
}); | |
} | |
function replaceWithEpisodes ($elem, podcastName) { | |
var episodesWithPodcastName = episodesReversedElements.filter(function (elem) { | |
return $(elem).find(".titlestack div:first-child").text() === podcastName; | |
}); | |
$elem.replaceWith($(episodesWithPodcastName).show()); | |
} | |
$activeEpisodes.hide(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment