How to use the @cliqz/adblocker.Request.fromRawDetails function in @cliqz/adblocker

To help you get started, we’ve selected a few @cliqz/adblocker 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 cliqz-oss / adblocker / bench / micro.ts View on Github external
export function benchRequestParsing({
  requests,
}: {
  requests: Array<{ url: string; frameUrl: string; cpt: string }>;
}) {
  for (let i = 0; i < requests.length; i += 1) {
    const { url, frameUrl, cpt } = requests[i];
    Request.fromRawDetails({
      sourceUrl: frameUrl,
      // @ts-ignore
      type: cpt,
      url,
    });
  }
}
github cliqz-oss / adblocker / packages / adblocker-electron / adblocker.ts View on Github external
export function fromElectronDetails({
  id,
  url,
  resourceType,
  referrer,
  webContentsId,
}: Electron.OnHeadersReceivedListenerDetails | Electron.OnBeforeRequestListenerDetails): Request {
  return Request.fromRawDetails({
    requestId: `${id}`,
    sourceUrl: referrer,
    tabId: webContentsId,
    type: (resourceType || 'other') as ElectronRequestType,
    url,
  });
}
github cliqz-oss / adblocker / packages / adblocker-puppeteer / adblocker.ts View on Github external
export function fromPuppeteerDetails(details: puppeteer.Request): Request {
  const frame = details.frame();
  const sourceUrl = frame !== null ? frame.url() : undefined;
  return Request.fromRawDetails({
    requestId: `${details.resourceType()} ${details.url()} ${sourceUrl}`,
    sourceUrl,
    type: details.resourceType(),
    url: details.url(),
  });
}
github cliqz-oss / adblocker / packages / adblocker-webextension / adblocker.ts View on Github external
export function fromWebRequestDetails(
  details: WebRequestBeforeRequestDetails | WebRequestHeadersReceivedDetails,
): Request {
  return Request.fromRawDetails({
    requestId: details.requestId,
    sourceUrl: details.initiator || details.originUrl || details.documentUrl,
    tabId: details.tabId,
    type: details.type,
    url: details.url,
  });
}
github cliqz-oss / adblocker / packages / adblocker-benchmarks / blockers / cliqz-base.js View on Github external
match({ url, frameUrl, type }) {
    return this.engine.match(Request.fromRawDetails({
      url,
      sourceUrl: frameUrl,
      type,
    })).match;
  }
};