Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid duplicate injections in MV3 workers #9

Merged
merged 6 commits into from
Feb 1, 2024
Merged

Avoid duplicate injections in MV3 workers #9

merged 6 commits into from
Feb 1, 2024

Conversation

@fregante fregante added the bug label Feb 1, 2024
import progressivelyInjectScript from './inject.js';

if (globalThis.chrome && !navigator.userAgent.includes('Firefox')) {
const {content_scripts: scripts} = chrome.runtime.getManifest();
onExtensionStart.addListener(() => {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core change

const singleInjection = !isPersistentBackgroundPage || scriptableTabs.length <= acceptableInjectionsCount;
// TODO: Non-persistent pages support via chrome.storage.session
// https://github.com/fregante/webext-inject-on-install/issues/4
const singleInjection = !isPersistentBackgroundPage() || scriptableTabs.length <= acceptableInjectionsCount;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by unrelated improvements

@fregante fregante changed the title Only run once on MV3 workers Avoid duplicate injections in MV3 workers Feb 1, 2024
@fregante fregante merged commit 4578f59 into main Feb 1, 2024
13 checks passed
@fregante fregante deleted the mv3-once branch February 1, 2024 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MV3 reinjects on service worker restart
1 participant