Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Intercept Fetch Response
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description Intercept and modify fetch response
- // @author You
- // @match *://*/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- const originalFetch = window.fetch;
- window.fetch = function(...args) {
- return originalFetch(...args).then(response => {
- // Intercept the specific request URL
- if (response.url.includes('https://files.thisisnotawebsitedotcom.com/is-it-time-yet/well-is-it.txt')) {
- return response.clone().text().then(data => {
- // Modify the response if it's 'NO'
- if (data.trim() === 'NO') {
- const modifiedResponse = new Response('YES', {
- status: response.status,
- statusText: response.statusText,
- headers: response.headers
- });
- return modifiedResponse;
- }
- return response;
- });
- }
- return response;
- });
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement