Clipper/joplin-webclipper/content_scripts/Readability.js
function () {
    // Avoid parsing too large documents, as per configuration option
    if (this._maxElemsToParse > 0) {
      var numTags = this._doc.getElementsByTagName("*").length;
      if (numTags > this._maxElemsToParse) {
        throw new Error("Aborting parsing document; " + numTags + " elements found");
      }
    }

    if (typeof this._doc.documentElement.firstElementChild === "undefined") {
      this._getNextNode = this._getNextNodeNoElementProperties;
    }
    // Remove script tags from the document.
    this._removeScripts(this._doc);

    this._prepDocument();

    var metadata = this._getArticleMetadata();
    this._articleTitle = metadata.title;

    var articleContent = this._grabArticle();
    if (!articleContent)
      return null;

    this.log("Grabbed: " + articleContent.innerHTML);

    this._postProcessContent(articleContent);

    // If we haven't found an excerpt in the article's metadata, use the article's
    // first paragraph as the excerpt. This is used for displaying a preview of
    // the article's content.
    if (!metadata.excerpt) {
      var paragraphs = articleContent.getElementsByTagName("p");
      if (paragraphs.length > 0) {
        metadata.excerpt = paragraphs[0].textContent.trim();
      }
    }

    var textContent = articleContent.textContent;
    return {
      title: this._articleTitle,
      byline: metadata.byline || this._articleByline,
      dir: this._articleDir,
      content: articleContent.innerHTML,
      textContent: textContent,
      length: textContent.length,
      excerpt: metadata.excerpt,
    };
  }
function () {
    // Avoid parsing too large documents, as per configuration option
    if (this._maxElemsToParse > 0) {
      var numTags = this._doc.getElementsByTagName("*").length;
      if (numTags > this._maxElemsToParse) {
        throw new Error("Aborting parsing document; " + numTags + " elements found");
      }
    }

    if (typeof this._doc.documentElement.firstElementChild === "undefined") {
      this._getNextNode = this._getNextNodeNoElementProperties;
    }
    // Remove script tags from the document.
    this._removeScripts(this._doc);

    this._prepDocument();

    var metadata = this._getArticleMetadata();
    this._articleTitle = metadata.title;

    var articleContent = this._grabArticle();
    if (!articleContent)
      return null;

    this.log("Grabbed: " + articleContent.innerHTML);

    this._postProcessContent(articleContent);

    // If we haven't found an excerpt in the article's metadata, use the article's
    // first paragraph as the excerpt. This is used for displaying a preview of
    // the article's content.
    if (!metadata.excerpt) {
      var paragraphs = articleContent.getElementsByTagName("p");
      if (paragraphs.length > 0) {
        metadata.excerpt = paragraphs[0].textContent.trim();
      }
    }

    var textContent = articleContent.textContent;
    return {
      title: this._articleTitle,
      byline: metadata.byline || this._articleByline,
      dir: this._articleDir,
      content: articleContent.innerHTML,
      textContent: textContent,
      length: textContent.length,
      excerpt: metadata.excerpt,
    };
  }
function ( ) { // Avoid parsing too large documents, as per configuration option if ( this . _maxElemsToParse > 0 ) { var numTags = this . _doc . getElementsByTagName ( "*" ) . length ; if ( numTags > this . _maxElemsToParse ) { throw new Error ( "Aborting parsing document; " + numTags + " elements found" ) ; } } if ( typeof this . _doc . documentElement . firstElementChild === "undefined" ) { this . _getNextNode = this . _getNextNodeNoElementProperties ; } // Remove script tags from the document. this . _removeScripts ( this . _doc ) ; this . _prepDocument ( ) ; var metadata = this . _getArticleMetadata ( ) ; this . _articleTitle = metadata . title ; var articleContent = this . _grabArticle ( ) ; if ( ! articleContent ) return null ; this . log ( "Grabbed: " + articleContent . innerHTML ) ; this . _postProcessContent ( articleContent ) ; // If we haven't found an excerpt in the article's metadata, use the article's // first paragraph as the excerpt. This is used for displaying a preview of // the article's content. if ( ! metadata . excerpt ) { var paragraphs = articleContent . getElementsByTagName ( "p" ) ; if ( paragraphs . length > 0 ) { metadata . excerpt = paragraphs [ 0 ] . textContent . trim ( ) ; } } var textContent = articleContent . textContent ; return { title : this . _articleTitle , byline : metadata . byline || this . _articleByline , dir : this . _articleDir , content : articleContent . innerHTML , textContent : textContent , length : textContent . length , excerpt : metadata . excerpt , } ; }
Runs readability.

Workflow:
1. Prep the document by removing script tags, css, etc.
2. Build readability's DOM tree.
3. Grab the article content from the current dom tree.
4. Replace the current DOM tree with the new one.
5. Read peacefully.

@return void
Runs readability .