From c29d6071b9475f503d440cb682ead587354f3a8e Mon Sep 17 00:00:00 2001 From: Rasmus Thomsen Date: Fri, 20 Oct 2017 12:43:53 +0200 Subject: [PATCH 1/2] Add favorites support to soundcloud plugin --- AUTHORS.md | 1 + plugins/soundcloud/integration.js | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index b1a4f753..adace4f2 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -12,3 +12,4 @@ Contributors - [Lukas Kolletzki](https://github.com/kolletzki) - [Mahmoud Hossam](https://github.com/mahmoudhossam) - [Terin Stock](https://github.com/terinjokes) +- [Rasmus Thomsen](https://github.com/Cogitri) diff --git a/plugins/soundcloud/integration.js b/plugins/soundcloud/integration.js index 45b2d6fe..8e0bce5f 100644 --- a/plugins/soundcloud/integration.js +++ b/plugins/soundcloud/integration.js @@ -42,7 +42,7 @@ function update() { "canSeek": false, "canGoNext": true, "canGoPrevious": true, - "canAddToFavorites": false, + "canAddToFavorites": true, "volume": 1, "duration": readTime('playbackTimeline__duration'), "position": readTime('playbackTimeline__timePassed'), @@ -98,11 +98,11 @@ function goPrevious() { clickButton('skipControl__previous'); } -function setVolume(volume) { - // not supported +function addToFavorites() { + clickButton('playbackSoundBadge__like'); } -function addToFavorites() { +function setVolume(volume) { // not supported } @@ -112,4 +112,4 @@ function removeFromFavorites() { function seekToPosition(position) { // not supported -} \ No newline at end of file +} From 3addf187b0edf4511ed131274b11a25d606f25fc Mon Sep 17 00:00:00 2001 From: Rasmus Thomsen Date: Fri, 20 Oct 2017 20:10:28 +0200 Subject: [PATCH 2/2] 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 }