forked from beardedspice/BS-Strategies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlexWeb.bsstrategy
57 lines (57 loc) · 2.2 KB
/
PlexWeb.bsstrategy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// PlexWeb.plist
// BeardedSpice
//
// Created by Ryan Sullivan on 8/20/15.
// Copyright (c) 2015 GPL v3 http://www.gnu.org/licenses/gpl.html
//
BSStrategy = {
version:3,
displayName:"Plex Web",
accepts: {
method: "script",
script: function () {
return (window.PLEXWEB != undefined || document.querySelector('#plex') != null);
}
},
isPlaying: function() {
var theButton = document.querySelector('.player.music .pause-btn');
if (theButton)
return !(theButton.classList.contains('hidden'));
else
return (document.querySelector('.video-player.playing') != undefined);
},
// Use the visibility of the pause button to determine if something is playing
toggle: function () {
var thePlayer = document.querySelector('.player.music') ? '.player.music' : '.video-player';
var pauseButton = document.querySelector(thePlayer + ' .pause-btn');
var buttonIsHidden = pauseButton.classList.contains('hidden');
var toggleButton = document.querySelector('button' + (buttonIsHidden ? '.play' : '.pause') + '-btn');
toggleButton.click();
},
next: function () {
var thePlayer = document.querySelector('.player.music') ? '.player.music' : '.video-player';
document.querySelector(thePlayer+' .next-btn').click()
},
previous: function () {
var thePlayer = document.querySelector('.player.music') ? '.player.music' : '.video-player';
document.querySelector(thePlayer+' .previous-btn').click()
},
pause: function () {
var thePlayer = document.querySelector('.player.music') ? '.player.music' : '.video-player';
document.querySelector(thePlayer + ' .pause-btn').click()
},
trackInfo: function () {
if (document.querySelector('.player.music')) {
var mediaPoster = document.querySelector('.player.music .media-poster');
return {
'image': mediaPoster.getAttribute('data-image-url'),
'track': mediaPoster.getAttribute('data-title'),
'album': mediaPoster.getAttribute('data-image-title'),
'artist': document.querySelector('.player.music .grandparent-title').innerText,
'favorited': (document.querySelector('.player.music .rating-container .user-rating') != undefined)
}
}
return {}
}
}