Created
February 11, 2026 11:44
-
-
Save nitefood/f4a1aa53fbde27a4c2fe559cc85b906a to your computer and use it in GitHub Desktop.
Reddit 403 temp fix for "Your request has been blocked by network security. Please try to login with your Reddit account" (violentmonkey fix)
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
| // ==UserScript== | |
| // @name Reddit 403 Auto-Refresh Fix (SPA-aware) | |
| // @match https://www.reddit.com/* | |
| // @run-at document-start | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| let fetchPatched = false; | |
| function patchFetch() { | |
| if (fetchPatched) return; | |
| fetchPatched = true; | |
| const origFetch = window.fetch; | |
| window.fetch = async function(...args) { | |
| const url = args[0]; | |
| // Detect the failing Shreddit endpoint | |
| if (typeof url === "string" && url.includes("/svc/shreddit/comments/")) { | |
| const response = await origFetch(...args); | |
| if (response.status === 403) { | |
| if (!sessionStorage.getItem("shreddit-refreshed")) { | |
| sessionStorage.setItem("shreddit-refreshed", "1"); | |
| location.reload(); | |
| } | |
| } | |
| return response; | |
| } | |
| return origFetch(...args); | |
| }; | |
| } | |
| // Patch immediately on first load | |
| patchFetch(); | |
| // Detect SPA navigations (Chromium Navigation API) | |
| if (window.navigation && navigation.addEventListener) { | |
| navigation.addEventListener("navigate", (event) => { | |
| // Reset refresh flag on real navigations | |
| sessionStorage.removeItem("shreddit-refreshed"); | |
| // Re-patch fetch after SPA navigation | |
| fetchPatched = false; | |
| patchFetch(); | |
| }); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment