From c3b5e4815f4b19bc295d2cd35c5abf5dfe991c50 Mon Sep 17 00:00:00 2001 From: Victor Hargrave <115231412+vhargrave@users.noreply.github.com> Date: Tue, 2 Jul 2024 11:46:56 +0200 Subject: [PATCH] fix errors from console (#33) * fix errors from console * only call martech stuff if it's active * format content * also check for metadata --- express/scripts/scripts.js | 6 +++++- express/scripts/utils.js | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/express/scripts/scripts.js b/express/scripts/scripts.js index b2100e8d..430f7bb9 100644 --- a/express/scripts/scripts.js +++ b/express/scripts/scripts.js @@ -66,6 +66,8 @@ const CONFIG = { links: 'on', }; +const urlParams = new URLSearchParams(window.location.search); + /* * ------------------------------------------------------------ * Edit below at your own risk @@ -120,7 +122,9 @@ decorateArea(); // listenMiloEvents(); buildAutoBlocks(); - import('./instrument.js').then((mod) => { mod.default(); }); + if (urlParams.get('martech') !== 'off' || getMetadata('martech') === 'off') { + import('./instrument.js').then((mod) => { mod.default(); }); + } if (getMetadata('sheet-powered') === 'Y') { const { default: replaceContent } = await import('./utils/content-replace.js'); await replaceContent(document.querySelector('main')); diff --git a/express/scripts/utils.js b/express/scripts/utils.js index 83c6168b..db04933e 100644 --- a/express/scripts/utils.js +++ b/express/scripts/utils.js @@ -452,7 +452,9 @@ export function buildAutoBlocks() { button.appendChild(colEl); button.classList.add('metadata-powered'); lastDiv.append(button); - import('./block-mediator.min.js').then((mod) => { mod.set('floatingCtasLoaded', true); }); + import('./block-mediator.min.js').then((mod) => { + mod.default.set('floatingCtasLoaded', true); + }); } } }