MissAV.com Stop pause video_

Removed the function to force video to pause when moving focus

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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.
})();