Skip to content

Instantly share code, notes, and snippets.

@mauscoelho
Created October 18, 2018 12:13
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 mauscoelho/f87430c9fd3dd7c7d8436b7211de16d3 to your computer and use it in GitHub Desktop.
Save mauscoelho/f87430c9fd3dd7c7d8436b7211de16d3 to your computer and use it in GitHub Desktop.
Listen Notes integration for BeardedSpice
//
// ListenNotes.plist
// BeardedSpice
//
// Created by Mauricio Coelho on 10/18/18
// Copyright (c) 2013 Tyler Rhodes / Jose Falcon. All rights reserved.
//
BSStrategy = {
version: 1,
displayName: "Listen Notes",
accepts: {
method: "predicateOnTab",
format: "%K LIKE[c] '*listennotes.com/*'",
args: ["URL"],
},
isPlaying: function() { return !document.querySelector('.media-player audio').paused; },
toggle: function() { document.querySelector('.ln-audioplayer-controls-container a:nth-child(2)').click(); },
previous: function() { document.querySelector('.ln-audioplayer-controls-container a:nth-child(1)').click(); },
next: function() { document.querySelector('.ln-audioplayer-controls-container a:nth-child(3)').click(); },
pause: function() {
if(!document.querySelector('.media-player audio').paused) {
document.querySelector('.ln-audioplayer-controls-container a:nth-child(2)').click()
}
},
trackInfo: function() {
timeInfo = document.querySelector('.ln-audioplayer-time-text-left').innerText;
thumb = document.querySelector('.ln-audioplayer-desktop-image');
title = document.querySelector('.ln-audioplayer-desktop-left-episode-title').innerText;
artist = document.querySelector('.ln-audioplayer-desktop-left-channel-title').innerText;
return {
'image': thumb.src,
'track': title,
'artist': artist,
'progress': `${timeInfo}`,
};
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment