bypass createElement overrides
This commit is contained in:
parent
7123a0545d
commit
108160ef73
2 changed files with 38 additions and 35 deletions
36
README.md
36
README.md
|
@ -25,25 +25,27 @@ function getIPs(callback){
|
||||||
|
|
||||||
//bypass naive webrtc blocking
|
//bypass naive webrtc blocking
|
||||||
if(!RTCPeerConnection){
|
if(!RTCPeerConnection){
|
||||||
//create an iframe node
|
//create an iframe node that doesn't allow plugins
|
||||||
var iframe = document.createElement('iframe');
|
var iframe = document.createElement("iframe");
|
||||||
iframe.style.display = 'none';
|
iframe.style.display = 'none';
|
||||||
|
iframe.sandbox = 'allow-same-origin allow-scripts';
|
||||||
//invalidate content script
|
|
||||||
iframe.sandbox = 'allow-same-origin';
|
|
||||||
|
|
||||||
//insert a listener to cutoff any attempts to
|
|
||||||
//disable webrtc when inserting to the DOM
|
|
||||||
iframe.addEventListener("DOMNodeInserted", function(e){
|
|
||||||
e.stopPropagation();
|
|
||||||
}, false);
|
|
||||||
iframe.addEventListener("DOMNodeInsertedIntoDocument", function(e){
|
|
||||||
e.stopPropagation();
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
//insert into the DOM and get that iframe's webrtc
|
|
||||||
document.body.appendChild(iframe);
|
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;
|
||||||
|
|
37
index.html
37
index.html
|
@ -32,26 +32,27 @@
|
||||||
|
|
||||||
//bypass naive webrtc blocking
|
//bypass naive webrtc blocking
|
||||||
if(!RTCPeerConnection){
|
if(!RTCPeerConnection){
|
||||||
//create an iframe node
|
//create an iframe node that doesn't allow plugins
|
||||||
var iframe = document.createElement('iframe');
|
var iframe = document.createElement("iframe");
|
||||||
iframe.style.display = 'none';
|
iframe.style.display = 'none';
|
||||||
|
iframe.sandbox = 'allow-same-origin allow-scripts';
|
||||||
//invalidate content script
|
|
||||||
iframe.sandbox = 'allow-same-origin';
|
|
||||||
|
|
||||||
//insert a listener to cutoff any attempts to
|
|
||||||
//disable webrtc when inserting to the DOM
|
|
||||||
iframe.addEventListener("DOMNodeInserted", function(e){
|
|
||||||
e.stopPropagation();
|
|
||||||
}, false);
|
|
||||||
iframe.addEventListener("DOMNodeInsertedIntoDocument", function(e){
|
|
||||||
e.stopPropagation();
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
|
|
||||||
//insert into the DOM and get that iframe's webrtc
|
|
||||||
document.body.appendChild(iframe);
|
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