Skip to content

Instantly share code, notes, and snippets.

@NoahCardoza
Last active September 21, 2024 02:24
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;
}
}
@NoahCardoza
Copy link
Author

just do it how i did it https://www.reddit.com/r/Spotifyhosts/comments/kdnk0u/spotify_1148625g1c87c7f7_patch/ggb0b7q?utm_source=share&utm_medium=web2x&context=3

I don't think these do the same things... Not to mention that the solution you pointed to looks like it only works on windows at first glance. I've tried solutions like that, but Spotify made changes to their API where they served ADs from the same server they served music which messed up the hosts trick.

I found a way around it by using Spotify from a browser with AD Block and added a plugin which let me use my media keys.

But to recap, this script only stops Discord from pausing your Spotify when talking on voice for > 30 seconds without pause.

@jansson4
Copy link

jansson4 commented Feb 4, 2021

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

@Enyzelo
Copy link

Enyzelo commented Feb 23, 2021

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

@NoahCardoza
Copy link
Author

Thanks @Conqube, totally missed that’s last comment. Sorry @jansson4!

@jansson4
Copy link

jansson4 commented Mar 14, 2021

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

I did all this and it doesn't get detected by discord

@jansson4
Copy link

nevermind

@jansson4
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

I did all this and it doesn't get detected by discord

Nah atually it doesn't get detectected by discord

@Enyzelo
Copy link

Enyzelo commented Mar 24, 2021

Nah atually it doesn't get detectected by discord

Does your file has a icon like this one
image
It might also be the problem that you have .js at the end because some computer show you file without the extension (Type of file)
You could try removing .js at the end and if your file will remain the same then it's because of how it's named.
Keep me updated.

@nicosiahaan
Copy link

where plungin folder is?

@Enyzelo
Copy link

Enyzelo commented Apr 10, 2021

where plungin folder is?

C:\Users\NAME\AppData\Roaming\betterdiscord\plugins

is default location

@Eriksomething
Copy link

thank you alot my dude ♥

@XenderLord
Copy link

This just got patched ;-; . Or did they change something which makes this no longer work?

@Enyzelo
Copy link

Enyzelo commented Jun 2, 2021

This just got patched ;-; . Or did they change something which makes this no longer work?

You can try searching on Google BetterDiscord plugin or download plugin called plugin repo for BetterDicord and try finding the same or similiar plugin called as this one.
I will show you after I get some time. If you need it of course.

@melon-husk
Copy link

Yup, this seems to be patched ;-;

@NoahCardoza
Copy link
Author

NoahCardoza commented Sep 16, 2021

@XenderLord @melon-husk

I don't really use this plugin anymore but I bet there's still a workaround like @Conqube said. The nature of DIscord's app running a browser makes it quite easy to hijack.

@Enyzelo
Copy link

Enyzelo commented Sep 17, 2021

@XenderLord @melon-husk @NoahCardoza

Indeed, you could also find a plugin that allows you to join other people on spotify through discord. Of course you have to find it since I am not at home nor I have it.

Copy link

ghost commented Jun 6, 2022

The BDD plugin work for me on linux by the 6th of june 2022.

thank you, you are a life saver

@Torential
Copy link

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?

@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