I have following textarea element having some templated codes in it and it cannot be modified as there is no option in blogger:
<textarea hidden class='hidden' id='tempJs'><script defer='' src='/js/cookienotice.js' type="976adfed5ff69a3a2e21c1d0-text/javascript"></script>
<script type="976adfed5ff69a3a2e21c1d0-text/javascript">
document.addEventListener('DOMContentLoaded', function(event) {
// Some JS
});
</script>
<script type="976adfed5ff69a3a2e21c1d0-text/javascript" src="https://www.blogger.com/static/v1/widgets/1197256859-widgets.js"></script>
<script type="976adfed5ff69a3a2e21c1d0-text/javascript">
window['__wavt'] = 'AOuZoY7izjkWOpen881b-llDDktDVnRQIQ:1672120416426';
//...Some JS
_WidgetManager._RegisterWidget('_HTMLView', new _WidgetInfo('HTML9', 'gmp_custom_script', document.getElementById('HTML9'), {}, 'displayModeFull'));
</script></textarea>
I want to extract the following parts of codes from textarea.innerText:
window['__wavt'] = 'AOuZoY7izjkWOpen881b-llDDktDVnRQIQ:1672120416426';
//...Some JS
_WidgetManager._RegisterWidget('_HTMLView', new _WidgetInfo('HTML9', 'gmp_custom_script', document.getElementById('HTML9'), {}, 'displayModeFull'));
I tried the following:
<!--[ My Script ]-->
<script>
/*<![CDATA [*/
let tempEl = document.getElementById("tempJs"),
tempTx = tempEl.innerText,
widgetJs = tempTx.split("<script type='text/javascript'>\n")[1].split("\n<\/script>")[0].trim();
tempEl.remove()
/*]]>*/
</script>
But, the thing is type attribute is changing all the time also there are four script tags
How can I extract only that part from string?