B站 WASM 软解动态屏蔽

动态屏蔽哔哩哔哩 WASM HEVC 解码器(需要浏览器支持HEVC才管用)

目前为 2024-09-24 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name B站 WASM 软解动态屏蔽
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.7
  5. // @description 动态屏蔽哔哩哔哩 WASM HEVC 解码器(需要浏览器支持HEVC才管用)
  6. // @author TGSAN
  7. // @exclude https://live.bilibili.com/*
  8. // @exclude http://live.bilibili.com/*
  9. // @match https://*.bilibili.com/*
  10. // @match http://*.bilibili.com/*
  11. // @run-at document-start
  12. // @grant unsafeWindow
  13. // @grant GM_registerMenuCommand
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. const useEdgeMode = false;
  20.  
  21. function GetUrlRelativePath()
  22. {
  23. let url = document.location.toString();
  24. let arrurl = url.split("//");
  25.  
  26. let start = arrurl[1].indexOf("/");
  27. let relurl = arrurl[1].substring(start);
  28.  
  29. if(relurl.indexOf("?") != -1){
  30. relurl = relurl.split("?")[0];
  31. }
  32. return relurl;
  33. }
  34.  
  35. function HookUA(uastr)
  36. {
  37. Object.defineProperty(navigator, 'userAgent', {
  38. value: uastr
  39. });
  40. }
  41.  
  42. if (MediaSource.isTypeSupported('video/mp4; codecs="hev1.1.6.L93"') || MediaSource.isTypeSupported('video/mp4; codecs="hvc1.1.6.L93"')) {
  43. // 检测是否支持HEVC
  44. if (document.domain == "live.bilibili.com") {
  45. // 直播
  46. HookUA(navigator.userAgent.replace(/\s+Edg\/(\d+\.)*\d+\s*/, ""));
  47. } else if (document.domain == "www.bilibili.com" || document.domain == "bilibili.com") {
  48. // 主站
  49. if (GetUrlRelativePath() == "/") {
  50. // 首页
  51. } else {
  52. // 点播
  53. if (useEdgeMode) {
  54. HookUA('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/100.0.3538.102 Safari/605.1.15 Edge/18.22000');
  55. } else {
  56. HookUA("Mozilla/5.0 (Macintosh; Intel Mac OS X 15_0) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/19.0 Safari/605.1.15");
  57. }
  58. }
  59. }
  60. } else {
  61. // 不支持的
  62. let userAgent = navigator.userAgent;
  63. let isEdge = userAgent.indexOf("Edge") > -1;
  64. let isEdgeChromium = userAgent.indexOf("Edg") > -1;
  65. let isWindows = userAgent.indexOf("Windows NT") > -1;
  66. if (isWindows && (isEdge || isEdgeChromium)) {
  67. GM_registerMenuCommand("(未启用)点击安装 HEVC 扩展", function() {
  68. window.open('ms-windows-store://pdp?productId=9n4wgh0z6vhq&mode=mini', '_self')
  69. });
  70. } else {
  71. GM_registerMenuCommand("(未启用)此浏览器不支持 HEVC", function() {
  72. alert("此插件尚未生效\r\n因为此浏览器不支持 HEVC\r\n\r\n推荐使用 Windows 版 Microsoft Edge 浏览器");
  73. });
  74. }
  75. }
  76. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址