JSFiddle - React, Tailwind, and code Playground

HTML

foo

<script>
    test();
</script>

bar

JavaScript

function test() {
    $('script:last').replaceWith("hacked");
}