From 754e8213cfd8f1404e117294388eacd76698f84e Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 27 Apr 2017 00:02:08 -0400 Subject: [PATCH] code review 6781a98f --- src/js/contentscript-start.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/js/contentscript-start.js b/src/js/contentscript-start.js index 2699d65..4cef60e 100644 --- a/src/js/contentscript-start.js +++ b/src/js/contentscript-start.js @@ -109,7 +109,6 @@ var injectNavigatorSpoofer = function(spoofedUserAgent) { scriptText = navigatorSpoofer.replace('{{ua-json}}', JSON.stringify(spoofedUserAgent)), script = document.createElement('script'); script.setAttribute('type', 'text/javascript'); - script.setAttribute('id', 'umatrix-ua-spoofer'); script.appendChild(document.createTextNode(scriptText)); try { parent.appendChild(script); @@ -118,21 +117,18 @@ var injectNavigatorSpoofer = function(spoofedUserAgent) { } // https://github.com/gorhill/uMatrix/issues/771 - var spoofer = document.querySelector('script#umatrix-ua-spoofer'); - if ( spoofer !== null ) { - spoofer.parentNode.removeChild(spoofer); + if ( script.parentNode !== null ) { + script.parentNode.removeChild(script); script = document.createElement('script'); script.setAttribute('type', 'text/javascript'); - script.setAttribute('id', 'umatrix-ua-spoofer'); script.setAttribute('src', 'data:application/javascript;base64,' + window.btoa(scriptText)); try { parent.appendChild(script); } catch (ex) { } - spoofer = document.querySelector('script#umatrix-ua-spoofer'); - if ( spoofer !== null ) { - spoofer.parentNode.removeChild(spoofer); + if ( script.parentNode !== null ) { + script.parentNode.removeChild(script); } }