MissAV.com Stop pause video_

Removed the function to force video to pause when moving focus

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Necesitará instalar una extensión como Tampermonkey para instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         MissAV.com Stop pause video_
// @namespace    http://tampermonkey.net/
// @version      0.41
// @description  Removed the function to force video to pause when moving focus
// @author       MC Moo Hyun
// @include      *://missav.*/*
// @run-at       document-start
// @grant        none
// @license      MIT
// ==/UserScript==

/*
(function() {
    'use strict';

    document.addEventListener('visibilitychange', (event) => {
        event.stopImmediatePropagation();
    }, true);

    document.addEventListener('blur', (event) => {
        event.stopImmediatePropagation();
    }, true);

    window.addEventListener('blur', (event) => {
        event.stopImmediatePropagation();
    }, true);
})();
*/
/*
(function() {
    'use strict';

    // Store the original addEventListener function.
    // We modify EventTarget.prototype because it's the base for window, document, and all elements.
    const originalAddEventListener = EventTarget.prototype.addEventListener;

    // Redefine the addEventListener function.
    EventTarget.prototype.addEventListener = function(type, listener, options) {
        // Check if the event type is one we want to block.
        if (type === 'blur' || type === 'visibilitychange') {
            // Log a message to the console for debugging, so you know the script is working.
            console.log(`Tampermonkey: Blocked an event listener for "${type}".`);
            // By returning here, we prevent the original function from being called,
            // effectively blocking the website from adding its auto-pause listener.
            return;
        }

        // For all other event types, call the original addEventListener function.
        // This ensures the rest of the website functions normally.
        // We use .call(this, ...) to maintain the correct context.
        originalAddEventListener.call(this, type, listener, options);
    };

    console.log('Tampermonkey: Anti-pause script is active.');
})();

*/
// (Method 2: Override Player Action)
(function() {
    'use strict';

    // We need to wait for the page's scripts to create the 'window.player' object.
    // This interval will check for it periodically.
    const playerCheckInterval = setInterval(() => {
        // Check if the player object and its pause function exist yet.
        if (window.player && typeof window.player.pause === 'function') {
            // Once the player is found, stop the interval check.
            clearInterval(playerCheckInterval);

            console.log('Tampermonkey: Player object found. Overriding pause function.');

            // Store the original pause function in a variable.
            const originalPause = window.player.pause;

            // Redefine the player's pause function with our own logic.
            window.player.pause = function() {
                // This is the core logic:
                // If the document is hidden OR if the window does not have focus,
                // it means the pause was triggered automatically by the browser tab change.
                if (document.hidden || !document.hasFocus()) {
                    // Log that we blocked the pause and do nothing.
                    console.log('Tampermonkey: Automatic pause blocked because tab is not active.');
                    return; // By returning here, we prevent the original pause from happening.
                }

                // If the page is visible and has focus, it means the user likely
                // clicked the pause button manually.
                console.log('Tampermonkey: Manual pause allowed.');
                // Call the original pause function to actually pause the video.
                // We use .call(window.player) to ensure 'this' is set correctly.
                originalPause.call(window.player);
            };
        }
    }, 500); // Check every 500 milliseconds.
})();