get an iframe directly to bypass overrides, thanks to upsuper
This commit is contained in:
parent
108160ef73
commit
bc6099ed96
2 changed files with 15 additions and 44 deletions
29
README.md
29
README.md
|
@ -23,29 +23,14 @@ function getIPs(callback){
|
||||||
|| window.webkitRTCPeerConnection;
|
|| window.webkitRTCPeerConnection;
|
||||||
var useWebKit = !!window.webkitRTCPeerConnection;
|
var useWebKit = !!window.webkitRTCPeerConnection;
|
||||||
|
|
||||||
//bypass naive webrtc blocking
|
//bypass naive webrtc blocking using an iframe
|
||||||
if(!RTCPeerConnection){
|
if(!RTCPeerConnection){
|
||||||
//create an iframe node that doesn't allow plugins
|
//NOTE: you need to have an iframe in the page right above the script tag
|
||||||
var iframe = document.createElement("iframe");
|
//
|
||||||
iframe.style.display = 'none';
|
//<iframe id="iframe" sandbox="allow-same-origin" style="display: none"></iframe>
|
||||||
iframe.sandbox = 'allow-same-origin allow-scripts';
|
//<script>...getIPs called in here...
|
||||||
document.body.appendChild(iframe);
|
//
|
||||||
|
var win = iframe.contentWindow;
|
||||||
//create a nested iframe that doesn't allow javascript
|
|
||||||
var iframe2 = iframe.contentDocument.createElement("iframe");
|
|
||||||
iframe2.sandbox = 'allow-same-origin';
|
|
||||||
|
|
||||||
//add a listener to cutoff any attempts to disable webrtc when inserting to the DOM
|
|
||||||
iframe2.addEventListener("DOMNodeInserted", function(e){
|
|
||||||
e.stopPropagation();
|
|
||||||
}, false);
|
|
||||||
iframe2.addEventListener("DOMNodeInsertedIntoDocument", function(e){
|
|
||||||
e.stopPropagation();
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
//get the RTCPeerConnection connection from the nested iframe
|
|
||||||
iframe.contentDocument.body.appendChild(iframe2);
|
|
||||||
var win = iframe2.contentWindow;
|
|
||||||
RTCPeerConnection = win.RTCPeerConnection
|
RTCPeerConnection = win.RTCPeerConnection
|
||||||
|| win.mozRTCPeerConnection
|
|| win.mozRTCPeerConnection
|
||||||
|| win.webkitRTCPeerConnection;
|
|| win.webkitRTCPeerConnection;
|
||||||
|
|
30
index.html
30
index.html
|
@ -19,6 +19,7 @@
|
||||||
<ul></ul>
|
<ul></ul>
|
||||||
<h4>Your public IP addresses:</h4>
|
<h4>Your public IP addresses:</h4>
|
||||||
<ul></ul>
|
<ul></ul>
|
||||||
|
<iframe id="iframe" sandbox="allow-same-origin" style="display: none"></iframe>
|
||||||
<script>
|
<script>
|
||||||
//get the IP addresses associated with an account
|
//get the IP addresses associated with an account
|
||||||
function getIPs(callback){
|
function getIPs(callback){
|
||||||
|
@ -30,29 +31,14 @@
|
||||||
|| window.webkitRTCPeerConnection;
|
|| window.webkitRTCPeerConnection;
|
||||||
var useWebKit = !!window.webkitRTCPeerConnection;
|
var useWebKit = !!window.webkitRTCPeerConnection;
|
||||||
|
|
||||||
//bypass naive webrtc blocking
|
//bypass naive webrtc blocking using an iframe
|
||||||
if(!RTCPeerConnection){
|
if(!RTCPeerConnection){
|
||||||
//create an iframe node that doesn't allow plugins
|
//NOTE: you need to have an iframe in the page right above the script tag
|
||||||
var iframe = document.createElement("iframe");
|
//
|
||||||
iframe.style.display = 'none';
|
//<iframe id="iframe" sandbox="allow-same-origin" style="display: none"></iframe>
|
||||||
iframe.sandbox = 'allow-same-origin allow-scripts';
|
//<script>...getIPs called in here...
|
||||||
document.body.appendChild(iframe);
|
//
|
||||||
|
var win = iframe.contentWindow;
|
||||||
//create a nested iframe that doesn't allow javascript
|
|
||||||
var iframe2 = iframe.contentDocument.createElement("iframe");
|
|
||||||
iframe2.sandbox = 'allow-same-origin';
|
|
||||||
|
|
||||||
//add a listener to cutoff any attempts to disable webrtc when inserting to the DOM
|
|
||||||
iframe2.addEventListener("DOMNodeInserted", function(e){
|
|
||||||
e.stopPropagation();
|
|
||||||
}, false);
|
|
||||||
iframe2.addEventListener("DOMNodeInsertedIntoDocument", function(e){
|
|
||||||
e.stopPropagation();
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
//get the RTCPeerConnection connection from the nested iframe
|
|
||||||
iframe.contentDocument.body.appendChild(iframe2);
|
|
||||||
var win = iframe2.contentWindow;
|
|
||||||
RTCPeerConnection = win.RTCPeerConnection
|
RTCPeerConnection = win.RTCPeerConnection
|
||||||
|| win.mozRTCPeerConnection
|
|| win.mozRTCPeerConnection
|
||||||
|| win.webkitRTCPeerConnection;
|
|| win.webkitRTCPeerConnection;
|
||||||
|
|
Loading…
Reference in a new issue