@Anybody I tried some hot code to test my suggested change (new to drupal)
function cookies_matomo_page_attachments(&$page) {
$doKo = CookiesKnockOutService::getInstance()->doKnockOut();
if ($doKo && isset($page["#attached"]["html_head"])) {
to
function cookies_matomo_page_attachments(&$page) {
$doKo = CookiesKnockOutService::getInstance()->doKnockOut();
$service = \Drupal::entityTypeManager()->getStorage('cookies_service')->load('matomo');
if ($doKo && $service->status() && $service->getConsentRequired() && isset($page["#attached"]["html_head"])) {
and the script type is not altered.