From 4a57825411c8103da92d578758d2bac4027e1ab2 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 1 Jun 2018 18:41:27 -0400 Subject: [PATCH] code review: remove scriplet js text after injection (see https://github.com/uBlockOrigin/uBlock-issues/issues/53#issuecomment-394024828) --- src/js/contentscript.js | 9 ++++++--- src/js/scriptlet-filtering.js | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/js/contentscript.js b/src/js/contentscript.js index 8d8d5edd0..5791f81de 100644 --- a/src/js/contentscript.js +++ b/src/js/contentscript.js @@ -1,7 +1,7 @@ /******************************************************************************* uBlock Origin - a browser extension to block requests. - Copyright (C) 2014-2017 Raymond Hill + Copyright (C) 2014-2018 Raymond Hill This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -356,8 +356,11 @@ vAPI.injectScriptlet = function(doc, text) { (doc.head || doc.documentElement).appendChild(script); } catch (ex) { } - if ( script && script.parentNode ) { - script.parentNode.removeChild(script); + if ( script ) { + if ( script.parentNode ) { + script.parentNode.removeChild(script); + } + script.textContent = ''; } }; diff --git a/src/js/scriptlet-filtering.js b/src/js/scriptlet-filtering.js index b12825dea..486cd58d9 100644 --- a/src/js/scriptlet-filtering.js +++ b/src/js/scriptlet-filtering.js @@ -78,8 +78,11 @@ (d.head || d.documentElement).appendChild(script); } catch (ex) { } - if ( script && script.parentNode ) { - script.parentNode.removeChild(script); + if ( script ) { + if ( script.parentNode ) { + script.parentNode.removeChild(script); + } + script.textContent = ''; } }; injectScriptlets(document);