# @global-savings-group/extension-utils

> Utilities for browser extensions

Latest version **0.3.0** (published 2024-12-05) · 0 weekly downloads

## Install

```sh
npm install @global-savings-group/extension-utils
pnpm add @global-savings-group/extension-utils
yarn add @global-savings-group/extension-utils
bun add @global-savings-group/extension-utils
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2024-12-05 |
| First published | 2024-03-07 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 17.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Global Savings Group |
| Maintainers | gsg_system, yuriy_khabarov_gsg |

## Links

- npm: https://www.npmjs.com/package/@global-savings-group/extension-utils
- npm.io page: https://npm.io/package/@global-savings-group/extension-utils

## Dependencies (1)

- [@global-savings-group/extension-storage](https://npm.io/package/@global-savings-group/extension-storage.md) 0.2.2

## Recent versions

- 0.3.0 (latest) — 2024-12-05
- 0.2.4 — 2024-03-17
- 0.2.3 — 2024-03-14
- 0.2.2 — 2024-03-14
- 0.2.1 — 2024-03-14
- 0.2.0 — 2024-03-12
- 0.1.0 — 2024-03-07

## README

# Browser extension utilities

### AffiliateNetworkService

```typescript
import { AffiliateNetworkService } from '@global-savings-group/extension-utils';

const affiliateNetworkService = new AffiliateNetworkService();

async function activateAffiliateNetwork() {
  ...
  try {
    await affiliateNetworkService.activate(affiliateLink);
  } catch (e){
    console.error('Cannot activate affiliate network', e);
  }
};

// subscribe to tab update events to close tab after activating affiliate network
chrome.tabs.onUpdated.addListener((tabId: number, changeInfo: chrome.tabs.TabChangeInfo) => {
  if (affiliateNetworkService.isActivationTab(tabId)) {
    affiliateNetworkService.onUpdated(tabId, changeInfo);
    return;
  }
  
  // other code/logic
});

```

### RemoteConfigService

```typescript
import { RemoteConfigService } from '@global-savings-group/extension-utils';

/**
 * {TIMESTAMP} is optional placeholder to be replaced with current timestamp, rounded down to cache duration
 */
const remoteConfigService = new RemoteConfigService('https://api.service.com/config.json?z={TIMESTAMP}');

const config = await remoteConfigService.get(); // returns remote config or undefined
console.log(config);
```

---
_Source: https://npm.io/package/@global-savings-group/extension-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
