How to use the fathom-web.note function in fathom-web

To help you get started, we’ve selected a few fathom-web 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 mozilla / price-tracker / src / extraction / fathom / ruleset_factory.js View on Github external
makeRuleset(coeffs, biases) {
    return ruleset([
      /**
       * Image rules
       */
      // consider all visible img elements
      rule(dom('img').when(this.isVisible.bind(this)), note(() => ({isVisible: true})).type('image')),
      // and divs, which sometimes have CSS background-images
      // TODO: Consider a bonus for <img> tags.
      rule(dom('div').when(fnode =&gt; this.isVisible(fnode) &amp;&amp; this.hasBackgroundImage(fnode)), type('image')),
      // better score the closer the element is to the top of the page
      rule(type('image'), score(this.isAboveTheFold.bind(this)), {name: 'isAboveTheFoldImage'}),
      // better score for larger images
      rule(type('image'), score(this.isBig.bind(this)), {name: 'isBig'}),
      // bonus for non-extreme aspect ratios, to filter out banners or nav elements
      // TODO: Meant to make this a penalty, but it turns out to work as is.
      // Try as a penalty.
      rule(type('image'), score(this.hasSquareAspectRatio.bind(this)), {name: 'hasSquareAspectRatio'}),
      // no background images, even ones that have reasonable aspect ratios
      // TODO: If necessary, also look at parents. I've seen them say
      // "background" in their IDs as well.
      rule(type('image'), score(this.hasBackgroundInID.bind(this)), {name: 'hasBackgroundInID'}),
      // return image element(s) with max score