WATCHIT STATMENT

Watch any videos without Ads & Log videos URLs with some meta data like type (HLS or DASH), codecs and encryptionn status (DRM OR NOT)

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         WATCHIT STATMENT
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Watch any videos without Ads & Log videos URLs with some meta data like type (HLS or DASH), codecs and encryptionn status (DRM OR NOT)
// @author       Mahmoud Khudairi
// @match        https://www.watchit.com/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=watchit.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    window.XMLHttpRequest = new Proxy(window.XMLHttpRequest, {
        construct(target, args) {
            const xhr = new target(...args);
            xhr.open = new Proxy(xhr.open, {
                apply(target, arg, args) {
                    if (/accounts\/\d+\/videos\/ref/i.test(args[1])) {
                        const url = new URL(args[1], location.href);
                        url.searchParams.delete("ad_config_id");
                        args[1] = url.toString();
                        xhr.addEventListener("load", function () {
                            const data = JSON.parse(this.responseText);
                            if (!data.sources) return;
                            let msg = "[WATCHIT_STATMENT]\nSources:";
                            for (const source of data.sources) {
                                const sourceMeta = [];
                                sourceMeta.push(`type=${encodeURIComponent(source.type.includes("mpegURL") ? "hls" : "dash")}`);
                                sourceMeta.push(`drm=${encodeURIComponent("key_systems" in source ? "yes" : "no")}`);
                                if ("key_systems" in source) {
                                    const keySystems = source.key_systems;
                                    for (const [keySystemName, keySystem] of Object.entries(keySystems)) {
                                        const name = keySystemName.match(/(?:widevine|playready)/);
                                        if (name) {
                                            sourceMeta.push(`${name}_license=${encodeURIComponent(keySystem.license_url)}`);
                                        } else {
                                            sourceMeta.push(`fairplay_key=${encodeURIComponent(keySystem.certificate_url)}`);
                                            sourceMeta.push(`fairplay_cert=${encodeURIComponent(keySystem.key_request_url)}`);
                                        }
                                    }
                                }
                                sourceMeta.push(`ads=${encodeURIComponent("vmap" in source ? "yes" : "no")}`);
                                sourceMeta.push(`codecs=${encodeURIComponent(source.codecs)}`);
                                sourceMeta.push(`src=${encodeURIComponent(source.src)}`);
                                console.log("[WATCHIT_STATMENT::STREAMS]:", Object.fromEntries(sourceMeta.map((param) => param.split("=").map((c, i) => i ? decodeURIComponent(c) : c))));
                                msg += `\n  ${sourceMeta.join("&")}`;
                            }
                            console.log(msg);
                        }, {once: 1});
                    }
                    return target.apply(arg, args);
                }
            });
            return xhr;
        }
    });
})();