From 3addf187b0edf4511ed131274b11a25d606f25fc Mon Sep 17 00:00:00 2001 From: Rasmus Thomsen Date: Fri, 20 Oct 2017 20:10:28 +0200 Subject: [PATCH] Add support for un-favoriting to soundcloud plugin --- plugins/soundcloud/integration.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/plugins/soundcloud/integration.js b/plugins/soundcloud/integration.js index 8e0bce5f..b6be3b6a 100644 --- a/plugins/soundcloud/integration.js +++ b/plugins/soundcloud/integration.js @@ -51,7 +51,7 @@ function update() { "artistName": '', "albumTitle": '', "artUrl": artUrl, - "isFavorite": false + "isFavorite": isFavorite() } } @@ -78,6 +78,13 @@ function readTime(elementClassName) { return hours * 3600 + minutes * 60 + seconds; } +function isFavorite() { + if (document.getElementsByClassName('playbackSoundBadge__like')[0].title === "Unlike") + return true; + else + return false; +} + function clickButton(buttonName) { document.getElementsByClassName(buttonName)[0].click() } @@ -102,11 +109,11 @@ function addToFavorites() { clickButton('playbackSoundBadge__like'); } -function setVolume(volume) { - // not supported +function removeFromFavorites() { + addToFavorites(); } -function removeFromFavorites() { +function setVolume(volume) { // not supported }