Skip to content

Commit

Permalink
AG-27583 fix multiple injection to the pages
Browse files Browse the repository at this point in the history
  • Loading branch information
maximtop committed Nov 18, 2024
1 parent 1e63b47 commit 8cf7d96
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { MAIN_FRAME_ID } from '../../common/constants';
import { CosmeticApi } from '../background/cosmetic-api';
import { CosmeticFrameProcessor } from '../background/cosmetic-frame-processor';
import { ContentType } from '../../common';
import { appContext } from '../background/app-context';

/**
* Injects cosmetic rules into tabs, opened before app initialization.
Expand Down Expand Up @@ -82,6 +83,14 @@ export class TabsCosmeticInjector {
documentId,
});

/**
* This condition prevents applying cosmetic rules to the tab multiple times.
* Applying them once after the extension's initialization is sufficient.
*/
if (appContext.startTimeMs && (currentTime - appContext.startTimeMs) > 10000) {
return;
}

// Note: this is an async function, but we will not await it because
// events do not support async listeners.
Promise.all([
Expand Down

0 comments on commit 8cf7d96

Please sign in to comment.