diff --git a/client/src/core/client/count/index.ts b/client/src/core/client/count/index.ts index 33d05faa65..6226672fc6 100644 --- a/client/src/core/client/count/index.ts +++ b/client/src/core/client/count/index.ts @@ -1,6 +1,5 @@ import { COUNT_SELECTOR } from "coral-framework/constants"; import detectCountScript from "coral-framework/helpers/detectCountScript"; -import getCurrentScriptOrigin from "coral-framework/helpers/getCurrentScriptOrigin"; import resolveStoryURL from "coral-framework/helpers/resolveStoryURL"; import jsonp from "coral-framework/utils/jsonp"; @@ -23,7 +22,11 @@ interface DetectAndInjectArgs { /** Detects count elements and use jsonp to inject the counts. */ function detectAndInject(opts: DetectAndInjectArgs = {}) { - const ORIGIN = getCurrentScriptOrigin(); + // Get ORIGIN from the count.js script that we know will be on the page. + const ORIGIN = document + .querySelector(".coral-script") + ?.getAttribute("src") + ?.split("/assets")[0]; const STORY_URL = resolveStoryURL(window); /** A map of references pointing to the count query arguments */