Here's an example script to include in your phtml file, which will be whitelisted by CSP. You can use a similar method for other inline scripts:
<?php
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
$scriptString = <<<script
require(['jquery'],function($){
$(document).ready(function() {
zE('webWidget', 'setLocale', 'NB');
});
});
script;
?>
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?>
Place this code in your phtml file, and it should resolve csp the error.
/**
* @return false|\Magento\Csp\Helper\CspNonceProvider
*/
public function getCspNonceProvider()
{
if (class_exists(\Magento\Csp\Helper\CspNonceProvider::class)) {
return \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Csp\Helper\CspNonceProvider::class);
}
return false;
}
<?php
$_helper = $this->helper(\Vendor\Module\Helper\Data::class);
/** @var \Vendor\Module\Helper\Data $_helper */
$cspNonceProvider = $_helper->getCspNonceProvider();
?>
<script <?php if ($cspNonceProvider) echo ' nonce="' . $cspNonceProvider->generateNonce() . '" ' ?>>
require(['jquery'],function($){
$(document).ready(function() {
zE('webWidget', 'setLocale', 'NB');
});
});
</script>