How to use the @cliqz/adblocker.makeRequest 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 dot-browser / desktop / src / main / services / web-request.ts View on Github external
async (details: Electron.OnBeforeRequestListenerDetails, callback: any) => {
      const tabId = getTabByWebContentsId(window, details.webContentsId);

      if (engine) {
        const { match, redirect } = engine.match(
          makeRequest({ type: details.resourceType, url: details.url }, parse),
        );

        if (match || redirect) {

          // if(file.get("adblockEnabled") == true) {
            appWindow.webContents.send(`blocked-ad-${tabId}`);

            if (redirect) {
              callback({ redirectURL: redirect });
            } else {
              callback({ cancel: true });
            }
  
            return;
          // }
        }
github wexond / desktop / src / main / services / web-request.ts View on Github external
async (details: Electron.OnBeforeRequestDetails, callback: any) => {
      const tabId = getTabByWebContentsId(window, details.webContentsId);

      if (engine && settings.isShieldToggled) {
        const { match, redirect } = engine.match(
          makeRequest({ type: details.resourceType, url: details.url }, parse),
        );

        if (match || redirect) {
          appWindow.webContents.send(`blocked-ad-${tabId}`);

          if (redirect) {
            callback({ redirectURL: redirect });
          } else {
            callback({ cancel: true });
          }

          return;
        }
      }

      await onBeforeRequest(details, callback);
github wexond / desktop / src / main / services / web-request.ts View on Github external
async (details: Electron.OnHeadersReceivedDetails, callback: any) => {
      updateResponseHeadersWithCSP(
        {
          url: details.url,
          type: details.resourceType as any,
          tabId: getTabByWebContentsId(window, details.webContentsId),
          method: details.method,
          statusCode: details.statusCode,
          statusLine: details.statusLine,
          requestId: details.id.toString(),
          frameId: 0,
          parentFrameId: -1,
          timeStamp: details.timestamp,
        },
        engine.getCSPDirectives(
          makeRequest(
            {
              sourceUrl: details.url,
              type: details.resourceType,
              url: details.url,
            },
            parse,
          ),
        ),
      ),
        await onHeadersReceived(details, callback);
    },
  );
github dot-browser / desktop / src / main / services / web-request.ts View on Github external
async (details: Electron.OnHeadersReceivedListenerDetails, callback: any) => {
      updateResponseHeadersWithCSP(
        {
          url: details.url,
          type: details.resourceType as any,
          tabId: getTabByWebContentsId(window, details.webContentsId),
          method: details.method,
          statusCode: details.statusCode,
          statusLine: details.statusLine,
          requestId: details.id.toString(),
          frameId: 0,
          parentFrameId: -1,
          timeStamp: details.timestamp,
        },
        engine.getCSPDirectives(
          makeRequest(
            {
              sourceUrl: details.url,
              type: details.resourceType,
              url: details.url,
            },
            parse,
          ),
        ),
      ),
        await onHeadersReceived(details, callback);
    },
  );