-
Notifications
You must be signed in to change notification settings - Fork 6
/
Audible.bsstrategy
44 lines (44 loc) · 1.52 KB
/
Audible.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
//
// Audible.plist
// BeardedSpice
//
// Created by Max Borghino on 12/06/15.
// Copyright (c) 2015 Tyler Rhodes / Jose Falcon. All rights reserved.
//
// strategy/site notes
// - favorite: sets a bookmark
// - prev: implements skip back 30 seconds
// - next: not used (alternative: we could do prev/next chapter, but this is not very useful)
// - track info: book title and author not in the player, only artwork, chapter, time/time left
BSStrategy = {
version:1,
displayName:"Audible",
accepts: {
method: "predicateOnTab",
format:"%K LIKE[c] '*audible.com/cloud-player*'",
args: ["URL"]
},
isPlaying:function () {
var p=document.querySelector('.pause');
return (p && !p.classList.contains('hide'));
},
toggle: function () {document.querySelector('.play').click();},
next: function () {document.querySelector('.fav').click();},
favorite: function () {},
previous: function () {document.querySelector('.repeat').click()},
pause:function () {
var p=document.querySelector('.pause');
if(p && !p.classList.contains('hide')){ p.click();}
},
trackInfo: function () {
var art = document.querySelector('.item img');
var chapter = document.querySelector('.chapter');
var timeCur = document.querySelector('.cur');
var timeRem = document.querySelector('.rem');
return {
'image': art ? art.getAttribute('src') : null,
'track': chapter ? chapter.innerText : null,
'artist': (timeCur ? timeCur.innerText : null) + '/' + (timeRem ? timeRem.innerText : null),
};
}
}