Capture bindSNS Request and Response

Capture and store the bindSNS request and response

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Capture bindSNS Request and Response
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Capture and store the bindSNS request and response
// @match        *://*/*
// @grant        none
// @license MIT
// ==/UserScript==


(function() {
    'use strict';

    // Store the request and response in global variables
    window.bindSNSRequest = null;
    window.bindSNSResponse = null;

    // Intercept fetch requests
    const originalFetch = window.fetch;
    window.fetch = function(...args) {
        const url = args[0];
        return originalFetch.apply(this, args).then(response => {
            if (url.includes("bindSNS")) {
                console.log("Captured bindSNS request:", url);
                window.bindSNSRequest = url;

                // Clone the response so we can read it
                response.clone().text().then(text => {
                    console.log("Captured bindSNS response:", text);
                    window.bindSNSResponse = text;
                });
            }
            return response;
        });
    };

    // Intercept XMLHttpRequests (if needed)
    const originalXhrOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(method, url) {
        this.addEventListener("readystatechange", function() {
            if (this.readyState === 4 && url.includes("bindSNS")) {  // readyState 4 means the request is done
                console.log("Captured bindSNS request:", url);
                window.bindSNSRequest = url;
                console.log("Captured bindSNS response:", this.responseText);
                window.bindSNSResponse = this.responseText;
            }
        });
        originalXhrOpen.apply(this, arguments);
    };
})();