0.2.4 • Published 3 months ago

@global-savings-group/extension-utils v0.2.4

Weekly downloads
-
License
-
Repository
-
Last release
3 months ago

Browser extension utilities

AffiliateNetworkService

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

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);
0.2.4

3 months ago

0.2.1

3 months ago

0.2.3

3 months ago

0.2.2

3 months ago

0.2.0

3 months ago

0.1.0

3 months ago