Created
June 22, 2018 18:06
-
-
Save ainth/2ac4375a31672ba520e68d11084359a6 to your computer and use it in GitHub Desktop.
This file contains 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
// | |
// YouTubeMusic.plist | |
// BeardedSpice | |
// | |
// Created by Jose Falcon on 12/15/13. | |
// Updated by Alin Panaitiu on 3/2/18. | |
// Copyright (c) 2013 Tyler Rhodes / Jose Falcon. All rights reserved. | |
// | |
BSStrategy = { | |
version:2, | |
displayName: 'YouTube Music', | |
accepts: { | |
method: 'predicateOnTab', | |
format: "%K LIKE[c] '*music.youtube.com/*'", | |
args: ['URL'], | |
}, | |
isPlaying: function() { | |
return document.querySelector('.ytmusic-player-bar.play-pause-button').title === 'Pause'; | |
}, | |
toggle: function() { | |
document.querySelector('.ytmusic-player-bar.play-pause-button').click(); | |
}, | |
previous: function() { | |
document.querySelector('.ytmusic-player-bar.previous-button').click(); | |
}, | |
next: function() { | |
document.querySelector('.ytmusic-player-bar.next-button').click(); | |
}, | |
pause: function() { | |
if (document.querySelector('.ytmusic-player-bar.play-pause-button').title === 'Pause') { | |
document.querySelector('.ytmusic-player-bar.play-pause-button').click(); | |
} | |
}, | |
favorite: function() { | |
document.querySelector('.ytmusic-like-button-renderer[title="Like"]').click(); | |
}, | |
trackInfo: function() { | |
timeInfo = document.querySelector('.ytmusic-player-bar.time-info').innerHTML.split('/'); | |
thumb = document.querySelector('.ytmusic-player-bar img'); | |
title = document.querySelector('.ytmusic-player-bar.title'); | |
byline = document.querySelector('.byline.ytmusic-player-bar'); | |
like = document.querySelector('.ytmusic-like-button-renderer'); | |
return { | |
image: thumb.src, | |
track: title.text.runs[0].text, | |
artist: byline.children[0].text, | |
progress: `${timeInfo[0].trim()} of ${timeInfo[1].trim()}`, | |
favorited: like.getAttribute('aria-pressed') === 'true', | |
}; | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment