TeleParty Addon

Nuke the TeleParty chat and all the other TeleParty crap, all while keeping TeleParty enabled and working :)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         TeleParty Addon
// @namespace    http://tampermonkey.net/
// @version      1.0
// @license      MIT
// @description  Nuke the TeleParty chat and all the other TeleParty crap, all while keeping TeleParty enabled and working :)
// @author       CandiceJoy
// @match        http*://hulu.com/*
// @match        http*://*.netflix.com/*
// @match        http*://*.disneyplus.com/*
// @match        http*://play.hbomax.com/*
// @match        http*://*.amazon.com/*/video/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=teleparty.com
// @require      https://code.jquery.com/jquery-3.6.0.min.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    const header = "[Candi Teleparty]";

    function log(msg,obj=null)
    {
        console.log( header + " " + msg );
    }

    let tpActive = false;
    let findPlayer;

    if( window.location.href.match( /netflix\.com/ig ) )
    {
        log("Netflix detected");
        findPlayer = function(){return document.querySelector(".watch-video--player-view");};
    }
    else if( window.location.href.match( /hulu\.com/ig ) )
    {
        log("Hulu detected");
        findPlayer = function(){return document.querySelector("#dash-player-container");};
    }
    else if( window.location.href.match( /disneyplus\.com/ig ) )
    {
        log("Disney+ detected");
        findPlayer = function(){return document.querySelector("#hudson-wrapper");};
    }
    else if( window.location.href.match( /hbomax\.com/ig ) )
    {
        log("HBO Max detected");
        findPlayer = function(){return null;};
    }
    else if( window.location.href.match( /amazon\.com/ig ) )
    {
        log("Amazon Prime detected");
        findPlayer = function(){return document.querySelector(".webPlayerSDKContainer");};
    }
    else
    {
        log("Streaming service not supported");
    }

    function callback(mutations,observer)
    {
        if( window.location.href.match( /hbomax/ig ) )
        {
            const area = document.querySelector("div.default");

            if( area )
            {
                const size = area.style.width;
                const player = document.querySelector(".tp-video");

                if( player )
                {
                    log("Resizing video");
                    player.style.width = size;
                }
            }
        }
        else
        {
            const player = findPlayer();

            if( player && player.classList.contains("with-chat") )
            {
                log("Resizing video");
                player.classList.remove("with-chat");
            }
        }

        if( !tpActive )
        {
            for(const mutation of mutations)
            {
                const target = mutation.target;
                const classes = mutation.target.classList;

                if( classes.contains("PlayerMetadata__subTitle") || classes.contains("ControlsContainer__transition") )
                {
                    continue;
                }

                //console.log("Mutated ",target);

                if( target.querySelector("#tpIconContainer") || target.querySelector("#chat-wrapper") )
                {
                    log("Detected Teleparty");
                    tpActive = true;
                    break;
                }
            }
        }

        if( !tpActive )
        {
            return;
        }

        const popup = document.querySelector("#tpIconContainer");

        if( popup )
        {
            log("Removing popup");
            popup.remove();
        }

        const chat = document.querySelector("#chat-wrapper");

        if( chat )
        {
            log("Removing chat");
            chat.remove();
        }

        if( !popup && !chat )
        {
            //observer.disconnect();
            log("Teleparty no longer detected");
            tpActive = false;
        }
    }

    log("Enabling observer");
    const targetNode = document.getElementsByTagName("body")[0];
    const config = { attributes: true, childList: true, subtree: true };
    const observer = new MutationObserver(callback);
    observer.observe(targetNode, config);
    //observer.disconnect();
})();