import { browser } from 'wxt/browser';

export default defineContentScript({
  matches: ['<all_urls>'],
  main(ctx) {
    const serviceWorkerKeepAlive = () => {
      const port = browser.runtime.connect({ name: 'keepAlive' });
      port.postMessage({ ping: true, from: 'Content Script' });
    };

    browser.runtime.sendMessage({ type: 'wakeUp' }).catch(() => {});

    serviceWorkerKeepAlive();
    ctx.setInterval(serviceWorkerKeepAlive, 5000);
  },
});
