Skip to content

Instantly share code, notes, and snippets.

@NoahCardoza
Last active July 21, 2024 10:20
Show Gist options
  • Save NoahCardoza/03daee70663e4b9a3bc12490f6ec9300 to your computer and use it in GitHub Desktop.
Save NoahCardoza/03daee70663e4b9a3bc12490f6ec9300 to your computer and use it in GitHub Desktop.
Discord: Spotify Pause Blocker

Spotify Pause Blocker

Disclaimer

I love both of you Discord and Spotify, but this new 30 seccond rule gets pretty annoying when my music gets turned off while just talking "to much." I mean talking kind of is the whole point of Discord...

Reason

Recently, Discord started automatically pausing Spotify when your mic has been active for 30 seconds while Spotify is playing (on any device) in order to comply with Spotify's ToS. While I this is a valid reason, it is annoying.

The Last Straw

After a while this got too annyoing, my music would just flat out stop while playing games on mic with friends, while using headphones.

Solutions

Easiest Solution

Use Better Discord and add discord-spotify-fix.plugin.js to your plugins folder.

Less Easiest Solution

Copy the contents of copyme.js into the developer tool's console of the Discord app. The only caveat being you'll have to do this everytime you open Discord.

// save the orignial open function
XMLHttpRequest.prototype.realOpen = XMLHttpRequest.prototype.open;
// create a new function to filter out certain urls
var myOpen = function(method, url, async, user, password) {
// redirects the /pause to /play (which will do nothing since Spotify is already playing)
if (url == "https://api.spotify.com/v1/me/player/pause") {
url = "https://api.spotify.com/v1/me/player/play";
}
this.realOpen (method, url, async, user, password);
}
// overwrite the original open with our modded version
XMLHttpRequest.prototype.open = myOpen;
//META{"name":"SpotifyFixer"}*//
class SpotifyFixer {
getName() {
return "Spotify Pause Blocker";
}
getDescription() {
return "Keeps Discord from pausing your Spotify after 30 secconds of constant mic input.";
}
getVersion() {
return "0.0.1";
}
getAuthor() {
return "Noah Cardoza (MacHacker#7322)";
}
start() {
// save the orignial open function
XMLHttpRequest.prototype.realOpen = XMLHttpRequest.prototype.open;
// create a new function to filter out certain urls
var myOpen = function(method, url, async, user, password) {
// redirects the /pause to /play (which will do nothing since Spotify is already playing)
if (url == "https://api.spotify.com/v1/me/player/pause") {
url = "https://api.spotify.com/v1/me/player/play";
}
this.realOpen (method, url, async, user, password);
}
// overwrite the original open with our modded version
XMLHttpRequest.prototype.open = myOpen;
}
stop() {
XMLHttpRequest.prototype.open = XMLHttpRequest.prototype.realOpen;
}
}
@Avnsx
Copy link

Avnsx commented Oct 29, 2023

In 2023, I just suggest using this: https://github.com/SpotX-Official/SpotX

@RandomBagel420
Copy link

Dirty workaround for those that want to get this functionality back, if you go to discord devtools and block "https://api.spotify.com/v1/me/player/pause" you can bypass the auto pause.

Go to devtools (Inspect Element) with CTRL+Shift+i (if you aren't using betterdiscord you may need to enable it first, google how to)
Press CTRL+Shift+P to open the command menu
Type in Network Request Blocking
image
In the new panel, Enable Network Request Blocking and press the + icon
Type in "https://api.spotify.com/v1/me/player/pause" and press Add
image

You can now listen to music and yap at the same time. Enjoy your god given right.

You will need to turn Network Request Blocking on again every time you restart Discord, but it should remember your entry.

(edit: Rewrote instructions because I was dumb)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment