danigm / spotify-ad-blocker

GNOME shell extension to mute spotify ads
GNU General Public License v3.0
57 stars 8 forks source link

Bug: Extension only works the first time Spotify is opened #22

Closed bmaupin closed 1 year ago

bmaupin commented 1 year ago

I've noticed that if I close Spotify and reopen it, the extension no longer works.

To fix it, the extension tray icon needs to be clicked on to manually disable it, then again to manually re-enable it.

danigm commented 1 year ago

I think that this could be related to the player object disappearing. This code tries to reload the player https://github.com/danigm/spotify-ad-blocker/blob/master/extension.js#L180, but maybe it's not working correctly.

bmaupin commented 1 year ago

I think that points me in the right direction, thanks! I'll try to take a look at it when I get a chance (unless someone else beats me to it).

bmaupin commented 1 year ago

Before Spotify is opened for the first time, this.player is undefined.

After Spotify is opened, this.player look like this:

{
  "_mprisProxy": { "CanRaise": true, "DesktopEntry": "spotify" },
  "_playerProxy": {
    "CanGoNext": true,
    "CanGoPrevious": true,
    "CanPlay": true,
    "Metadata": {
      "mpris:trackid": {},
      "mpris:length": {},
      "mpris:artUrl": {},
      "xesam:album": {},
      "xesam:albumArtist": {},
      "xesam:artist": {},
      "xesam:autoRating": {},
      "xesam:discNumber": {},
      "xesam:title": {},
      "xesam:trackNumber": {},
      "xesam:url": {}
    },
    "PlaybackStatus": "Paused"
  },
  "_visible": true,
  "_trackArtists": ["..."],
  "_trackTitle": "...",
  "_trackCoverUrl": "https://i.scdn.co/image/...",
  "_busName": "org.mpris.MediaPlayer2.spotify",
  "_signalConnections": [
    { "id": 1, "name": "closed", "disconnected": false },
    { "id": 2, "name": "show", "disconnected": false },
    { "id": 3, "name": "hide", "disconnected": false },
    { "id": 4, "name": "changed", "disconnected": false },
    { "id": 5, "name": "closed", "disconnected": false },
    { "id": 6, "name": "changed", "disconnected": false }
  ],
  "_nextConnectionId": 7
}

After Spotify is closed, this.player looks like this:

{
  "_mprisProxy": null,
  "_playerProxy": null,
  "_visible": true,
  "_trackArtists": ["..."],
  "_trackTitle": "...",
  "_trackCoverUrl": "https://i.scdn.co/image/...",
  "_busName": "org.mpris.MediaPlayer2.spotify",
  "_signalConnections": [
    { "id": 1, "name": "closed", "disconnected": false },
    { "id": 2, "name": "show", "disconnected": false },
    { "id": 3, "name": "hide", "disconnected": false },
    { "id": 6, "name": "changed", "disconnected": false }
  ],
  "_nextConnectionId": 7
}