Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@global-savings-group/extension-serp

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@global-savings-group/extension-serp

Browser Extension Search Engine Result Page

  • 2.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
23
increased by109.09%
Maintainers
0
Weekly downloads
 
Created
Source

Usage

Init Serp singleton object in Injection file with callback functions that renders the UI part.

import { Serp, Theme, SearchEngine, BadgeDataSet } from '@global-savings-group/extension-serp'

const renderUI = (
  partnerLink: Element,
  theme: Theme,
  searchEngine: SearchEngine,
  container: HTMLElement,
) => {
  const customDomain = partnerLink.getAttribute("href");

  chrome.runtime.sendMessage(
    {
      type: "check-partner",
      param: { customDomain },
    },
    (partner: Partner) => {
      if (!partner) {
        return;
      }
      if (partner.vouchers.length > 0 || partner.deals.length > 0) {
        const emptyElement = document.createElement("div");
        emptyElement.dataset[BadgeDataSet.key] = BadgeDataSet.value;
        render(
          SERPBadge({
            vouchersCount: partner.vouchers.length,
            theme,
            searchEngine,
          }),
          emptyElement
        );
        Serp.insertElementTo(container, emptyElement);
      }
    }
  );
};

const sendAnalytics = (partnerName: string): void => {
  sendMessage(MESSAGE_TYPE.SEND_GA, {
    name: 'view_serp',
    params: {
      retailer_name: partnerName,
    },
  });
};

const EXTENSION_NAME = 'Extension Name';

const getSERPSettings = () =>
  chrome.runtime.sendMessage({ type: "get-serp-settings" });

getSERPSettings().then((SERPSettings: iSERPSettings) => {
  if (SERPSettings.enabled) {
    Serp.init(renderBadgePartner, sendAnalytics, EXTENSION_NAME);
  }
});

FAQs

Package last updated on 16 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc