☰

JW Player Double-Tap Fullscreen Blocker

Blocks JW Player's double-tap fullscreen trigger on ohentai.org. Manual fullscreen, play/pause, and in-fullscreen gestures remain functional.

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

You will need to install an extension such as Tampermonkey or Violentmonkey 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               JW Player Double-Tap Fullscreen Blocker
// @namespace          https://sleazyfork.org/en/users/1645436-angraecums
// @version            27.03
// @author             angraecums
// @description        Blocks JW Player's double-tap fullscreen trigger on ohentai.org. Manual fullscreen, play/pause, and in-fullscreen gestures remain functional.
// @license            MIT
// @icon               https://ohentai.org/favicon.ico
// @homepageURL        https://sleazyfork.org/en/scripts/596682-jw-player-double-tap-fullscreen-blocker
// @supportURL         https://sleazyfork.org/en/scripts/596682-jw-player-double-tap-fullscreen-blocker/feedback
// @match              *://*.ohentai.org/*
// @grant              none
// @run-at             document-start
// ==/UserScript==
(function () {
    'use strict';

    const TAG = '[JW-DT-Blocker]';
    const DOUBLE_TAP_WINDOW = 300; // ms

    // ---------------------------------------------------------------
    // 1. Neutralize webkitEnterFullscreen (iOS Safari fallback path)
    // ---------------------------------------------------------------
    ['webkitEnterFullscreen', 'webkitEnterFullScreen'].forEach(function (name) {
        const original = HTMLVideoElement.prototype[name];
        if (typeof original === 'function') {
            HTMLVideoElement.prototype[name] = function () {
                console.log(TAG, 'Intercepted', name);
                return original.apply(this, arguments);
            };
        }
    });

    // ---------------------------------------------------------------
    // 2. Suppress window-level dblclick (prevents bubbling to player)
    // ---------------------------------------------------------------
    window.addEventListener('dblclick', function (e) {
        e.stopImmediatePropagation();
    }, true);

    // ---------------------------------------------------------------
    // 3. Block the second touchstart on JW Player containers only.
    //    First tap still passes through so single-tap controls work.
    // ---------------------------------------------------------------
    let lastTapTime = 0;

    document.addEventListener('touchstart', function (e) {
        const target = e.target;
        if (!target || typeof target.closest !== 'function') return;
        if (!target.closest('.jwplayer')) return;

        const now = Date.now();
        if (now - lastTapTime < DOUBLE_TAP_WINDOW) {
            console.log(TAG, 'Second tap blocked on JW Player container.');
            e.stopImmediatePropagation();
        }
        lastTapTime = now;
    }, true);

    // ---------------------------------------------------------------
    // 4. Disable native double-tap gesture via CSS touch-action
    // ---------------------------------------------------------------
    const style = document.createElement('style');
    style.textContent = [
        '.jwplayer,',
        '.jw-media,',
        'video.jw-video {',
        '    touch-action: manipulation !important;',
        '}'
    ].join('\n');
    (document.head || document.documentElement).appendChild(style);

    console.log(TAG, 'v27.01 active.');
})();