Guest User

Untitled

a guest
Jun 23rd, 2025
3,350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Pixverse NSFW Video Bypass
  3. // @match       https://app.pixverse.ai/*
  4. // @run-at      document-start
  5. // @version     3.2
  6. // @author      cptdan
  7. // ==/UserScript==
  8.  
  9. (function () {
  10.     'use strict';
  11.  
  12.     const DEBUG_PREFIX = '[Pixverse Bypass]';
  13.     const MAX_ATTEMPTS = 20;
  14.     let savedMediaPath = null;
  15.     let isInitialized = false;
  16.  
  17.     function log(message, ...args) {
  18.         console.log(`${DEBUG_PREFIX} ${message}`, ...args);
  19.     }
  20.  
  21.     function error(message, ...args) {
  22.         console.error(`${DEBUG_PREFIX} ${message}`, ...args);
  23.     }
  24.  
  25.     // Safe XHR Override
  26.     function overrideXHR() {
  27.         if (!window.XMLHttpRequest) {
  28.             error('XMLHttpRequest not supported');
  29.             return;
  30.         }
  31.  
  32.         try {
  33.             const originalOpen = XMLHttpRequest.prototype.open;
  34.             const originalSend = XMLHttpRequest.prototype.send;
  35.  
  36.             XMLHttpRequest.prototype.open = function (method, url) {
  37.                 this.requestUrl = url;
  38.                 log('Opening request:', url);
  39.                 try {
  40.                     return originalOpen.apply(this, arguments);
  41.                 } catch (e) {
  42.                     error('Open error:', e);
  43.                     throw e;
  44.                 }
  45.             };
  46.  
  47.             XMLHttpRequest.prototype.send = function (body) {
  48.                 log('Sending request:', this.requestUrl);
  49.  
  50.                 // Capture media path
  51.                 if (this.requestUrl.includes('/media/') && body) {
  52.                     try {
  53.                         let data = body;
  54.                         if (body instanceof FormData) {
  55.                             data = Object.fromEntries(body);
  56.                         } else if (typeof body === 'string') {
  57.                             data = JSON.parse(body || '{}');
  58.                         }
  59.                         savedMediaPath = extractMediaPath(data, this.requestUrl);
  60.                         log('Captured media path:', savedMediaPath);
  61.                     } catch (e) {
  62.                         error('Error parsing request body:', e);
  63.                     }
  64.                 }
  65.  
  66.                 // Handle response
  67.                 const loadHandler = function () {
  68.                     if (this.status >= 200 && this.status < 300) {
  69.                         try {
  70.                             const response = parseResponse(this);
  71.                             const modifiedData = modifyResponse(response, this.requestUrl);
  72.  
  73.                             if (modifiedData) {
  74.                                 Object.defineProperties(this, {
  75.                                     response: { value: modifiedData, writable: true, configurable: true },
  76.                                     responseText: { value: JSON.stringify(modifiedData), writable: true, configurable: true }
  77.                                 });
  78.                                 log('Response modified successfully for:', this.requestUrl);
  79.                             }
  80.                         } catch (e) {
  81.                             error('Response processing error:', e);
  82.                         }
  83.                     } else {
  84.                         log('Request failed with status:', this.status);
  85.                     }
  86.                 }.bind(this);
  87.  
  88.                 this.addEventListener('load', loadHandler, { once: true });
  89.  
  90.                 try {
  91.                     return originalSend.apply(this, arguments);
  92.                 } catch (e) {
  93.                     error('Send error:', e);
  94.                     throw e;
  95.                 }
  96.             };
  97.  
  98.             log('XHR overrides initialized successfully');
  99.         } catch (e) {
  100.             error('Failed to initialize XHR overrides:', e);
  101.         }
  102.     }
  103.  
  104.     function extractMediaPath(data, url) {
  105.         if (url.includes('/media/batch_upload_media')) {
  106.             return data?.images?.[0]?.path;
  107.         } else if (url.includes('/media/upload')) {
  108.             return data?.path;
  109.         }
  110.         return null;
  111.     }
  112.  
  113.     function parseResponse(xhr) {
  114.         try {
  115.             return xhr.responseType === 'json' ? xhr.response : JSON.parse(xhr.responseText || '{}');
  116.         } catch (e) {
  117.             error('Failed to parse response:', e);
  118.             return {};
  119.         }
  120.     }
  121.  
  122.     function modifyResponse(data, url) {
  123.         if (!data || typeof data !== 'object') return null;
  124.  
  125.         if (url.includes('/video/list/personal')) {
  126.             return modifyVideoList(data);
  127.         } else if (url.includes('/media/batch_upload_media')) {
  128.             return modifyBatchUpload(data);
  129.         } else if (url.includes('/media/upload')) {
  130.             return modifySingleUpload(data);
  131.         }
  132.         return null;
  133.     }
  134.  
  135.     function modifyVideoList(data) {
  136.         if (!data?.Resp?.data) return data;
  137.  
  138.         return {
  139.             ...data,
  140.             Resp: {
  141.                 ...data.Resp,
  142.                 data: data.Resp.data.map(item => ({
  143.                     ...item,
  144.                     video_status: item.video_status === 7 ? 1 : item.video_status,
  145.                     first_frame: (item.extended === 1 && item.customer_paths?.customer_video_last_frame_url) ||
  146.                                 item.customer_paths?.customer_img_url || '',
  147.                     url: item.video_path ? `https://media.pixverse.ai/${item.video_path}` : ''
  148.                 }))
  149.             }
  150.         };
  151.     }
  152.  
  153.     function modifyBatchUpload(data) {
  154.         if (data?.ErrCode === 400 && savedMediaPath) {
  155.             const imageId = Date.now();
  156.             const imageName = savedMediaPath.split('/').pop() || 'uploaded_media';
  157.  
  158.             return {
  159.                 ErrCode: 0,
  160.                 ErrMsg: "success",
  161.                 Resp: {
  162.                     result: [{
  163.                         id: imageId,
  164.                         category: 0,
  165.                         err_msg: "",
  166.                         name: imageName,
  167.                         path: savedMediaPath,
  168.                         size: 0,
  169.                         url: `https://media.pixverse.ai/${savedMediaPath}`
  170.                     }]
  171.                 }
  172.             };
  173.         }
  174.         return data;
  175.     }
  176.  
  177.     function modifySingleUpload(data) {
  178.         if (data?.ErrCode === 400040 && savedMediaPath) {
  179.             return {
  180.                 ErrCode: 0,
  181.                 ErrMsg: "success",
  182.                 Resp: {
  183.                     path: savedMediaPath,
  184.                     url: `https://media.pixverse.ai/${savedMediaPath}`
  185.                 }
  186.             };
  187.         }
  188.         return data;
  189.     }
  190.  
  191.     // Watermark Button Setup
  192.     function setupWatermarkButton() {
  193.         let attempts = 0;
  194.  
  195.         function attemptReplace() {
  196.             try {
  197.                 const watermarkDiv = Array.from(document.querySelectorAll('div'))
  198.                     .find(el => el.textContent?.trim() === 'Watermark-free');
  199.  
  200.                 if (watermarkDiv && watermarkDiv.parentNode) {
  201.                     const newButton = createWatermarkButton();
  202.                     watermarkDiv.parentNode.replaceChild(newButton, watermarkDiv);
  203.                     log('Watermark button replaced successfully');
  204.                     return true;
  205.                 } else if (attempts < MAX_ATTEMPTS) {
  206.                     attempts++;
  207.                     log('Attempting to find watermark button:', attempts);
  208.                     setTimeout(attemptReplace, 500);
  209.                     return false;
  210.                 } else {
  211.                     error('Max attempts reached for watermark button');
  212.                     return false;
  213.                 }
  214.             } catch (e) {
  215.                 error('Error in button replacement:', e);
  216.                 return false;
  217.             }
  218.         }
  219.  
  220.         if (document.readyState === 'complete') {
  221.             attemptReplace();
  222.         } else {
  223.             document.addEventListener('DOMContentLoaded', attemptReplace);
  224.         }
  225.     }
  226.  
  227.     function createWatermarkButton() {
  228.         const button = document.createElement('button');
  229.         button.textContent = 'Watermark-free';
  230.  
  231.         button.addEventListener('click', (e) => {
  232.             e.preventDefault();
  233.             e.stopPropagation();
  234.  
  235.             const videoElement = document.querySelector('.component-video > video');
  236.             if (videoElement?.src) {
  237.                 downloadVideo(videoElement.src);
  238.             } else {
  239.                 error('No video element found');
  240.                 alert('No video available to download');
  241.             }
  242.         });
  243.  
  244.         return button;
  245.     }
  246.  
  247.     function downloadVideo(url) {
  248.         try {
  249.             const link = document.createElement('a');
  250.             link.href = url;
  251.             link.download = url.split('/').pop() || 'video.mp4';
  252.             document.body.appendChild(link);
  253.             link.click();
  254.             document.body.removeChild(link);
  255.             log('Video download initiated:', url);
  256.         } catch (e) {
  257.             error('Download error:', e);
  258.             alert('Failed to download video');
  259.         }
  260.     }
  261.  
  262.     // Initialization
  263.     function initialize() {
  264.         if (isInitialized) return;
  265.  
  266.         try {
  267.             overrideXHR();
  268.             setupWatermarkButton();
  269.             isInitialized = true;
  270.             log('Script initialized successfully');
  271.         } catch (e) {
  272.             error('Initialization failed:', e);
  273.         }
  274.     }
  275.  
  276.     if (document.readyState === 'loading') {
  277.         document.addEventListener('DOMContentLoaded', initialize);
  278.     } else {
  279.         initialize();
  280.     }
  281. })();
Advertisement
Add Comment
Please, Sign In to add comment