';
jNode.append( removeItem );
});
// on click
// scrolling is needed because it wouldn't load more when all visible are removed
waitForKeyElements(".soundList__item .mdb-removeItem", function( jNode ) {
$(".mdb-removeItem").click(function(){
log( "click remove" );
// keep lazy loading active
$(".lazyInfo").remove();
$(".lazyLoadingList__list, .userStream__list .soundList").after('
Problems loading more players? Try scrolling up and down.
');
var y = $(window).scrollTop();
$("html, body").animate({scrollTop:y + 1}, 0);
$(this).closest('.soundList__item').remove();
var y = $(window).scrollTop();
$("html, body").delay(2).animate({scrollTop:y - 1}, 2);
if( $(".paging-eof").is(':visible') ) {
$('.lazyInfo').remove();
}
// remove
$(this).closest(".soundList__item").remove();
});
});
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Hide options
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// lazy loading lists (streams and feed)
waitForKeyElements(".stream__list .lazyLoadingList", lazyLoadingList);
waitForKeyElements(".userStream.lazyLoadingList", lazyLoadingList);
waitForKeyElements(".soundList.lazyLoadingList", lazyLoadingList);
waitForKeyElements(".trackList.lazyLoadingList", lazyLoadingList);
function lazyLoadingList(jNode) {
logFunc( "lazyLoadingList" );
// add checkboxes
if( $("#mdb-streamActions").length === 0 ) {
jNode.before('');
// vars
var sa = $("#mdb-streamActions"),
checkedPl = "checked",
checkedReposts = "",
checkedFav = "",
checkedUsed = "";
if( getHidePl == "false" ) checkedPl = '';
if( getHideReposts == "true" ) checkedReposts = 'checked';
if( getHideFav == "true" ) checkedFav = 'checked';
if( getHideUsed == "true" ) checkedUsed = 'checked';
// Display filter options per tab type
sa.append('Hide:');
if( !isSetPage ) {
sa.append('');
sa.append('');
sa.append('');
}
// Not on Playlists tab, e.g. https://soundcloud.com/resident-advisor/sets
// but allow on playlist page, e.g. https://soundcloud.com/resident-advisor/sets/ra-podcast
if( !isSetPage || isSetPage && typeof( urlPath(3) ) != "undefined" ) {
sa.append('');
} else {
sa.append( "Filter options on pages with multiple playlists create too much server load. Open the playlist/set page of interest individually." );
}
}
// reload
var windowLocation = window.location,
href = $(location).attr('href');
if( typeof href != "undefined" ) {
var url = href.replace(/\?.*$/g,"");
}
if( typeof url != "undefined" ) {
$("#hidePl").change(function(){
if(!this.checked) { windowLocation.href = url + "?hidePl=false&hideReposts="+getHideReposts+"&hideFav="+getHideFav+"&hideUsed="+getHideUsed;
} else { windowLocation.href = url + "?hidePl=true&hideReposts="+getHideReposts+"&hideFav="+getHideFav+"&hideUsed="+getHideUsed;
}});
$("#hideReposts").change(function(){
if(!this.checked) { windowLocation.href = url + "?hidePl="+getHidePl+"&hideReposts=false&hideFav="+getHideFav+"&hideUsed="+getHideUsed;
} else { windowLocation.href = url + "?hidePl="+getHidePl+"&hideReposts=true&hideFav="+getHideFav+"&hideUsed="+getHideUsed;
}});
$("#hideFav").change(function(){
if(!this.checked) { windowLocation.href = url + "?hidePl="+getHidePl+"&hideReposts="+getHideReposts+"&hideFav=false&hideUsed="+getHideUsed;
} else { windowLocation.href = url + "?hidePl="+getHidePl+"&hideReposts="+getHideReposts+"&hideFav=true&hideUsed="+getHideUsed;
}});
$("#hideUsed").change(function(){
if(!this.checked) { windowLocation.href = url + "?hidePl="+getHidePl+"&hideReposts="+getHideReposts+"&hideFav="+getHideFav+"&hideUsed=false";
} else { windowLocation.href = url + "?hidePl="+getHidePl+"&hideReposts="+getHideReposts+"&hideFav="+getHideFav+"&hideUsed=true";
}});
}
}
// Pass URL parameters for hiding options to user profile tabs
waitForKeyElements(".userInfoBar__tabs ul", function( jNode ) {
$("a.g-tabs-link", jNode).each(function(){
var link = $(this),
href = link.attr("href"),
hidingParams = location.search;
logVar( "hidingParams", hidingParams );
if( /.*hidePl.*/.test(hidingParams) ) {
var href_hidingParams = href + hidingParams;
link.attr( "href", href_hidingParams );
}
});
});
// Hiding option: each playlist
waitForKeyElements(".soundList__item .sound.playlist", function( jNode ) {
if( getHidePl == "true" ) {
log( "Hidden: " + jNode.closest(".soundTitle__title") );
jNode.closest(".soundList__item").remove();
}
});
// Hiding option: each repost player
waitForKeyElements(".soundList__item .sc-ministats-reposts", function( jNode ) {
if( getHidePl == "true" ) {
log( "Hidden: " + jNode.closest(".soundTitle__title") );
jNode.closest(".soundList__item").remove();
}
});
// Hiding option: each fFaved players > on waitForKeyElements fav button
// Hiding option: each used player in li.soundList__item
waitForKeyElements(".sc-link-primary.soundTitle__title", function( jNode ) {
if( getHideUsed == "true" ) {
logFunc( "Hiding used players in li.soundList__item" );
var wrapper = jNode.closest("li.soundList__item"),
playerUrl = "soundcloud.com" + jNode.attr("href");
logVar( "li.soundList__itemplayerUrl", playerUrl );
getToolkit( playerUrl, "hide if used", "lazy loading list", wrapper );
}
});
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Player page / features using SC API
* like soundAactions buttons and upload date
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* fixDefaultSoundActions
* Make more space by removing button text for most
*/
waitForKeyElements(".soundActions", function( jNode ) {
logFunc( "fixDefaultSoundActions" );
var buyLink = $(".soundActions__purchaseLink", jNode);
if( buyLink.length !== 0 ) {
var buyLink_href = fixScRedirectUrl( buyLink.attr("href") ),
buyLink_text = buyLink.text();
buyLink.remove();
jNode.append( '' );
}
});
/*
* Call API
*/
// run all this only once
var RUN_sc_button_group = true;
waitForKeyElements(".l-listen-wrapper .soundActions .sc-button-group", function( jNode ) {
if( RUN_sc_button_group ) {
RUN_sc_button_group = false;
if( urlPath(2) != "sets" ) {
logFunc( "Player page / sound action buttons" );
// API call
getScAccessTokenFromApi(function(output){
scAccessToken = output;
logVar( "scAccessToken", scAccessToken );
if( scAccessToken != "null" ) {
// Call API on current page
var currentTrack_id = $('meta[property="al:ios:url"]').attr("content").replace( "soundcloud://sounds:", "" ); // e.g. 2007615367
logVar( "currentTrack_id", currentTrack_id );
var scApiURl_currentTrack = "https://api.soundcloud.com/tracks/" + currentTrack_id; // Track ID would need to be grabbed (e.g. via sound action "report" URL
//var scApiURl_currentTrack = "https://api.soundcloud.com/resolve?url=" + encodeURIComponent( location.href );
logVar( "scApiURl_currentTrack", scApiURl_currentTrack );
$.ajax({
beforeSend: function(request) {
request.setRequestHeader( "Authorization", "OAuth " + scAccessToken );
},
dataType: "json",
url: scApiURl_currentTrack,
success: function( t ) {
var kind = t.kind,
id = t.id,
title = t.title,
created_at = formatScDate( t.created_at ),
release_date = formatScDate( t.release_date ),
last_modified = formatScDate( t.last_modified ),
dur_ms = t.duration,
downloadable = t.downloadable,
download_url = t.download_url;
logVar( "kind", kind );
logVar( "title", title );
logVar( "downloadable", downloadable );
if( kind == "track" ) {
// trackHeader
var soundActions = jNode,
trackHeader = $("#mdb-trackHeader");
if( $("h1", trackHeader).length === 0 ) {
var trackHeader_content = '