屏蔽html5播放器p2p上传

屏蔽html5播放器使用WebRTC技术进行p2p上传,以及防止通过p2p泄露ip,如斗鱼直播后台上传等。需要注意默认屏蔽所有网站html5的p2p功能,需要使用p2p的网站请自行加入排除列表,如网易uu语音、twitch等。嫌麻烦的请勿用。

  1. // ==UserScript==
  2. // @name 屏蔽html5播放器p2p上传
  3. // @version 0.1.4
  4. // @description 屏蔽html5播放器使用WebRTC技术进行p2p上传,以及防止通过p2p泄露ip,如斗鱼直播后台上传等。需要注意默认屏蔽所有网站html5的p2p功能,需要使用p2p的网站请自行加入排除列表,如网易uu语音、twitch等。嫌麻烦的请勿用。
  5. // @author binsee
  6. // @namespace https://github.com/binsee/tampermonkey-scripts
  7. // @supportURL https://github.com/binsee/tampermonkey-scripts/issues
  8. // @license GPL
  9. // @run-at document-start
  10. // @match *://*.douyu.com/*
  11. // @match *://*.qq.com/*
  12. // @match *://*.huya.com/*
  13. // @match *://*/*
  14. // @exclude *://*.bilibili.com/*
  15. // @exclude *://*.discord.com/*
  16. // @exclude *://*.twitch.tv/*
  17. // @exclude *://*.ext-twitch.tv/*
  18. // @grant none
  19. // ==/UserScript==
  20. let HookFlag = false
  21.  
  22. let debugFlag = true
  23. let jsName = '屏蔽html5播放器p2p上传'
  24. let logger = {
  25. debug: createDebugMethod('debug'),
  26. info: createDebugMethod('info'),
  27. warn: createDebugMethod('warn'),
  28. error: createDebugMethod('error')
  29. };
  30.  
  31. function createDebugMethod(name) {
  32. const bgColorMap = {
  33. debug: '#0070BB',
  34. info: '#009966',
  35. warn: '#BBBB23',
  36. error: '#bc0004'
  37. };
  38. name = bgColorMap[name] ? name : 'info';
  39. return function () {
  40. const args = Array.from(arguments);
  41. args.unshift(`color: white; background-color: ${bgColorMap[name] || '#FFFFFF'}`);
  42. args.unshift(`【${jsName}】 %c[${name.toUpperCase()}]:`);
  43. console[name].apply(console, args);
  44. }
  45. }
  46.  
  47.  
  48. (function () {
  49. 'use strict';
  50. let funNameList = [
  51. 'RTCPeerConnection',
  52. 'webkitRTCPeerConnection',
  53. 'mozRTCPeerConnection',
  54. 'msRTCPeerConnectio',
  55. ]
  56. funNameList.forEach(name => {
  57. if (typeof window._RTCPeerConnection === "undefined") window._RTCPeerConnection = window[name];
  58. if (typeof window[name] !== "undefined") window[name] = debugFlag ? MyPeerConnection : undefined;
  59. })
  60. logger.info('已屏蔽p2p上传功能')
  61.  
  62. function MyPeerConnection(args) {
  63. logger.debug(`PeerConnection() 被调用!
  64. 当前页面尝试建立p2p连接!
  65. 调用参数: ${JSON.stringify(args)}`)
  66. return HookFlag ? new window._RTCPeerConnection(args) : undefined
  67. }
  68. })();
  69.  
  70.  

QingJ © 2025

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