This code is a **UserScript** designed to bypass rate-limiting messages...

August 29, 2025 at 10:31 PM

// ==UserScript== // @name Nitter Rate Limiting Bypass // @namespace http://tampermonkey.net/ // @version 0.2 // @description Seamlessly bypass rate limiting errors and warnings on nitter.space and lightbrd.com // @author You // @match *://*.nitter.space/* // @match *://*.lightbrd.com/* // @grant none // ==/UserScript== (function() { 'use strict'; // Optimized regex for rate limiting messages const RATE_LIMIT_REGEX = /rate\s?(?:limiting|Instance has no auth tokens)/gi; // Function to clean response text function cleanResponseText(text) { return typeof text === 'string'? text.replace(RATE_LIMIT_REGEX, '') : text;} // Function to intercept and modify network responses async function interceptNetworkResponse(request, response) { try { if (response.status === 200 && response.type === 'basic') { const responseText = await response.text(); const cleanedText = cleanResponseText(responseText); return new Response(cleanedText, { status: response.status, statusText: response.statusText, headers: response.headers });} return response;} catch (error) { console.error('Error in interceptNetworkResponse:', error); return response;} } // Override fetch API const originalFetch = window.fetch; window.fetch = async function(...args) { try { const response = await originalFetch.apply(this, args); return await interceptNetworkResponse(args[0], response);} catch (error) { console.error('Fetch override error:', error); return originalFetch.apply(this, args);} }; // Override XMLHttpRequest const originalOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function(method, url, async, user, password) { this.addEventListener('load', function() { try { if (this.status === 200 && this.responseText) { Object.defineProperty(this, 'responseText', { get: () => cleanResponseText(this._responseText), set: (value) => { this._responseText = value;}, configurable: true });} } catch (error) { console.error('XMLHttpRequest override error:', error);} }); originalOpen.apply(this, arguments);}; // Clean DOM content on load document.addEventListener('DOMContentLoaded', () => { try { const observer = new MutationObserver((mutations) => { mutations.forEach(mutation => { if (mutation.target && mutation.target.textContent) { mutation.target.textContent = cleanResponseText(mutation.target.textContent);} }); }); observer.observe(document.body, { childList: true, subtree: true });} catch (error) { console.error('MutationObserver error:', error);} }); // Service Worker fetch interception if ('serviceWorker' in navigator) { self.addEventListener('fetch', (event) => { event.respondWith( (async () => { try { const response = await fetch(event.request); return await interceptNetworkResponse(event.request, response);} catch (error) { console.error('ServiceWorker fetch error:', error); return fetch(event.request);} })() ); });}})();

This code is a UserScript designed to bypass rate-limiting messages on websites like nitter.space and lightbrd.com. Here's a breakdown of what it does:

  1. Header Metadata:

    • The script is set up as a UserScript, meaning it is to be used in browser extensions like Tampermonkey or Greasemonkey.
    • It defines metadata like the name, namespace, version, description, author, and websites (via the @match keyword) on which the script will run.
  2. Purpose:

    • The script targets rate-limiting errors and warnings, specifically on the aforementioned domains, and removes them to improve the user experience.
  3. How It Works:

    • Regex Matching:
      • A regular expression (RATE_LIMIT_REGEX) is defined to identify and match text messages related to rate-limiting or other related errors ("rate limiting" or "Instance has no auth tokens").
    • Network Response Cleaning:
      • The script intercepts and modifies network responses (both in fetch and XMLHttpRequest) to remove text matching the RATE_LIMIT_REGEX.
      • A function called cleanResponseText is used to sanitize and remove such messages from text-based responses.
    • Overrides Fetch API:
      • It overrides the fetch function in the browser to intercept network requests and clean up responses if they contain rate-limiting messages.
    • Overrides XMLHttpRequest:
      • Similarly, it overrides the XMLHttpRequest interface to intercept responses when loaded and cleans any matching error messages.
    • DOM Content Cleaning:
      • Once the page is loaded (DOMContentLoaded), a MutationObserver is used to monitor changes in the page's content. Any new text added to the DOM that contains rate-limiting errors is cleaned immediately.
    • Service Worker Fetch Handling:
      • If a Service Worker is present and intercepts fetch events, the script modifies the response to clean any rate-limiting-related text detected.
  4. Outcome:

    • The user is no longer bothered by rate-limiting error messages or warnings on the designated domains. The script essentially modifies the behavior of network requests and page content dynamically to bypass these issues.
  5. Error Handling:

    • Extensive error handling is included throughout the script to ensure that if any part of it fails (e.g., during response interception or DOM mutation), it logs the error to the console without breaking the website’s functionality.

Summary:
This script intercepts both client-side and network-level occurrences of rate-limiting error messages, removes them, and ensures a seamless browsing experience on the target websites.

Generate your own explanations
Download our vscode extension
Read other generated explanations

Built by @thebuilderjr
Sponsored by beam analytics
Read our terms and privacy policy
Forked from openai-quickstart-node