Parser_PayLoad_JVC

Parser_PayLoad_JVC_Html_Or_Str

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/588212/1908643/Parser_PayLoad_JVC.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// Parser_JVC_PayLoad.js
// ASYNCH

async function getPayloadFromHtml(doc) {
    //Test base64(gzip(JSON))
    try {
        const payload64 = [...doc.scripts].map(s => s.textContent.match(/jvc\.\w+Payload\s*=\s*["']([^"']+)["']/)).find(Boolean)?.[1];
        if (payload64) {
            const bytes = Uint8Array.from(atob(payload64), c => c.charCodeAt(0));
            const decompressedStream = new Blob([bytes]).stream().pipeThrough(new DecompressionStream('gzip'));
            return await new Response(decompressedStream).json();
        }
    } catch {}
    //Test base64(JSON)
    try {
        const payload64 = [...doc.scripts].map(s => s.textContent.match(/jvc\.\w+Payload\s*=\s*["']([^"']+)["']/)).find(Boolean)?.[1];
        if (payload64) return JSON.parse(atob(payload64));
    } catch {}
    //Test natif
    try {
        const payload = [...doc.scripts].map(s => s.textContent.match(/jvc\.\w*payload\s*=\s*(\{[\s\S]*?\})\s*;/i)).find(Boolean)?.[1];
        if (payload) return JSON.parse(payload);
    } catch {}
    return null;
}


async function getPayloadFromRaw(rawData) {
    //Test  base64(gzip(JSON))
    try {
        const payload64 = rawData.match(/jvc\.\w+Payload\s*=\s*["']([^"']+)["']/)?.[1];
        if (payload64) {
            const bytes = Uint8Array.from(atob(payload64), c => c.charCodeAt(0));
            const decompressedStream = new Blob([bytes]).stream().pipeThrough(new DecompressionStream('gzip'));
            return await new Response(decompressedStream).json();
        }
    } catch {}
    //Test base64(JSON)
    try {
        const payload64 = rawData.match(/jvc\.\w+Payload\s*=\s*["']([^"']+)["']/)?.[1];
        if (payload64) return JSON.parse(atob(payload64));
    } catch {}
    //Test natif
    try {
        const scripts = rawData.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi) || [];
        const payload = scripts.map(s => s.match(/jvc\.\w*payload\s*=\s*(\{[\s\S]*?\})\s*;/i)).find(Boolean)?.[1];
        if (payload) return JSON.parse(payload);
    } catch {}
    return null;
}