html5 p2p直播源,屏蔽html5播放器p2p上传

// ==UserScript==

// @name 屏蔽html5播放器p2p上传

// @version 0.1.3

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

// @author binsee

// @namespace https://github.com/binsee/tampermonkey-scripts

// @supportURL https://github.com/binsee/tampermonkey-scripts/issues

// @license GPL

// @match *://*.douyu.com/*

// @match *://*.qq.com/*

// @match *://*.huya.com/*

// @match *://*/*

// @exclude *://*.bilibili.com/*

// @exclude *://*.discord.com/*

// @exclude *://*.twitch.tv/*

// @exclude *://*.ext-twitch.tv/*

// @grant none

// ==/UserScript==

let HookFlag = false

let debugFlag = true

let jsName = '屏蔽html5播放器p2p上传'

let logger = {

debug: createDebugMethod('debug'),

info: createDebugMethod('info'),

warn: createDebugMethod('warn'),

error: createDebugMethod('error')

};

function createDebugMethod(name) {

const bgColorMap = {

debug: '#0070BB',

info: '#009966',

warn: '#BBBB23',

error: '#bc0004'

};

name = bgColorMap[name] ? name : 'info';

return function () {

const args = Array.from(arguments);

args.unshift(`color: white; background-color: ${bgColorMap[name] || '#FFFFFF'}`);

args.unshift(`【${jsName}】 %c[${name.toUpperCase()}]:`);

console[name].apply(console, args);

}

}

(function () {

'use strict';

let funNameList = [

'RTCPeerConnection',

'webkitRTCPeerConnection',

'mozRTCPeerConnection',

'msRTCPeerConnectio',

]

funNameList.forEach(name => {

if (typeof window._RTCPeerConnection === "undefined") window._RTCPeerConnection = window[name];

if (typeof window[name] !== "undefined") window[name] = debugFlag ? MyPeerConnection : undefined;

})

logger.info('已屏蔽p2p上传功能')

function MyPeerConnection(args) {

logger.debug(`PeerConnection() 被调用!

当前页面尝试建立p2p连接!

调用参数: ${JSON.stringify(args)}`)

return HookFlag ? new window._RTCPeerConnection(args) : undefined

}

})();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值