How to use the matcher.defaultMatcher.matchesAny function in matcher

To help you get started, we’ve selected a few matcher 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 turnkeylinux / common / overlays / ninjux / home / user / .config / chromium / Default / Extensions / cfhdojbkjhnklbpkdaibdccddilifddb / 1.6.1_0 / background.js View on Github external
function isWhitelisted(url, parentUrl, type)
{
  // Ignore fragment identifier
  var index = url.indexOf("#");
  if (index >= 0)
    url = url.substring(0, index);

  var result = defaultMatcher.matchesAny(url, type || "DOCUMENT", extractHostFromURL(parentUrl || url), false);
  return (result instanceof WhitelistFilter ? result : null);
}
github turnkeylinux / common / overlays / ninjux / home / user / .config / chromium / Default / Extensions / cfhdojbkjhnklbpkdaibdccddilifddb / 1.6.1_0 / background.js View on Github external
if (sender.tab)
      {
        tabId = sender.tab.id;
        frameId = getFrameId(tabId, request.documentUrl);
      }

      if (isFrameWhitelisted(tabId, frameId, "DOCUMENT"))
      {
        sendResponse(false);
        break;
      }

      var requestHost = extractHostFromURL(request.url);
      var documentHost = extractHostFromURL(request.documentUrl);
      var thirdParty = isThirdParty(requestHost, documentHost);
      var filter = defaultMatcher.matchesAny(request.url, request.type, documentHost, thirdParty);
      if (filter instanceof BlockingFilter)
      {
        var collapse = filter.collapse;
        if (collapse == null)
          collapse = (localStorage.hidePlaceholders != "false");
        sendResponse(collapse);
      }
      else
        sendResponse(false);
      break;
    case "get-domain-enabled-state":
      // Returns whether this domain is in the exclusion list.
      // The page action popup asks us this.
      if(sender.tab)
      {
        sendResponse({enabled: !isWhitelisted(sender.tab.url)});
github adblockplus / adblockpluschrome / background.js View on Github external
}
      }

      sendResponse(selectors);
      break;
    case "should-collapse":
      if (isFrameWhitelisted(sender.page, sender.frame, "DOCUMENT"))
      {
        sendResponse(false);
        break;
      }

      var requestHost = extractHostFromURL(msg.url);
      var documentHost = extractHostFromFrame(sender.frame);
      var thirdParty = isThirdParty(requestHost, documentHost);
      var filter = defaultMatcher.matchesAny(msg.url, msg.mediatype, documentHost, thirdParty);
      if (filter instanceof BlockingFilter)
      {
        var collapse = filter.collapse;
        if (collapse == null)
          collapse = Prefs.hidePlaceholders;
        sendResponse(collapse);
      }
      else
        sendResponse(false);
      break;
    case "get-domain-enabled-state":
      // Returns whether this domain is in the exclusion list.
      // The browser action popup asks us this.
      if(sender.page)
      {
        sendResponse({enabled: !isWhitelisted(sender.page.url)});
github adblockplus / adblockplus / lib / contentPolicy.js View on Github external
return response(true, false);
        else
          nogeneric = true;
      }
    }

    let match = null;
    let wndLocation = frames[0].location;
    let docDomain = getHostname(wndLocation);
    let [sitekey, sitekeyFrame] = getSitekey(frames);

    let thirdParty = isThirdParty(location, docDomain);
    let collapse = false;
    if (!match && Prefs.enabled && RegExpFilter.typeMap.hasOwnProperty(contentType))
    {
      match = defaultMatcher.matchesAny(location, RegExpFilter.typeMap[contentType],
                                        docDomain, thirdParty, sitekey, nogeneric);
      if (match instanceof BlockingFilter && !this.nonVisualTypes.has(contentType))
        collapse = (match.collapse != null ? match.collapse : !Prefs.fastcollapse);
    }
    addHit(null, contentType, docDomain, thirdParty, location, match);

    return response(!match || match instanceof WhitelistFilter, collapse);
  },
github adblockplus / adblockplus / lib / contentPolicy.js View on Github external
let [sitekey, sitekeyFrame] = getSitekey(frames);
    let nogenericHit = null;

    let typeMap = RegExpFilter.typeMap.DOCUMENT;
    if (isElemHide)
      typeMap = typeMap | RegExpFilter.typeMap.ELEMHIDE;
    let genericType = (isElemHide ? "GENERICHIDE" : "GENERICBLOCK");

    for (let i = 0; i < frames.length; i++)
    {
      let frame = frames[i];
      let wndLocation = frame.location;
      let parentWndLocation = frames[Math.min(i + 1, frames.length - 1)].location;
      let parentDocDomain = getHostname(parentWndLocation);

      let match = defaultMatcher.matchesAny(wndLocation, typeMap, parentDocDomain, false, sitekey);
      if (match instanceof WhitelistFilter)
      {
        let whitelistType = (match.contentType & RegExpFilter.typeMap.DOCUMENT) ? "DOCUMENT" : "ELEMHIDE";
        return [i, whitelistType, parentDocDomain, false, wndLocation, match];
      }

      if (!nogenericHit)
      {
        match = defaultMatcher.matchesAny(wndLocation,
            RegExpFilter.typeMap[genericType], parentDocDomain, false, sitekey);
        if (match instanceof WhitelistFilter)
          nogenericHit = [i, genericType, parentDocDomain, false, wndLocation, match];
      }

      if (frame == sitekeyFrame)
        [sitekey, sitekeyFrame] = getSitekey(frames.slice(i + 1));
github adblockplus / adblockpluschrome / lib / popupBlocker.js View on Github external
function checkPotentialPopup(tabId, popup)
{
  let urlObj = new URL(popup.url || "about:blank");
  let urlString = stringifyURL(urlObj);
  let documentHost = extractHostFromFrame(popup.sourceFrame);
  let thirdParty = isThirdParty(urlObj, documentHost);

  let specificOnly = !!checkWhitelisted(
    popup.sourcePage, popup.sourceFrame,
    RegExpFilter.typeMap.GENERICBLOCK
  );

  let filter = defaultMatcher.matchesAny(
    urlString, RegExpFilter.typeMap.POPUP,
    documentHost, thirdParty, null, specificOnly
  );

  if (filter instanceof BlockingFilter)
    chrome.tabs.remove(tabId);

  logRequest(
    popup.sourcePage, urlString, "POPUP",
    documentHost, thirdParty, null,
    specificOnly, filter
  );
}
github adblockplus / adblockplus / lib / contentPolicy.js View on Github external
{
      let frame = frames[i];
      let wndLocation = frame.location;
      let parentWndLocation = frames[Math.min(i + 1, frames.length - 1)].location;
      let parentDocDomain = getHostname(parentWndLocation);

      let match = defaultMatcher.matchesAny(wndLocation, typeMap, parentDocDomain, false, sitekey);
      if (match instanceof WhitelistFilter)
      {
        let whitelistType = (match.contentType & RegExpFilter.typeMap.DOCUMENT) ? "DOCUMENT" : "ELEMHIDE";
        return [i, whitelistType, parentDocDomain, false, wndLocation, match];
      }

      if (!nogenericHit)
      {
        match = defaultMatcher.matchesAny(wndLocation,
            RegExpFilter.typeMap[genericType], parentDocDomain, false, sitekey);
        if (match instanceof WhitelistFilter)
          nogenericHit = [i, genericType, parentDocDomain, false, wndLocation, match];
      }

      if (frame == sitekeyFrame)
        [sitekey, sitekeyFrame] = getSitekey(frames.slice(i + 1));
    }

    return nogenericHit;
  },