Netflix Tile Fix

Open Netflix's non-link tiles in new tabs with "title" URLs instead of "watch" on middle click, ignoring regular links.

スクリプトをインストールするには、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		Netflix Tile Fix
// @namespace	http://tampermonkey.net/
// @version     0.92
// @description Open Netflix's non-link tiles in new tabs with "title" URLs instead of "watch" on middle click, ignoring regular links.
// @author      Murat Malatya
// @match		https://www.netflix.com/*
// @grant		none
// @license     MIT
// ==/UserScript==

(function() {
    'use strict';

    function extractNetflixId(element) {
        const allElements = [element, ...element.querySelectorAll('*')];
        for (const el of allElements) {
            const ctx = el.getAttribute('data-ui-tracking-context');
            if (ctx) {
                try {
                    const parsed = JSON.parse(decodeURIComponent(ctx));
                    if (parsed.video_id) {
                        return parsed.video_id;
                    }
                }
                catch (e) {
                }
            }
        }
        return null;
    }

    function isNetflixRecommendation(element) {
        if (element.closest('.ptrack-content')) {
            return true;
        }
        return false;
    }

    function handleMouseDown(event) {
        if (event.button !== 1) {
            return;
        }

        const target = event.target;
        let element = target;
        let maxDepth = 10;

        while (element && maxDepth > 0) {
            if (element.tagName === 'A' && element.href) {
                return;
            }

            if (isNetflixRecommendation(element)) {
                const netflixId = extractNetflixId(element);
                if (netflixId) {
                    event.preventDefault();
                    event.stopPropagation();
                    event.stopImmediatePropagation();
                    const titleUrl = `https://www.netflix.com/title/${netflixId}`;
                    window.open(titleUrl, '_blank');
                    return;
                }
            }

            element = element.parentElement;
            maxDepth--;
        }
    }

    document.addEventListener('mousedown', handleMouseDown, {
        capture: true,
        passive: false
    });
})();