/* eslint-env es6:false */ /* globals exports */ /* * DO NOT MODIFY THIS FILE DIRECTLY! * * This is a shared library that is maintained in an external repo: * https://github.com/mozilla/readability */ /* * Copyright (c) 2010 Arc90 Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * This code is heavily based on Arc90's readability.js (1.7.1) script * available at: http://code.google.com/p/arc90labs-readability */ var REGEXPS = { // NOTE: These two regular expressions are duplicated in // Readability.js. Please keep both copies in sync. unlikelyCandidates: /-ad-|banner|breadcrumbs|combx|comment|community|cover-wrap|disqus|extra|foot|header|legends|menu|related|remark|replies|rss|shoutbox|sidebar|skyscraper|social|sponsor|supplemental|ad-break|agegate|pagination|pager|popup|yom-remote/i, okMaybeItsACandidate: /and|article|body|column|main|shadow/i, }; function isNodeVisible(node) { // Have to null-check node.style to deal with SVG and MathML nodes. return (!node.style || node.style.display != "none") && !node.hasAttribute("hidden"); } /** * Decides whether or not the document is reader-able without parsing the whole thing. * * @return boolean Whether or not we suspect Readability.parse() will suceeed at returning an article object. */ function isProbablyReaderable(doc, isVisible) { if (!isVisible) { isVisible = isNodeVisible; } var nodes = doc.querySelectorAll("p, pre"); // Get