Created
February 26, 2019 18:41
-
-
Save edwinfinch/813ea2fcce98284580f574e0dded5629 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
// | |
// 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