This code defines a userscript written for Tampermonkey (or any...
This code defines a userscript written for Tampermonkey (or any other compatible browser userscript manager) that is designed to modify the behavior of certain websites, specifically nitter.space
and lightbrd.com
.
What it does:
The userscript programmatically removes or bypasses any warnings or messages related to rate-limiting errors and related issues on these sites. Here's a breakdown of its features:
-
Intercept and Modify Network Requests:
- The script hijacks the
fetch
API and theXMLHttpRequest
functionality (both are used to make network requests in modern web apps). - It inspects network responses and modifies the text content to remove specific messages like "rate limiting," "instance has no auth tokens," and similar phrases.
- Optionally adds a custom header (
x-rate-limit-bypass
) to further bypass or confuse potential rate-limiting mechanisms.
- The script hijacks the
-
Modify Service Worker Responses:
- If the website uses service workers (a background script for handling network requests), the script intercepts their responses, applies the same text modifications, and ensures no rate-limiting-related warnings are displayed.
-
Monitor and Alter DOM Updates:
- The script uses
MutationObserver
and related APIs (likeIntersectionObserver
,ResizeObserver
, andPerformanceObserver
) to monitor changes in the DOM (Document Object Model). - It scans the content dynamically added to the webpage, scrubs out rate-limiting-related text (e.g., "rate limiting") from the displayed content.
- A persistent interval (runs every 198 ms) also ensures any dynamically loaded content is scrubbed of such text.
- The script uses
-
Scrub the Initial Page Load:
- On
DOMContentLoaded
(once the webpage finishes loading), the script modifies the entire HTML content of the page body to remove rate-limiting-related text messages.
- On
-
Tamper with Headers:
- Modifies outgoing header values (specifically the
User-Agent
header) to insert a randomized bot-like identifier (DAC-Bot
). This might help obfuscate or confuse servers regarding the identity of the browser and bypass rate-limiting checks tied to specific user-agent identifiers.
- Modifies outgoing header values (specifically the
Summary:
This code aims to completely bypass and hide rate-limiting-related restrictions and messages on the specified websites (nitter.space
and lightbrd.com
). It alters network requests, dynamic content, and service worker responses while ensuring any related error or warning messages are removed from the user-visible page content. This provides a seamless browsing experience for the user without interruptions from such restrictions.