diff --git a/src/content.tsx b/src/content.tsx index ca59507..48d1b7f 100644 --- a/src/content.tsx +++ b/src/content.tsx @@ -5,7 +5,8 @@ import type { TargetConfig } from 'services/config' void (async () => { let lastRightClick: { element: Element } | null = null let lastElement: Element | null = null - let lastTargets: TargetConfig[] = [] + let lastLocalTargets: TargetConfig[] = [] + let lastSyncTargets: TargetConfig[] = [] let mode: 'standby' | 'addTarget' = 'standby' // Top priority functions (for save mouse position for contextmenu) @@ -36,18 +37,26 @@ void (async () => { ]) ChromeStorageUtils.get('local', ConfigService.TARGETS_KEY, []).then(targets => { - lastTargets = targets + lastLocalTargets = targets }) ChromeStorageUtils.listen('local', ConfigService.TARGETS_KEY, targets => { - lastTargets = targets + lastLocalTargets = targets + }) + + ChromeStorageUtils.get('sync', ConfigService.TARGETS_KEY, []).then(targets => { + lastSyncTargets = targets + }) + + ChromeStorageUtils.listen('sync', ConfigService.TARGETS_KEY, targets => { + lastSyncTargets = targets }) document.addEventListener('keydown', async event => { const url = UrlUtils.getCurrentUrl() const hotKey = HotKeyService.parse(event) - const hitTargets = lastTargets + const hitTargets = [...lastLocalTargets, ...lastSyncTargets] .filter(target => UrlUtils.checkIsMatchedUrl(target.url, url)) .filter(target => HotKeyService.checkIsSame(hotKey, target.hotKey))