Skip to content

Instantly share code, notes, and snippets.

@bennettmcelwee
Last active January 23, 2018 02:41
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 bennettmcelwee/a9952ca3c698b570d17d8a55b294d7b2 to your computer and use it in GitHub Desktop.
Save bennettmcelwee/a9952ca3c698b570d17d8a55b294d7b2 to your computer and use it in GitHub Desktop.
Snippet to inject into Freegal pages to make them more readable
// Change New Releases page to a complete text listing with hover images
if (window.location.pathname === '/homes/new_releases') {
$('<style>\
.videos-shadow-container { display: none; }\
.my-top-100-page { height: auto; }\
.album-shadow-container > .album-scrollable { display: none; }\
.album-shadow-container > button { display: none; }\
.album-shadow-container + h3 { display: none; }\
.hnr-at { border-spacing: 3px; border-collapse: separate; margin-left: -3px; font-family: "Helvetica Neue", sans-serif; }\
.hnr-at .album-link img {position: absolute; }\
.hnr-at .album-link:not(:hover) img { display: none; }\
.hnr-da .artist { color: #ccc; }\
</style>').appendTo('head');
$('.album-shadow-container').prepend(
$('<table class="hnr-at"></table>').prepend(
$('.album-scrollable li').has('.album-title')
.map((i, e) => ({
artist:$(e).find('.artist-name a').attr('title').trim().replace(/^The /, ''),
artist_short:$(e).find('.artist-name a').text().trim(),
album:$(e).find('.album-title a').attr('title').trim(),
link:$(e).find('.album-title a').attr('href'),image:$(e).find('.album-container a img').attr('src'),
image:$(e).find('.album-container > a img')[0]
}))
.toArray()
.sort((a,b) => a.artist.localeCompare(b.artist))
.map(o => {
const row = $('<tr><td class="artist"><span title="' + o.artist + '">' + o.artist_short + '</span></td></tr>');
const album = $('<a class="album-link" href="' + o.link + '">' + o.album + '</a>').append(o.image);
return row.append($('<td></td>').append(album));
})
)
);
$('.hnr-at tr').filter((i, e) => {
const $e = $(e);
return ($e.find('.artist span').attr('title') === $e.prev().find('.artist span').attr('title'));
}).addClass('hnr-da');
}
// Change artists page to show all albums in a wraparound list
if (/\/artists\/album\/.+/.test(window.location.pathname)) {
$('<style>\
#content .album-shadow-container { height: auto; }\
#content .album-shadow-container .left-scroll-button-ajax { display: none; }\
#content .album-shadow-container .right-scroll-button-ajax { display: none; }\
#content .album-scrollable { height: auto; margin-left: 0; margin-right: 0; }\
#content .album-scrollable > ul { height: auto; width: auto !important; }\
#content .album-scrollable > ul > li { display: inline-block; float: none; vertical-align: top; }\
</style>').appendTo('head');
}
// Set page title
if (1 === jQuery('.album-detail-container').length) {
const artist = jQuery('.album-detail-container .artist-name').text().trim()
const title = jQuery('.album-detail-container .album-title').text().trim()
if (artist && title) {
document.title = `${artist} - ${title}`
}
}
else if (1 === jQuery('.artist-page h2').length) {
const artist = jQuery('.artist-page h2').text().trim()
if (artist) {
document.title = artist
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment