Untitled

mail@pastecode.io avatarunknown
plain_text
2 months ago
880 B
3
Indexable
Never
interface Ap3c {
  cmd: (() => void)[];
  act?: any[];
  init: (apiKey: string, apiUrl: string) => void;
  track: (params: { v: number }) => void;
  activity: (act: any) => void;
}

declare global {
  interface Window {
    ap3c: Ap3c;
  }
}

window.ap3c = window.ap3c ?? ({} as Ap3c);
const ap3c = window.ap3c;
ap3c.cmd = ap3c.cmd ?? [];
ap3c.cmd.push(() => {
  ap3c.init('ZM1hMAbRn1UH5kosdGVzdGluZ3VzYWJpbGl0eWh1Yg', 'https://capture-api.eu.autopilotapp.com/');
  ap3c.track({ v: 0 });
});
ap3c.activity = function (act: any) {
  ap3c.act = ap3c.act ?? [];
  ap3c.act.push(act);
};

const script = document.createElement('script');
script.type = 'text/javascript';
script.src = "https://cdneu.net/app.js";
const target = document.querySelector('script'); // Using querySelector is more specific
target?.insertAdjacentElement('beforebegin', script);