fix(hotkeys): Fixed bug with several hotkeys not working due to Tidal's HTML/css changes. fixes #250

This commit is contained in:
Rick van Lieshout 2023-07-23 23:13:37 +02:00
parent 41ca1d5a43
commit a39fef8d49
2 changed files with 14 additions and 8 deletions

View File

@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## 5.4.0 ## 5.4.0
- Added [Songwhip](https://songwhip.com/) integration - Added [Songwhip](https://songwhip.com/) integration
- Fixed bug with several hotkeys not working due to Tidal's HTML/css changes
- [DEV]: - [DEV]:
- added a logger to log into STDout - added a logger to log into STDout
- added "watchStart" which will automatically restart electron when it detects a source code change - added "watchStart" which will automatically restart electron when it detects a source code change

View File

@ -26,13 +26,12 @@ const elements = {
title: '*[data-test^="footer-track-title"]', title: '*[data-test^="footer-track-title"]',
artists: '*[data-test^="grid-item-detail-text-title-artist"]', artists: '*[data-test^="grid-item-detail-text-title-artist"]',
home: '*[data-test="menu--home"]', home: '*[data-test="menu--home"]',
back: '[class^="backwardButton"]', back: '[title^="Back"]',
forward: '[class^="forwardButton"]', forward: '[title^="Next"]',
search: '[class^="searchField"]', search: '[class^="searchField"]',
shuffle: '*[data-test="shuffle"]', shuffle: '*[data-test="shuffle"]',
repeat: '*[data-test="repeat"]', repeat: '*[data-test="repeat"]',
block: '[class="blockButton"]', account: '*[class^="profileOptions"]',
account: '*[data-test^="profile-image-button"]',
settings: '*[data-test^="open-settings"]', settings: '*[data-test^="open-settings"]',
media: '*[data-test="current-media-imagery"]', media: '*[data-test="current-media-imagery"]',
image: "img", image: "img",
@ -40,9 +39,10 @@ const elements = {
duration: '*[data-test="duration"]', duration: '*[data-test="duration"]',
bar: '*[data-test="progress-bar"]', bar: '*[data-test="progress-bar"]',
footer: "#footerPlayer", footer: "#footerPlayer",
mediaItem: "[data-type='mediaItem']",
album_header_title: '.header-details [data-test="title"]', album_header_title: '.header-details [data-test="title"]',
playing_title: 'span[data-test="table-cell-title"].css-1vjc1xk', currentlyPlaying: "[class^='isPlayingIcon'], [data-test-is-playing='true']",
album_name_cell: '[data-test="table-cell-album"]', album_name_cell: '[class^="album"]',
tracklist_row: '[data-test="tracklist-row"]', tracklist_row: '[data-test="tracklist-row"]',
volume: '*[data-test="volume"]', volume: '*[data-test="volume"]',
/** /**
@ -106,7 +106,9 @@ const elements = {
window.location.href.includes("/mix/") window.location.href.includes("/mix/")
) { ) {
if (currentPlayStatus === statuses.playing) { if (currentPlayStatus === statuses.playing) {
const row = window.document.querySelector(this.playing_title).closest(this.tracklist_row); // find the currently playing element from the list (which might be in an album icon), traverse back up to the mediaItem (row) and select the album cell.
// document.querySelector("[class^='isPlayingIcon'], [data-test-is-playing='true']").closest('[data-type="mediaItem"]').querySelector('[class^="album"]').textContent
const row = window.document.querySelector(this.currentlyPlaying).closest(this.mediaItem);
if (row) { if (row) {
return row.querySelector(this.album_name_cell).textContent; return row.querySelector(this.album_name_cell).textContent;
} }
@ -207,7 +209,10 @@ function playPause() {
function addHotKeys() { function addHotKeys() {
if (settingsStore.get(settings.enableCustomHotkeys)) { if (settingsStore.get(settings.enableCustomHotkeys)) {
addHotkey("Control+p", function () { addHotkey("Control+p", function () {
elements.click("account").click("settings"); elements.click("account");
setTimeout(() => {
elements.click("settings");
}, 100);
}); });
addHotkey("Control+l", function () { addHotkey("Control+l", function () {
handleLogout(); handleLogout();