pull/2/head
gorhill 8 years ago
parent 69a9cd66d1
commit 754e8213cf

@ -109,7 +109,6 @@ var injectNavigatorSpoofer = function(spoofedUserAgent) {
scriptText = navigatorSpoofer.replace('{{ua-json}}', JSON.stringify(spoofedUserAgent)), scriptText = navigatorSpoofer.replace('{{ua-json}}', JSON.stringify(spoofedUserAgent)),
script = document.createElement('script'); script = document.createElement('script');
script.setAttribute('type', 'text/javascript'); script.setAttribute('type', 'text/javascript');
script.setAttribute('id', 'umatrix-ua-spoofer');
script.appendChild(document.createTextNode(scriptText)); script.appendChild(document.createTextNode(scriptText));
try { try {
parent.appendChild(script); parent.appendChild(script);
@ -118,21 +117,18 @@ var injectNavigatorSpoofer = function(spoofedUserAgent) {
} }
// https://github.com/gorhill/uMatrix/issues/771 // https://github.com/gorhill/uMatrix/issues/771
var spoofer = document.querySelector('script#umatrix-ua-spoofer'); if ( script.parentNode !== null ) {
if ( spoofer !== null ) { script.parentNode.removeChild(script);
spoofer.parentNode.removeChild(spoofer);
script = document.createElement('script'); script = document.createElement('script');
script.setAttribute('type', 'text/javascript'); script.setAttribute('type', 'text/javascript');
script.setAttribute('id', 'umatrix-ua-spoofer');
script.setAttribute('src', 'data:application/javascript;base64,' + window.btoa(scriptText)); script.setAttribute('src', 'data:application/javascript;base64,' + window.btoa(scriptText));
try { try {
parent.appendChild(script); parent.appendChild(script);
} }
catch (ex) { catch (ex) {
} }
spoofer = document.querySelector('script#umatrix-ua-spoofer'); if ( script.parentNode !== null ) {
if ( spoofer !== null ) { script.parentNode.removeChild(script);
spoofer.parentNode.removeChild(spoofer);
} }
} }

Loading…
Cancel
Save