Netflix UHD

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

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

  1. // ==UserScript==
  2. // @name Netflix UHD
  3. // @name:en Netflix UHD
  4. // @namespace http://tampermonkey.net/
  5. // @version 1.0
  6. // @description 让 Netflix 在任何分辨率的显示器上播放 UHD 内容
  7. // @description:en Play Netflix UHD content on any screen resolution
  8. // @author TGSAN
  9. // @match https://www.netflix.com/*
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=netflix.com
  11. // @run-at document-start
  12. // @grant unsafeWindow
  13. // @grant GM_registerMenuCommand
  14. // ==/UserScript==
  15.  
  16. (function () {
  17. // 'use strict';
  18.  
  19. if (self.unsafeWindow) {
  20. console.log("use unsafeWindow mode");
  21. delete unsafeWindow.screen;
  22. unsafeWindow.__defineGetter__('screen', function () {
  23. let s = [];
  24. s['width'] = 3840;
  25. s['height'] = 2160;
  26. s['availWidth'] = 3840;
  27. s['availHeight'] = 2160;
  28. s['availLeft'] = 0;
  29. s['availTop'] = 0;
  30. s['colorDepth'] = 32;
  31. s['isExtended'] = false;
  32. s['pixelDepth'] = 32;
  33. return s;
  34. });
  35. delete unsafeWindow.devicePixelRatio;
  36. unsafeWindow.devicePixelRatio = 4;
  37.  
  38. if (unsafeWindow.MSMediaKeys) {
  39. unsafeWindow.MSMediaKeys.isTypeSupportedWithFeaturesOriginal = unsafeWindow.MSMediaKeys.isTypeSupportedWithFeatures;
  40. unsafeWindow.MSMediaKeys.isTypeSupportedWithFeatures = function (a, b) {
  41. const reg = /,display-res-[x|y]=\d+,display-res-[x|y]=\d+/
  42. b = b.replace(reg, "");
  43. let r = this.isTypeSupportedWithFeaturesOriginal(a, b);
  44. if (r !== '') {
  45. console.log("Hook MSMediaKeys isTypeSupportedWithFeatures:", a, b, r !== '');
  46. } else {
  47. console.debug("Hook MSMediaKeys isTypeSupportedWithFeatures:", a, b, r !== '');
  48. }
  49. return r;
  50. }
  51. }
  52. } else {
  53. console.log("use window mode");
  54. delete window.screen;
  55. window.__defineGetter__('screen', function () {
  56. let s = [];
  57. s['width'] = 3840;
  58. s['height'] = 2160;
  59. s['availWidth'] = 3840;
  60. s['availHeight'] = 2160;
  61. s['availLeft'] = 0;
  62. s['availTop'] = 0;
  63. s['colorDepth'] = 32;
  64. s['isExtended'] = false;
  65. s['pixelDepth'] = 32;
  66. return s;
  67. });
  68. delete window.devicePixelRatio;
  69. window.devicePixelRatio = 4;
  70. if (window.MSMediaKeys) {
  71. window.MSMediaKeys.isTypeSupportedWithFeaturesOriginal = MSMediaKeys.isTypeSupportedWithFeatures;
  72. window.MSMediaKeys.isTypeSupportedWithFeatures = function (a, b) {
  73. const reg = /,display-res-[x|y]=\d+,display-res-[x|y]=\d+/
  74. b = b.replace(reg, "");
  75. let r = this.isTypeSupportedWithFeaturesOriginal(a, b);
  76. if (r !== '') {
  77. console.log("Hook MSMediaKeys isTypeSupportedWithFeatures:", a, b, r !== '');
  78. } else {
  79. console.debug("Hook MSMediaKeys isTypeSupportedWithFeatures:", a, b, r !== '');
  80. }
  81. return r;
  82. }
  83. }
  84. }
  85. let checkHDCPAsync = async function () {
  86. if (self.GM_registerMenuCommand && window.MSMediaKeys) {
  87. let hdcp0 = window.MSMediaKeys.isTypeSupportedWithFeaturesOriginal("com.microsoft.playready.software", 'video/mp4; features="hdcp=0"') != '';
  88. let hdcp1 = window.MSMediaKeys.isTypeSupportedWithFeaturesOriginal("com.microsoft.playready.software", 'video/mp4; features="hdcp=1"') != '';
  89. let hdcp2 = window.MSMediaKeys.isTypeSupportedWithFeaturesOriginal("com.microsoft.playready.software", 'video/mp4; features="hdcp=2"') != '';
  90. let bool2Status = function (booltype) {
  91. return booltype ? "Yes" : "No";
  92. };
  93. GM_registerMenuCommand("PlayReady DRM Info (" + (hdcp2 ? "UHD Ready" : "Restricted") + ")", function () {
  94. let content = "PlayReady DRM (without HDCP 2.2): " + bool2Status(hdcp0) + "\n";
  95. content += "PlayReady DRM (HDCP 2.2): " + bool2Status(hdcp1) + "\n";
  96. content += "PlayReady DRM (HDCP 2.2 Type 1): " + bool2Status(hdcp2) + "\n";
  97. alert(content);
  98. });
  99. }
  100. };
  101. checkHDCPAsync();
  102. })();