diff --git a/src/background/services/monetization.ts b/src/background/services/monetization.ts index 617c86ab..de8cf12f 100644 --- a/src/background/services/monetization.ts +++ b/src/background/services/monetization.ts @@ -63,7 +63,7 @@ export class MonetizationService { ) return } - const { tabId, frameId, url } = getSender(sender) + const { tabId, frameId, url, isPrerendering } = getSender(sender) const sessions = this.tabState.getSessions(tabId) const replacedSessions = new Set() @@ -95,6 +95,8 @@ export class MonetizationService { sessions.set(requestId, session) }) + if (isPrerendering) return; + this.events.emit('monetization.state_update', tabId) const sessionsArr = this.tabState.getEnabledSessions(tabId) diff --git a/src/background/utils.ts b/src/background/utils.ts index 1a378abf..11bf7296 100644 --- a/src/background/utils.ts +++ b/src/background/utils.ts @@ -88,8 +88,10 @@ export const getTab = (sender: Runtime.MessageSender): Tabs.Tab => { export const getSender = (sender: Runtime.MessageSender) => { const tabId = getTabId(sender) const frameId = notNullOrUndef(sender.frameId, 'sender.frameId') + const isPrerendering = (sender as any).documentLifecycle === 'prerender' && sender.frameId !== 0; - return { tabId, frameId, url: sender.url } + + return { tabId, frameId, url: sender.url, isPrerendering } } export const computeRate = (rate: string, sessionsCount: number): AmountValue =>