Guest User

Untitled

a guest
Mar 12th, 2023
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         ChatGPT_Unblock
  3. // @namespace    http://tampermonkey.intercept
  4. // @version      1.1
  5. // @author       Iumi#5555
  6. // @description  Remove Orange flagged status and restore keep messages from ChatGPT
  7. // @match        https://chat.openai.com/*
  8. // @grant        none
  9. // @run-at       document-start
  10. // ==/UserScript==
  11.  
  12. (function() {
  13.     'use strict';
  14.  
  15.     // Intercept fetch GET requests and remove JSON attribute
  16.     const originalFetch = window.fetch;
  17.     window.fetch = async function(url, options) {
  18.         if (options && options.method && options.method.toUpperCase() === 'GET') {
  19.             console.log('Intercepted GET request:', url);
  20.             const response = await originalFetch(url, options);
  21.             if (response.headers.get('content-type').startsWith('application/json')) {
  22.                 const responseBody = await response.json();
  23.                 console.log('JSON response:', responseBody);
  24.                 // Remove specified attribute from JSON response
  25.                 delete responseBody.moderation_results;
  26.                 const modifiedResponse = new Response(JSON.stringify(responseBody), response);
  27.                 return Promise.resolve(modifiedResponse);
  28.             }
  29.             return Promise.resolve(response);
  30.         } else if (options && options.method && options.method.toUpperCase() === 'POST' && url === 'https://chat.openai.com/backend-api/moderations') {
  31.             console.log('Blocked POST request:', url);
  32.             return Promise.resolve(new Response(null, { status: 403, statusText: 'Forbidden' }));
  33.         }
  34.         return originalFetch.apply(this, arguments);
  35.     };
  36. })();
Add Comment
Please, Sign In to add comment