WebRTC禁用脚本

尝试禁止WebRTC泄露真实ip

// ==UserScript==
// @name         WebRTC禁用脚本
// @version      1.1
// @description  尝试禁止WebRTC泄露真实ip
// @match        *://*/*
// @grant        unsafeWindow
// @grant        GM_xmlhttpRequest
// @run-at       document-start
// @license      MIT
// @namespace https://viayoo.com/
// ==/UserScript==

// 在这里添加不禁用WebRTC的站点 Add your whitelist URLs here
const whitelist = [
  "https://example.com",
  "https://example.net"
];

function isWhitelisted(url) {
  return whitelist.some((whitelistedUrl) => url.startsWith(whitelistedUrl));
}

// Block WebRTC on non-whitelisted pages
if (!isWhitelisted(window.location.href)) {
    const killWebRTC = () => {
        unsafeWindow['RTCPeerConnection'] = null;
        unsafeWindow['webkitRTCPeerConnection'] = null;
        unsafeWindow['mozRTCPeerConnection'] = null;
    };
    killWebRTC();
}