Skip to content

Instantly share code, notes, and snippets.

@beerriot
Last active March 25, 2022 15:55
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 beerriot/b5cd6a8284847d2f276f565e94ab81ed to your computer and use it in GitHub Desktop.
Save beerriot/b5cd6a8284847d2f276f565e94ab81ed to your computer and use it in GitHub Desktop.
UnderCurrents Radio Playlist Table

The bookmarklet below restyles the UnderCurrents Radio Playlist from a flat, one-line-per-field list, into a basic table.

To install the bookmarklet:

  1. Create a new bookmark (to this page is fine)
  2. Edit that bookmark
  3. Change its name to something like "UnderCurrents Radio Playlist Table"
  4. Change its linked address to this:
javascript:(function(){var s = document.createElement('style'); s.setAttribute('type', 'text/css'); s.innerText = 'div.entry-content div.sqs-block-content p:nth-child(n+2){display: inline-block} div.entry-content div.sqs-block-content p:nth-child(4n+2){width: 10%} div.entry-content div.sqs-block-content p:nth-child(4n+3){width: 20%}div.entry-content div.sqs-block-content p:nth-child(4n+4){width: 50%} div.entry-content div.sqs-block-content p:nth-child(4n+5){width: 20%}'; document.head.append(s);})();

To use: navigate to the UnderCurrents Radio Playlist, then click the bookmarklet in your bookmarks menu.

How it works:

The bookmarklet adds a small amount of extra CSS to the page header:

/* Allow elements to flow next to each other, instead of appearing on their own lines.
   'n+2' skips the show number header. */
div.entry-content div.sqs-block-content p:nth-child(n+2){
   display: inline-block
}
/* Give the show timestamp 10% of the page width */
div.entry-content div.sqs-block-content p:nth-child(4n+2){
   width: 10%
}
/* Give the artist name 20% of the page width */
div.entry-content div.sqs-block-content p:nth-child(4n+3){
   width: 20%
}
/* Give the track title 50% of the page width */
div.entry-content div.sqs-block-content p:nth-child(4n+4){
   width: 50%
}
/* Give the album title the remaining 20% of the page width.
   This forces the next timestamp onto the next line. */
div.entry-content div.sqs-block-content p:nth-child(4n+5){
   width: 20%
}

That's inserted into a new style element in the HTML head by this javascript:

var s = document.createElement('style');
s.setAttribute('type', 'text/css');
s.innerText = 'div.entry-content div.sqs-block-content p:nth-child(n+2){display: inline-block} div.entry-content div.sqs-block-content p:nth-child(4n+2){width: 10%} div.entry-content div.sqs-block-content p:nth-child(4n+3){width: 20%}div.entry-content div.sqs-block-content p:nth-child(4n+4){width: 50%} div.entry-content div.sqs-block-content p:nth-child(4n+5){width: 20%}';
document.head.append(s);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment