added functionality to favorite a song. fixes #323

This commit is contained in:
2024-01-07 14:58:49 +01:00
parent 1d19857977
commit 5e82c18d8a
7 changed files with 25 additions and 0 deletions

View File

@@ -54,6 +54,7 @@ const elements = {
album_name_cell: '[class^="album"]',
tracklist_row: '[data-test="tracklist-row"]',
volume: '*[data-test="volume"]',
favorite: '*[data-test="footer-favorite-button"]',
/**
* Get an element from the dom
* @param {*} key key in elements object to fetch
@@ -131,6 +132,10 @@ const elements = {
return this.get("volume").getAttribute("aria-checked") === "false"; // it's muted if aria-checked is false
},
isFavorite: function () {
return this.get("favorite").getAttribute("aria-checked") === "true";
},
/**
* Shorthand function to get the text of a dom element
* @param {*} key key in elements object to fetch
@@ -208,6 +213,10 @@ function addHotKeys() {
handleLogout();
});
addHotkey("Control+a", function () {
elements.click("favorite");
});
addHotkey("Control+h", function () {
elements.click("home");
});
@@ -306,6 +315,9 @@ function addIPCEventListeners() {
case globalEvents.pause:
elements.click("pause");
break;
case globalEvents.toggleFavorite:
elements.click("favorite");
break;
default:
break;
}
@@ -516,6 +528,7 @@ setInterval(function () {
"app-name": appName,
image: "",
icon: "",
favorite: elements.isFavorite(),
};
const titleOrArtistsChanged = currentSong !== songDashArtistTitle;