Skip to content
This repository has been archived by the owner on May 3, 2019. It is now read-only.

Add favorites support to soundcloud plugin #134

Merged
merged 2 commits into from
Oct 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
23 changes: 15 additions & 8 deletions plugins/soundcloud/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -51,7 +51,7 @@ function update() {
"artistName": '',
"albumTitle": '',
"artUrl": artUrl,
"isFavorite": false
"isFavorite": isFavorite()
}
}

Expand All @@ -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()
}
Expand All @@ -98,18 +105,18 @@ function goPrevious() {
clickButton('skipControl__previous');
}

function setVolume(volume) {
// not supported
}

function addToFavorites() {
// not supported
clickButton('playbackSoundBadge__like');
}

function removeFromFavorites() {
addToFavorites();
}

function setVolume(volume) {
// not supported
}

function seekToPosition(position) {
// not supported
}
}