private function injectJqueryToResponse(string $body, string $tokenValue): string
    {
        $regex = '/(.*?)(<\/body>)/is';
        $jQueryCode = sprintf(
            '<script>$.ajaxSetup({beforeSend: function (xhr) { xhr.setRequestHeader("X-CSRF-Token","%s"); }});</script>',
            $tokenValue
        );
        $body = preg_replace($regex, '$1' . $jQueryCode . '$2', $body, -1, $count) ?? '';

        if (!$count) {
            // Inject JS code anyway
            $body .= $jQueryCode;
        }

        return $body;
    }