Skip to content

Instantly share code, notes, and snippets.

@edwinfinch
Created February 26, 2019 18:41
Show Gist options
  • Save edwinfinch/813ea2fcce98284580f574e0dded5629 to your computer and use it in GitHub Desktop.
Save edwinfinch/813ea2fcce98284580f574e0dded5629 to your computer and use it in GitHub Desktop.
//
// LingQMediaStrategy.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",
accepts: {
method: "predicateOnTab",
format: "%K LIKE[c] '*lingq.com/*/learn/*/web/lesson/*'",
args: [
"URL"
]
},
isPlaying: function(){
return document.querySelector(".lingq-audio-player").classList.contains("playing");
},
toggle: function () {
var isPlaying = document.querySelector(".lingq-audio-player").classList.contains("playing");
document.querySelector(isPlaying ? ".pause-button" : ".play-button").click();
},
previous: function () {
document.querySelector(".rewind-button").click();
},
next: function () {
document.querySelector(".rate-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(".lesson-title").innerText,
"album": document.querySelector(".course-title").innerText,
"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