Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event appchange does not fire anymore #3047

Closed
2 tasks done
arboriusphoto opened this issue May 27, 2024 · 4 comments
Closed
2 tasks done

event appchange does not fire anymore #3047

arboriusphoto opened this issue May 27, 2024 · 4 comments
Labels
๐Ÿ› bug Something isn't working

Comments

@arboriusphoto
Copy link

๐Ÿ” Have you checked Spicetify.app page for your issue?

  • I have checked the FAQ

๐Ÿ” Is there already an issue for your problem?

  • I have checked older issues, open and closed

โ„น Environment / Computer Info

Spotify fรผr Windows (64ย Bit)
1.2.38.720.ga4a70a0e
Spicetify v2.36.10
Theme: marketplace
Extensions: personal-scrobbles.js, genres.js, section-marker.js, listPlaylistsWithSong.js, spotifyGenres.js
Custom apps: marketplace
xpui_2024-05-17_1715913620018_a4a70a0
cef_124.3.5+gff7dcd8+chromium-124.0.6367.119
Runtime: Chrome
Build System: CMake

๐Ÿ“ Description

I have my own js file "personal-scrobbles.js" which fetches data from last.fm and shows for example the play count in the playlist list next to each song.
It worked for over a year, when changing to a playlist that the event was fired. However, since December i guess it doesnt work anymore.
I noticed in the issues that you removed the appchange event because apparently noone was using it (#2696). Is there another way to execute a script when a new page in spotify opens?

๐Ÿ“ธ Screenshots

No response

@arboriusphoto arboriusphoto added the ๐Ÿ› bug Something isn't working label May 27, 2024
@rxri
Copy link
Member

rxri commented May 27, 2024

Spicetify.Platform.History

@rxri rxri closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2024
@arboriusphoto
Copy link
Author

Thanks for the quick response!

I managed to get it working:

let previousPathname = Spicetify.Platform.History.location.pathname;

const checkHistoryChange = () => {
  const currentPathname = Spicetify.Platform.History.location.pathname;
  if (currentPathname !== previousPathname) {
      previousPathname = currentPathname;
      
      //do what I need to do when a history change is detected
  }
};

// Check for history changes every 500 milliseconds
setInterval(checkHistoryChange, 500);

@rxri
Copy link
Member

rxri commented May 27, 2024

Thanks for the quick response!

I managed to get it working:

let previousPathname = Spicetify.Platform.History.location.pathname;

const checkHistoryChange = () => {
  const currentPathname = Spicetify.Platform.History.location.pathname;
  if (currentPathname !== previousPathname) {
      previousPathname = currentPathname;
      
      //do what I need to do when a history change is detected
  }
};

// Check for history changes every 500 milliseconds
setInterval(checkHistoryChange, 500);

or just use Spicetify.Platform.History.listen(({ pathname }) => { console.log(pathname) })). There's no need for setInterval here...

@arboriusphoto
Copy link
Author

Thanks! That is what I was looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
๐Ÿ› bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants