Skip to content

Script load ever and do not respect a condition for a trigger manual #307

Open
@Met96

Description

@Met96

📚 What are you trying to do?

I make the follow code for run the script only in a specific countries, but it will be loaded ever without respect the condition
The follow code is inside a composable called in the app.vue of nuxt project.

Can you help me ?

🔍 What have you tried?

const notLoadCookieBanner = ['en-us'] 
const countryLocale = ref('es-es')
const {
    onLoaded,
    load: loadCookie,
  } = useScript<OneTrust>(
    {
      src: 'https://cdn.cookielaw.org/scripttemplates/otSDKStub.js',
      'data-domain-script': '....',
      defer: true,
    },
    {
      trigger: 'manual',
      use() {
        return window.OneTrust
      },
    }
  )

  if (
    countryLocale.value &&
    notLoadCookieBanner.findIndex(
      countryLocaleBanner => countryLocaleBanner === countryLocale.value
    ) === -1
  ) {
    loadCookie()
  }

ℹ️ Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions