Clipper/joplin-webclipper/content_scripts/Readability.js
function() {
    var metadata = {};
    var values = {};
    var metaElements = this._doc.getElementsByTagName("meta");

    // Match "description", or Twitter's "twitter:description" (Cards)
    // in name attribute.
    var namePattern = /^\s*((twitter)\s*:\s*)?(description|title)\s*$/gi;

    // Match Facebook's Open Graph title & description properties.
    var propertyPattern = /^\s*og\s*:\s*(description|title)\s*$/gi;

    // Find description tags.
    this._forEachNode(metaElements, function(element) {
      var elementName = element.getAttribute("name");
      var elementProperty = element.getAttribute("property");

      if ([elementName, elementProperty].indexOf("author") !== -1) {
        metadata.byline = element.getAttribute("content");
        return;
      }

      var name = null;
      if (namePattern.test(elementName)) {
        name = elementName;
      } else if (propertyPattern.test(elementProperty)) {
        name = elementProperty;
      }

      if (name) {
        var content = element.getAttribute("content");
        if (content) {
          // Convert to lowercase and remove any whitespace
          // so we can match below.
          name = name.toLowerCase().replace(/\s/g, '');
          values[name] = content.trim();
        }
      }
    });

    if ("description" in values) {
      metadata.excerpt = values["description"];
    } else if ("og:description" in values) {
      // Use facebook open graph description.
      metadata.excerpt = values["og:description"];
    } else if ("twitter:description" in values) {
      // Use twitter cards description.
      metadata.excerpt = values["twitter:description"];
    }

    metadata.title = this._getArticleTitle();
    if (!metadata.title) {
      if ("og:title" in values) {
        // Use facebook open graph title.
        metadata.title = values["og:title"];
      } else if ("twitter:title" in values) {
        // Use twitter cards title.
        metadata.title = values["twitter:title"];
      }
    }

    return metadata;
  }
function() {
    var metadata = {};
    var values = {};
    var metaElements = this._doc.getElementsByTagName("meta");

    // Match "description", or Twitter's "twitter:description" (Cards)
    // in name attribute.
    var namePattern = /^\s*((twitter)\s*:\s*)?(description|title)\s*$/gi;

    // Match Facebook's Open Graph title & description properties.
    var propertyPattern = /^\s*og\s*:\s*(description|title)\s*$/gi;

    // Find description tags.
    this._forEachNode(metaElements, function(element) {
      var elementName = element.getAttribute("name");
      var elementProperty = element.getAttribute("property");

      if ([elementName, elementProperty].indexOf("author") !== -1) {
        metadata.byline = element.getAttribute("content");
        return;
      }

      var name = null;
      if (namePattern.test(elementName)) {
        name = elementName;
      } else if (propertyPattern.test(elementProperty)) {
        name = elementProperty;
      }

      if (name) {
        var content = element.getAttribute("content");
        if (content) {
          // Convert to lowercase and remove any whitespace
          // so we can match below.
          name = name.toLowerCase().replace(/\s/g, '');
          values[name] = content.trim();
        }
      }
    });

    if ("description" in values) {
      metadata.excerpt = values["description"];
    } else if ("og:description" in values) {
      // Use facebook open graph description.
      metadata.excerpt = values["og:description"];
    } else if ("twitter:description" in values) {
      // Use twitter cards description.
      metadata.excerpt = values["twitter:description"];
    }

    metadata.title = this._getArticleTitle();
    if (!metadata.title) {
      if ("og:title" in values) {
        // Use facebook open graph title.
        metadata.title = values["og:title"];
      } else if ("twitter:title" in values) {
        // Use twitter cards title.
        metadata.title = values["twitter:title"];
      }
    }

    return metadata;
  }
function ( ) { var metadata = { } ; var values = { } ; var metaElements = this . _doc . getElementsByTagName ( "meta" ) ; // Match "description", or Twitter's "twitter:description" (Cards) // in name attribute. var namePattern = / ^\s*((twitter)\s*:\s*)?(description|title)\s*$ / gi ; // Match Facebook's Open Graph title & description properties. var propertyPattern = / ^\s*og\s*:\s*(description|title)\s*$ / gi ; // Find description tags. this . _forEachNode ( metaElements , function ( element ) { var elementName = element . getAttribute ( "name" ) ; var elementProperty = element . getAttribute ( "property" ) ; if ( [ elementName , elementProperty ] . indexOf ( "author" ) !== - 1 ) { metadata . byline = element . getAttribute ( "content" ) ; return ; } var name = null ; if ( namePattern . test ( elementName ) ) { name = elementName ; } else if ( propertyPattern . test ( elementProperty ) ) { name = elementProperty ; } if ( name ) { var content = element . getAttribute ( "content" ) ; if ( content ) { // Convert to lowercase and remove any whitespace // so we can match below. name = name . toLowerCase ( ) . replace ( / \s / g , '' ) ; values [ name ] = content . trim ( ) ; } } } ) ; if ( "description" in values ) { metadata . excerpt = values [ "description" ] ; } else if ( "og:description" in values ) { // Use facebook open graph description. metadata . excerpt = values [ "og:description" ] ; } else if ( "twitter:description" in values ) { // Use twitter cards description. metadata . excerpt = values [ "twitter:description" ] ; } metadata . title = this . _getArticleTitle ( ) ; if ( ! metadata . title ) { if ( "og:title" in values ) { // Use facebook open graph title. metadata . title = values [ "og:title" ] ; } else if ( "twitter:title" in values ) { // Use twitter cards title. metadata . title = values [ "twitter:title" ] ; } } return metadata ; }
Attempts to get excerpt and byline metadata for the article.

@return Object with optional "excerpt" and "byline" properties
Attempts to get excerpt and byline metadata for the article .