UNPKG

create-chrome-ext

Version:

Scaffolding your chrome extension, multiple boilerplates supported!

32 lines (24 loc) 574 B
import Alpine from 'alpinejs' import type { Alpine as AlpineType } from 'alpinejs' declare global { interface Window { Alpine: AlpineType } } window.Alpine = Alpine queueMicrotask(() => { Alpine?.data?.('options', () => ({ countSync: 0, init() { chrome.storage.sync.get(['count'], (result) => { this.countSync = result.count || 0 }) chrome.runtime.onMessage.addListener((request) => { if (request.type === 'COUNT') { this.countSync = request.count || 0 } }) }, })) Alpine.start() })