Netflix UHD

让 Netflix 在任何分辨率的显示器上播放 UHD 内容

当前为 2022-04-28 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name                 Netflix UHD
// @name:en              Netflix UHD
// @namespace            http://tampermonkey.net/
// @version              1.0
// @description          让 Netflix 在任何分辨率的显示器上播放 UHD 内容
// @description:en       Play Netflix UHD content on any screen resolution
// @author               TGSAN
// @match                https://www.netflix.com/*
// @icon                 https://www.google.com/s2/favicons?sz=64&domain=netflix.com
// @run-at               document-start
// @grant                unsafeWindow
// @grant                GM_registerMenuCommand
// ==/UserScript==

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

    if (self.unsafeWindow) {
        console.log("use unsafeWindow mode");
        delete unsafeWindow.screen;
        unsafeWindow.__defineGetter__('screen', function () {
            let s = [];
            s['width'] = 3840;
            s['height'] = 2160;
            s['availWidth'] = 3840;
            s['availHeight'] = 2160;
            s['availLeft'] = 0;
            s['availTop'] = 0;
            s['colorDepth'] = 32;
            s['isExtended'] = false;
            s['pixelDepth'] = 32;
            return s;
        });
        delete unsafeWindow.devicePixelRatio;
        unsafeWindow.devicePixelRatio = 4;

        if (unsafeWindow.MSMediaKeys) {
            unsafeWindow.MSMediaKeys.isTypeSupportedWithFeaturesOriginal = unsafeWindow.MSMediaKeys.isTypeSupportedWithFeatures;
            unsafeWindow.MSMediaKeys.isTypeSupportedWithFeatures = function (a, b) {
                const reg = /,display-res-[x|y]=\d+,display-res-[x|y]=\d+/
                b = b.replace(reg, "");
                let r = this.isTypeSupportedWithFeaturesOriginal(a, b);
                if (r !== '') {
                    console.log("Hook MSMediaKeys isTypeSupportedWithFeatures:", a, b, r !== '');
                } else {
                    console.debug("Hook MSMediaKeys isTypeSupportedWithFeatures:", a, b, r !== '');
                }
                return r;
            }
        }
    } else {
        console.log("use window mode");
        delete window.screen;
        window.__defineGetter__('screen', function () {
            let s = [];
            s['width'] = 3840;
            s['height'] = 2160;
            s['availWidth'] = 3840;
            s['availHeight'] = 2160;
            s['availLeft'] = 0;
            s['availTop'] = 0;
            s['colorDepth'] = 32;
            s['isExtended'] = false;
            s['pixelDepth'] = 32;
            return s;
        });
        delete window.devicePixelRatio;
        window.devicePixelRatio = 4;
        if (window.MSMediaKeys) {
            window.MSMediaKeys.isTypeSupportedWithFeaturesOriginal = MSMediaKeys.isTypeSupportedWithFeatures;
            window.MSMediaKeys.isTypeSupportedWithFeatures = function (a, b) {
                const reg = /,display-res-[x|y]=\d+,display-res-[x|y]=\d+/
                b = b.replace(reg, "");
                let r = this.isTypeSupportedWithFeaturesOriginal(a, b);
                if (r !== '') {
                    console.log("Hook MSMediaKeys isTypeSupportedWithFeatures:", a, b, r !== '');
                } else {
                    console.debug("Hook MSMediaKeys isTypeSupportedWithFeatures:", a, b, r !== '');
                }
                return r;
            }
        }
    }
    let checkHDCPAsync = async function () {
        if (self.GM_registerMenuCommand && window.MSMediaKeys) {
            let hdcp0 = window.MSMediaKeys.isTypeSupportedWithFeaturesOriginal("com.microsoft.playready.software", 'video/mp4; features="hdcp=0"') != '';
            let hdcp1 = window.MSMediaKeys.isTypeSupportedWithFeaturesOriginal("com.microsoft.playready.software", 'video/mp4; features="hdcp=1"') != '';
            let hdcp2 = window.MSMediaKeys.isTypeSupportedWithFeaturesOriginal("com.microsoft.playready.software", 'video/mp4; features="hdcp=2"') != '';
            let bool2Status = function (booltype) {
                return booltype ? "Yes" : "No";
            };
            GM_registerMenuCommand("PlayReady DRM Info (" + (hdcp2 ? "UHD Ready" : "Restricted") + ")", function () {
                let content = "PlayReady DRM (without HDCP 2.2): " + bool2Status(hdcp0) + "\n";
                content += "PlayReady DRM (HDCP 2.2): " + bool2Status(hdcp1) + "\n";
                content += "PlayReady DRM (HDCP 2.2 Type 1): " + bool2Status(hdcp2) + "\n";
                alert(content);
            });
        }
    };
    checkHDCPAsync();
})();