Advertisement
Guest User

Untitled

a guest
Jul 31st, 2024
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Intercept Fetch Response
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Intercept and modify fetch response
  6. // @author You
  7. // @match *://*/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. const originalFetch = window.fetch;
  15. window.fetch = function(...args) {
  16. return originalFetch(...args).then(response => {
  17. // Intercept the specific request URL
  18. if (response.url.includes('https://files.thisisnotawebsitedotcom.com/is-it-time-yet/well-is-it.txt')) {
  19. return response.clone().text().then(data => {
  20. // Modify the response if it's 'NO'
  21. if (data.trim() === 'NO') {
  22. const modifiedResponse = new Response('YES', {
  23. status: response.status,
  24. statusText: response.statusText,
  25. headers: response.headers
  26. });
  27. return modifiedResponse;
  28. }
  29. return response;
  30. });
  31. }
  32. return response;
  33. });
  34. };
  35. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement