Created
January 23, 2025 08:49
-
-
Save akirilyuk/08b6fca11b28643c3187b20ee3b50f24 to your computer and use it in GitHub Desktop.
Overwrite global fetch with discord proxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const addProxy = (url) => { | |
| if(url.startsWith('data')){ | |
| return url; | |
| } | |
| const split = url.split('/'); | |
| const proxyIndex = url.includes('://') ? 3 : split[0] !== '' ? 0 : 1; | |
| if (split.length <= proxyIndex) { | |
| return url; | |
| } | |
| if (split[proxyIndex] !== '.proxy' && split[proxyIndex] !== '') { | |
| split.splice(proxyIndex, 0, '.proxy'); | |
| return split.join('/'); | |
| } | |
| return url; | |
| }; | |
| const originalFetch = window.fetch; | |
| window.fetch = (param1, param2) => { | |
| if (typeof param1 === 'string') { | |
| return originalFetch(addProxy(param1), param2); | |
| } | |
| return originalFetch(param1, param2); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment