diff --git a/README.md b/README.md index b9f1021..afbe9d7 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,22 @@ function getIPs(callback){ var RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; + + //bypass naive webrtc blocking + if (!RTCPeerConnection) { + var iframe = document.createElement('iframe'); + iframe.style.display = 'none'; + document.body.appendChild(iframe); + var win = iframe.contentWindow; + window.RTCPeerConnection = win.RTCPeerConnection; + window.mozRTCPeerConnection = win.mozRTCPeerConnection; + window.webkitRTCPeerConnection = win.webkitRTCPeerConnection; + RTCPeerConnection = window.RTCPeerConnection + || window.mozRTCPeerConnection + || window.webkitRTCPeerConnection; + } + + //minimal requirements for data connection var mediaConstraints = { optional: [{RtpDataChannels: true}] }; diff --git a/index.html b/index.html index 66e5bb1..a53b300 100644 --- a/index.html +++ b/index.html @@ -28,19 +28,22 @@ var RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; + + //bypass naive webrtc blocking if (!RTCPeerConnection) { - //bypass naive webrtc blocking - var iframe = document.createElement('iframe'); - iframe.style.display = 'none'; - document.body.appendChild(iframe); - var win = iframe.contentWindow; - window.RTCPeerConnection = win.RTCPeerConnection; - window.mozRTCPeerConnection = win.mozRTCPeerConnection; - window.webkitRTCPeerConnection = win.webkitRTCPeerConnection; - RTCPeerConnection = window.RTCPeerConnection - || window.mozRTCPeerConnection - || window.webkitRTCPeerConnection; + var iframe = document.createElement('iframe'); + iframe.style.display = 'none'; + document.body.appendChild(iframe); + var win = iframe.contentWindow; + window.RTCPeerConnection = win.RTCPeerConnection; + window.mozRTCPeerConnection = win.mozRTCPeerConnection; + window.webkitRTCPeerConnection = win.webkitRTCPeerConnection; + RTCPeerConnection = window.RTCPeerConnection + || window.mozRTCPeerConnection + || window.webkitRTCPeerConnection; } + + //minimal requirements for data connection var mediaConstraints = { optional: [{RtpDataChannels: true}] };