How to use webext-detect-page - 1 common examples

To help you get started, we’ve selected a few webext-detect-page examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fregante / webext-options-sync / index.ts View on Github external
private async _runMigrations(migrations: Array>): Promise {
		if (migrations.length === 0 || !isBackgroundPage()) {
			return;
		}

		const {installType} = await new Promise(resolve => chrome.management.getSelf(resolve));
		// Chrome doesn't run `onInstalled` when launching the browser with a pre-loaded development extension #25
		if (installType !== 'development') {
			await new Promise(resolve => chrome.runtime.onInstalled.addListener(resolve));
		}

		const options = await this._getAll();
		const initial = JSON.stringify(options);

		this._log('log', 'Found these stored options', {...options});
		this._log('info', 'Will run', migrations.length, migrations.length === 1 ? 'migration' : ' migrations');
		migrations.forEach(migrate => migrate(options, this.defaults));

webext-detect-page

Detects where the current browser extension code is being run. Compatible with Firefox, Chrome and derivates.

MIT
Latest version published 3 months ago

Package Health Score

67 / 100
Full package analysis

Popular webext-detect-page functions