Created
February 26, 2019 18:57
-
-
Save edwinfinch/73e438c879c75739985fdc5cf515db3a 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
// | |
// LingQPlaylistMediaStrategy.js | |
// Edwin Finch | |
// | |
// Created by Edwin on Feb 26th, 2019. | |
// Copyright (c) 2015-2019 GPL v3 http://www.gnu.org/licences/gpl.html | |
// | |
BSStrategy = { | |
version: 1, | |
displayName: "LingQ Playlist", | |
accepts: { | |
method: "predicateOnTab", | |
format: "%K LIKE[c] '*lingq.com/*/learn/*/web/playlist'", | |
args: [ | |
"URL" | |
] | |
}, | |
isPlaying: function(){ | |
return document.querySelector(".playlist").classList.contains("playing"); | |
}, | |
toggle: function () { | |
var isPlaying = document.querySelector(".playlist").classList.contains("playing"); | |
document.querySelector(isPlaying ? ".pause-button" : ".play-button").click(); | |
}, | |
previous: function () { | |
document.querySelector(".rewind-button").click(); | |
}, | |
next: function () { | |
document.querySelector(".forward-button").click() | |
}, | |
pause: function () { | |
document.querySelector(".pause-button").click(); | |
}, | |
favorite: function () { }, //It should be spelt 'favourite', but I guess I will have to let that go. | |
trackInfo: function () { | |
return { | |
"track": document.querySelector(".item-title").innerText, | |
"album": "Playlist", | |
"artist": "LingQ", | |
"image": "https://scontent.fyyz1-1.fna.fbcdn.net/v/t1.0-9/12871469_10153672710498786_4059947752259266619_n.png", | |
"favorited": false | |
}; | |
} | |
} | |
// The file must have an empty line at the end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment