Skip to content

Instantly share code, notes, and snippets.

@NoahCardoza
Last active November 28, 2024 13:36
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;
}
}
@Enyzelo
Copy link

Enyzelo commented Jun 12, 2022

The BDD plugin work for me on linux by the 6th of june 2022.
thank you, you are a life saver

Wheres the BDD plugin?

If you gonna scroll down from the top you will find bunch of randow words and letters or so called code in the post where it was originally posted, so there's two version that you can use is copyme.js which allows you to execute without BetterDiscord installed but you need to do it every time you turn on the Discord. But it might be harder now after the new recent Discord update where you can't open inspect element. If you will go on any browser and press ctrl+shift+i or f12 you will be able to open it. Then below it you will find discord-spotify-fix.plugin.js whivh I think you can download if not copy it and paste it in a .txt file for example spotify-plugin.txt > spotify-plugin.js and put it in the spotify plugin folder.

@Enyzelo
Copy link

Enyzelo commented Jun 12, 2022

@Torential
Copy link

So I made a video for everyone to watch. @Torential @melon-husk @XenderLord https://www.youtube.com/watch?v=CltPs5MjIIA

Cheers, I found another way that works the same without needing betterdiscord though.

@Enyzelo
Copy link

Enyzelo commented Jun 12, 2022

So I made a video for everyone to watch. @Torential @melon-husk @XenderLord https://www.youtube.com/watch?v=CltPs5MjIIA

Cheers, I found another way that works the same without needing betterdiscord though.

There are many ways to do it so nice.

@Stuyvenstein
Copy link

After checking the code within the JS file, I noticed that Discord pushes the pause request via the Spotify API, so my solution was to create a firewall rule that applies to Discord.exe only, that blocks api.spotify.com (IP 35.186.224.25)
NOTE: This will block all communication from Discord to the Spotify API.

@elijaholmos
Copy link

So I made a video for everyone to watch. @Torential @melon-husk @XenderLord youtube.com/watch?v=CltPs5MjIIA

Cheers, I found another way that works the same without needing betterdiscord though.

@Torential what was the way?

@ryrychu
Copy link

ryrychu commented Feb 5, 2023

@karimawi
Copy link

karimawi commented Feb 19, 2023

@osamamehfooz15
Copy link

How do i put the file in the plugins folder cuz when i do it it doesn't work

I will tell everything what you need to do.

  1. You will have to create a new text document
  2. Rename the text document to spotify.plugin.js
  3. Profit!

Why change it in the strange way? Well because betterdiscord now detects plugins if it has .plugin.js in the name. Name at the start or spotify in another words you can change it to anything you want but you will have to end it with AnyName.plugin.js In my case it's

image

Hope it helps you @jansson4

It works!!! Thank you

@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