NeverDecaf / discord-PWA

A wrapper for the Discord web client as a PWA, made for Chromium browsers on desktop.
MIT License
145 stars 13 forks source link

Refuses to connect when user is using browser scripts with Discord #5

Closed ghost closed 3 years ago

ghost commented 4 years ago

The use of browser scripts via TamperMonkey which modify discord.com, such as this, directly causes Discord PWA to fail to connect. Specifically, the error shows as "discord.com refused to connect."

I am using the latest version of Ungoogled Chromium. I suspect this could possibly be caused by a browser setting or flag, but upon disabling TamperMonkey, Discord PWA begins working immediately.

While TamperMonkey is enabled and running scripts, discord.com (non-PWA) remains functional.

NeverDecaf commented 4 years ago

Are you using a self-built Ungoogled Chromium? On 83.0.4103.116 from https://github.com/macchrome/winchrome, a.k.a woolyss' site the script you linked works fine in TamperMonkey for me.

ghost commented 4 years ago

I'm using the same binary downloaded by your auto-updater (thanks for creating that, btw!). I initially used the portable version from https://ungoogled-software.github.io/ungoogled-chromium-binaries/releases/windows/64bit/81.0.4044.138-1.1, but when I began using your auto-updater, I removed my portable install. AFAIK, my version should be the same as yours. Perhaps I have a flag or setting changed which is messing it up. I will start troubleshooting as soon as possible.

NeverDecaf commented 4 years ago

That is surprising, we should have the same setup. One possibility I can think of is either Tampermonkey itself or one of your scripts is modifying the HTTP Headers sent by discord.com (not sure if this is even possible in Tampermonkey userscripts) and reversing the change made by the discord-PWA extension to the X-Frame-Options or Content-Security-Policy headers as the "refused to connect" error is also what you would see without the accompanying extension installed. Perhaps a good place to start would be disabling all your userscripts besides the one in question to see if the problem still occurs.

ghost commented 4 years ago

Great call, the inspector console for the frame shows a single error, Refused to display 'https://discord.com/channels/@me' in a frame because it set 'X-Frame-Options' to 'deny'.

I recently reinstalled my OS so that userscript was the only one I have, and the only one I have any interest in using with Discord at the moment. The error is also only a problem while the page is loading. If I disable the script (or, more easily, Tampermonkey itself), open Discord-PWA, and then enable the script/Tampermonkey, Discord-PWA continues to work, and the script works too.

I suppose you would know better than I would what causes the problem specifically.

NeverDecaf commented 4 years ago

This is probably caused by installing Tampermonkey after the discord-PWA extension. The webrequest documentation states: Only one extension is allowed to redirect a request or modify a header at a time. If more than one extension attempts to modify the request, the most recently installed extension wins and all others are ignored. Try removing and reinstalling the bypass extension and see if you still get the error.

ghost commented 3 years ago

I think this information should be added to the readme.