Hulu Remove Up Next and Dialog

Removes the "Up Next" section and any related dialogs on Hulu for playback

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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         Hulu Remove Up Next and Dialog
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Removes the "Up Next" section and any related dialogs on Hulu for playback
// @author       F02x
// @match        https://www.hulu.com/*
// @grant        none
// @license      WTFPL
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    // Function to remove elements matching a selector
    function removeElements(selector) {
        const elements = document.querySelectorAll(selector);
        elements.forEach(el => {
            el.style.display = 'none'; // Hide instead of remove to avoid breaking scripts
        });
    }

    // Function to check and remove "Up Next" and dialogs
    function cleanUpNextAndDialogs() {
        // Target "Up Next" section (common class names based on Hulu's typical structure)
        removeElements('.UpNext, .up-next, [class*="upnext"], [class*="UpNext"]');

        // Target dialog/pop-up elements (common overlay or modal classes)
        removeElements('.modal, .dialog, .overlay, [class*="Modal"], [class*="Dialog"]');

        // Target any autoplay-related elements
        removeElements('[class*="autoplay"], [class*="Autoplay"]');
    }

    // Run cleanup initially
    cleanUpNextAndDialogs();

    // Use a MutationObserver to handle dynamically loaded content
    const observer = new MutationObserver(() => {
        cleanUpNextAndDialogs();
    });

    // Observe changes in the body to catch dynamic updates
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

    // Optional: Stop observer when leaving the page (cleanup)
    window.addEventListener('unload', () => {
        observer.disconnect();
    });
})();