From c2063d10fbf43ef83a6881a653360cd0629274fe Mon Sep 17 00:00:00 2001 From: samuelmaddock Date: Wed, 1 Jul 2020 20:52:43 -0400 Subject: [PATCH] fix: replace innerHTML with textContent --- packages/metastream-remote-extension/src/first.js | 6 +++--- packages/metastream-remote-extension/src/player.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/metastream-remote-extension/src/first.js b/packages/metastream-remote-extension/src/first.js index a28aeb29..10f89e1f 100644 --- a/packages/metastream-remote-extension/src/first.js +++ b/packages/metastream-remote-extension/src/first.js @@ -114,7 +114,7 @@ mutationList.reduce((scripts, mutation) => { if (mutation.type !== 'childList') return scripts const inlineScripts = Array.from(mutation.addedNodes).filter( - node => node instanceof HTMLScriptElement && node.innerHTML.length > 0 + node => node instanceof HTMLScriptElement && node.textContent.length > 0 ) return inlineScripts.length > 0 ? [...scripts, ...inlineScripts] : scripts }, []) @@ -124,8 +124,8 @@ const scripts = getAddedScripts(mutationsList) for (let script of scripts) { for (let snippet of scriptSnippets) { - if (script.innerHTML.includes(snippet.code)) { - script.innerHTML = script.innerHTML.split(snippet.code).join(snippet.replacement) + if (script.textContent.includes(snippet.code)) { + script.textContent = script.textContent.split(snippet.code).join(snippet.replacement) } } } diff --git a/packages/metastream-remote-extension/src/player.js b/packages/metastream-remote-extension/src/player.js index 421bda7c..23d7cf71 100644 --- a/packages/metastream-remote-extension/src/player.js +++ b/packages/metastream-remote-extension/src/player.js @@ -999,7 +999,7 @@ ${ignoredSelectors}:empty { const visibleTagName = target instanceof HTMLVideoElement ? 'video' : 'iframe' const style = document.createElement('style') - style.innerHTML = getFocusStyles(visibleTagName, playerSettings.theaterModeSelectors) + style.textContent = getFocusStyles(visibleTagName, playerSettings.theaterModeSelectors) theaterModeStyle = style document.head.appendChild(theaterModeStyle) }