Last active
July 29, 2020 02:40
-
-
Save bosconian-dynamics/a04040e1d38b4ccd0ed1ccb0cbbb6b9c to your computer and use it in GitHub Desktop.
Sort the Battlefield Friends playlist on Internet Archive
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
/** | |
* Golfed version of bff-ia-sort.js. | |
* Same functionality formatted as a shortened one-liner for execution in a browser's address bar. | |
* Can be saved and executed as a bookmarklet - save the following as a bookmark's URL, and click | |
* the bookmark when viewing https://archive.org/details/Battlefield_Friends/ | |
**/ | |
javascript:{((j,p,x,y,z,s=j.getPlaylist().map(i=>i.title.includes('Take The Objective')?{...i,s:3,e:6}:([x,y,z]=i.title.match(/(\d)\s*Ep?\s*(\d+)/),{...i,s:p(y),e:p(z)})).sort((a,b)=>a.s>b.s?1:a.s<b.s?-1:a.e>b.e?1:a.e<b.e?-1:0))=>($('#jw6__list a').each((i,e)=>$(e).find('.ttl').text(s[i].title)),j.load(s)))(jwplayer(),parseInt)} |
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
/** | |
* Sorts the Battlefield Friends playlist at https://archive.org/details/Battlefield_Friends/ | |
* Execute the following in your browser's JavaScript console | |
**/ | |
const sorted_playlist = jwplayer().getPlaylist() | |
.map( i => { | |
if( i.title === 'BFFs Battlefield Friends - Take The Objective' ) | |
return {...i, season: 3, episode: 6}; | |
const [ match, season, episode ] = i.title.match( /(\d)\s*Ep?\s*(\d+)/ ); | |
return {...i, season: parseInt( season ), episode: parseInt( episode ) }; | |
} ) | |
.sort( (a, b) => { | |
if( a.season > b.season ) | |
return 1; | |
if( b.season > a.season ) | |
return -1; | |
if( a.episode > b.episode ) | |
return 1; | |
if( b.episode > a.episode ) | |
return -1; | |
return 0; | |
} ); | |
$('#jw6__list a').each( (i, el) => { $(el).find( '.ttl' ).text( sorted_playlist[i].title ); } ); | |
jwplayer().load( sorted_playlist ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment