<script>
console.log(1)
</script>
<script>
console.log(1)
</script>
const str = `
<script>
console.log(1)
</script>
<script>
console.log(1)
</script>
`;
const head = document.getElementsByTagName('head')[0];
const script = document.createElement('script');
script.text = str.replace(/<[^>]*>?/gm, '');
head.appendChild(script);