diff --git a/tracker/tracker/src/main/index.ts b/tracker/tracker/src/main/index.ts index d1f345d55..2bca8f1a9 100644 --- a/tracker/tracker/src/main/index.ts +++ b/tracker/tracker/src/main/index.ts @@ -40,6 +40,7 @@ import type { Options as TimingOptions } from './modules/timing.js' import type { Options as NetworkOptions } from './modules/network.js' import type { MouseHandlerOptions } from './modules/mouse.js' import type { SessionInfo } from './app/session.js' +import type { CssRulesOptions } from './modules/cssrules.js' import type { StartOptions } from './app/index.js' //TODO: unique options init @@ -61,7 +62,7 @@ export type Options = Partial< } // dev only __DISABLE_SECURE_MODE?: boolean - checkCssInterval?: number + css: CssRulesOptions } const DOCS_SETUP = '/en/sdk' @@ -193,7 +194,7 @@ export default class API { Mouse(app, options.mouse) // inside iframe, we ignore viewport scroll Scroll(app, this.crossdomainMode) - CSSRules(app, options) + CSSRules(app, options.css) ConstructedStyleSheets(app) Console(app, options) Exception(app, options) diff --git a/tracker/tracker/src/main/modules/cssrules.ts b/tracker/tracker/src/main/modules/cssrules.ts index 0bb79c09b..cade75566 100644 --- a/tracker/tracker/src/main/modules/cssrules.ts +++ b/tracker/tracker/src/main/modules/cssrules.ts @@ -8,7 +8,12 @@ import { import { hasTag } from '../app/guards.js' import { nextID, styleSheetIDMap } from './constructedStyleSheets.js' -export default function (app: App, opts: { checkCssInterval?: number }) { +export interface CssRulesOptions { + checkCssInterval?: number + scanInMemoryCSS?: boolean +} + +export default function (app: App, opts: CssRulesOptions) { if (app === null) return if (!window.CSSStyleSheet) { app.send(TechnicalInfo('no_stylesheet_prototype_in_window', '')) @@ -22,6 +27,7 @@ export default function (app: App, opts: { checkCssInterval?: number }) { const checkIntervalMs = opts.checkCssInterval || 200 function checkRuleChanges() { + if (!opts.scanInMemoryCSS) return for (let i = 0; i < document.styleSheets.length; i++) { try { const sheet = document.styleSheets[i] @@ -171,7 +177,7 @@ export default function (app: App, opts: { checkCssInterval?: number }) { }) function startChecking() { - if (checkInterval) return + if (checkInterval || !opts.scanInMemoryCSS) return checkInterval = window.setInterval(checkRuleChanges, checkIntervalMs) }