Skip to content

Instantly share code, notes, and snippets.

@edwinfinch
Created February 26, 2019 18:57
Show Gist options
  • Save edwinfinch/73e438c879c75739985fdc5cf515db3a to your computer and use it in GitHub Desktop.
Save edwinfinch/73e438c879c75739985fdc5cf515db3a to your computer and use it in GitHub Desktop.
//
// 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