(function(scripts,callback,errorback){if(typeof errorback!='function')errorback=function(url){alert('jsloader load error: '+url)};var cssRegexp=/.css$/;var load=function(url){if(cssRegexp.test(url)){var link=document.createElement('link');link.href=url;link.type='text/css';link.rel='stylesheet';(document.getElementsByTagName('head')[0]||document.body).appendChild(link);if(scripts.length){load(scripts.shift())}else{callback()}}else{var script=document.createElement('script');script.type='text/javascript';script.charset='utf-8';var current_callback;if(scripts.length){var u=scripts.shift();current_callback=function(){load(u)}}else{current_callback=callback}if(window.ActiveXObject){script.onreadystatechange=function(){if(script.readyState=='complete'||script.readyState=='loaded'){current_callback()}}}else{script.onload=current_callback;script.onerror=function(){errorback(url)}}script.src=url;document.body.appendChild(script)}};load(scripts.shift())})(["https://raw.githubusercontent.com/mozilla/readability/master/Readability.js"],(function(){
/*
* 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.
*/
function Readability(doc,options){if(options&&options.documentElement){doc=options;options=arguments[2]}else if(!doc||!doc.documentElement){throw new Error("First argument to Readability constructor should be a document object.")}options=options||{};this._doc=doc;this._docJSDOMParser=this._doc.firstChild.__JSDOMParser__;this._articleTitle=null;this._articleByline=null;this._articleDir=null;this._articleSiteName=null;this._attempts=[];this._debug=!!options.debug;this._maxElemsToParse=options.maxElemsToParse||this.DEFAULT_MAX_ELEMS_TO_PARSE;this._nbTopCandidates=options.nbTopCandidates||this.DEFAULT_N_TOP_CANDIDATES;this._charThreshold=options.charThreshold||this.DEFAULT_CHAR_THRESHOLD;this._classesToPreserve=this.CLASSES_TO_PRESERVE.concat(options.classesToPreserve||[]);this._keepClasses=!!options.keepClasses;this._serializer=options.serializer||function(el){return el.innerHTML};this._disableJSONLD=!!options.disableJSONLD;this._flags=this.FLAG_STRIP_UNLIKELYS|this.FLAG_WEIGHT_CLASSES|this.FLAG_CLEAN_CONDITIONALLY;if(this._debug){let logNode=function(node){if(node.nodeType==node.TEXT_NODE){return`${node.nodeName} ("${node.textContent}")`}let attrPairs=Array.from(node.attributes||[],(function(attr){return`${attr.name}="${attr.value}"`})).join(" ");return`<${node.localName} ${attrPairs}>`};this.log=function(){if(typeof dump!=="undefined"){var msg=Array.prototype.map.call(arguments,(function(x){return x&&x.nodeName?logNode(x):x})).join(" ");dump("Reader: (Readability) "+msg+"\n")}else if(typeof console!=="undefined"){let args=Array.from(arguments,(arg=>{if(arg&&arg.nodeType==this.ELEMENT_NODE){return logNode(arg)}return arg}));args.unshift("Reader: (Readability)");console.log.apply(console,args)}}}else{this.log=function(){}}}Readability.prototype={FLAG_STRIP_UNLIKELYS:1,FLAG_WEIGHT_CLASSES:2,FLAG_CLEAN_CONDITIONALLY:4,ELEMENT_NODE:1,TEXT_NODE:3,DEFAULT_MAX_ELEMS_TO_PARSE:0,DEFAULT_N_TOP_CANDIDATES:5,DEFAULT_TAGS_TO_SCORE:"section,h2,h3,h4,h5,h6,p,td,pre".toUpperCase().split(","),DEFAULT_CHAR_THRESHOLD:500,REGEXPS:{unlikelyCandidates:/-ad-|ai2html|banner|breadcrumbs|combx|comment|community|cover-wrap|disqus|extra|footer|gdpr|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|content|main|shadow/i,positive:/article|body|content|entry|hentry|h-entry|main|page|pagination|post|text|blog|story/i,negative:/-ad-|hidden|^hid$| hid$| hid |^hid |banner|combx|comment|com-|contact|foot|footer|footnote|gdpr|masthead|media|meta|outbrain|promo|related|scroll|share|shoutbox|sidebar|skyscraper|sponsor|shopping|tags|tool|widget/i,extraneous:/print|archive|comment|discuss|e[\-]?mail|share|reply|all|login|sign|single|utility/i,byline:/byline|author|dateline|writtenby|p-author/i,replaceFonts:/<(\/?)font[^>]*>/gi,normalize:/\s{2,}/g,videos:/\/\/(www\.)?((dailymotion|youtube|youtube-nocookie|player\.vimeo|v\.qq)\.com|(archive|upload\.wikimedia)\.org|player\.twitch\.tv)/i,shareElements:/(\b|_)(share|sharedaddy)(\b|_)/i,nextLink:/(next|weiter|continue|>([^\|]|$)|»([^\|]|$))/i,prevLink:/(prev|earl|old|new|<|«)/i,tokenize:/\W+/g,whitespace:/^\s*$/,hasContent:/\S$/,hashUrl:/^#.+/,srcsetUrl:/(\S+)(\s+[\d.]+[xw])?(\s*(?:,|$))/g,b64DataUrl:/^data:\s*([^\s;,]+)\s*;\s*base64\s*,/i,jsonLdArticleTypes:/^Article|AdvertiserContentArticle|NewsArticle|AnalysisNewsArticle|AskPublicNewsArticle|BackgroundNewsArticle|OpinionNewsArticle|ReportageNewsArticle|ReviewNewsArticle|Report|SatiricalArticle|ScholarlyArticle|MedicalScholarlyArticle|SocialMediaPosting|BlogPosting|LiveBlogPosting|DiscussionForumPosting|TechArticle|APIReference$/},UNLIKELY_ROLES:["menu","menubar","complementary","navigation","alert","alertdialog","dialog"],DIV_TO_P_ELEMS:new Set(["BLOCKQUOTE","DL","DIV","IMG","OL","P","PRE","TABLE","UL"]),ALTER_TO_DIV_EXCEPTIONS:["DIV","ARTICLE","SECTION","P"],PRESENTATIONAL_ATTRIBUTES:["align","background","bgcolor","border","cellpadding","cellspacing","frame","hspace","rules","style","valign","vspace"],DEPRECATED_SIZE_ATTRIBUTE_ELEMS:["TABLE","TH","TD","HR","PRE"],PHRASING_ELEMS:["ABBR","AUDIO","B","BDO","BR","BUTTON","CITE","CODE","DATA","DATALIST","DFN","EM","EMBED","I","IMG","INPUT","KBD","LABEL","MARK","MATH","METER","NOSCRIPT","OBJECT","OUTPUT","PROGRESS","Q","RUBY","SAMP","SCRIPT","SELECT","SMALL","SPAN","STRONG","SUB","SUP","TEXTAREA","TIME","VAR","WBR"],CLASSES_TO_PRESERVE:["page"],HTML_ESCAPE_MAP:{lt:"<",gt:">",amp:"&",quot:'"',apos:"'"},_postProcessContent:function(articleContent){this._fixRelativeUris(articleContent);this._simplifyNestedElements(articleContent);if(!this._keepClasses){this._cleanClasses(articleContent)}},_removeNodes:function(nodeList,filterFn){if(this._docJSDOMParser&&nodeList._isLiveNodeList){throw new Error("Do not pass live node lists to _removeNodes")}for(var i=nodeList.length-1;i>=0;i--){var node=nodeList[i];var parentNode=node.parentNode;if(parentNode){if(!filterFn||filterFn.call(this,node,i,nodeList)){parentNode.removeChild(node)}}}},_replaceNodeTags:function(nodeList,newTagName){if(this._docJSDOMParser&&nodeList._isLiveNodeList){throw new Error("Do not pass live node lists to _replaceNodeTags")}for(const node of nodeList){this._setNodeTag(node,newTagName)}},_forEachNode:function(nodeList,fn){Array.prototype.forEach.call(nodeList,fn,this)},_findNode:function(nodeList,fn){return Array.prototype.find.call(nodeList,fn,this)},_someNode:function(nodeList,fn){return Array.prototype.some.call(nodeList,fn,this)},_everyNode:function(nodeList,fn){return Array.prototype.every.call(nodeList,fn,this)},_concatNodeLists:function(){var slice=Array.prototype.slice;var args=slice.call(arguments);var nodeLists=args.map((function(list){return slice.call(list)}));return Array.prototype.concat.apply([],nodeLists)},_getAllNodesWithTag:function(node,tagNames){if(node.querySelectorAll){return node.querySelectorAll(tagNames.join(","))}return[].concat.apply([],tagNames.map((function(tag){var collection=node.getElementsByTagName(tag);return Array.isArray(collection)?collection:Array.from(collection)})))},_cleanClasses:function(node){var classesToPreserve=this._classesToPreserve;var className=(node.getAttribute("class")||"").split(/\s+/).filter((function(cls){return classesToPreserve.indexOf(cls)!=-1})).join(" ");if(className){node.setAttribute("class",className)}else{node.removeAttribute("class")}for(node=node.firstElementChild;node;node=node.nextElementSibling){this._cleanClasses(node)}},_fixRelativeUris:function(articleContent){var baseURI=this._doc.baseURI;var documentURI=this._doc.documentURI;function toAbsoluteURI(uri){if(baseURI==documentURI&&uri.charAt(0)=="#"){return uri}try{return new URL(uri,baseURI).href}catch(ex){}return uri}var links=this._getAllNodesWithTag(articleContent,["a"]);this._forEachNode(links,(function(link){var href=link.getAttribute("href");if(href){if(href.indexOf("javascript:")===0){if(link.childNodes.length===1&&link.childNodes[0].nodeType===this.TEXT_NODE){var text=this._doc.createTextNode(link.textContent);link.parentNode.replaceChild(text,link)}else{var container=this._doc.createElement("span");while(link.firstChild){container.appendChild(link.firstChild)}link.parentNode.replaceChild(container,link)}}else{link.setAttribute("href",toAbsoluteURI(href))}}}));var medias=this._getAllNodesWithTag(articleContent,["img","picture","figure","video","audio","source"]);this._forEachNode(medias,(function(media){var src=media.getAttribute("src");var poster=media.getAttribute("poster");var srcset=media.getAttribute("srcset");if(src){media.setAttribute("src",toAbsoluteURI(src))}if(poster){media.setAttribute("poster",toAbsoluteURI(poster))}if(srcset){var newSrcset=srcset.replace(this.REGEXPS.srcsetUrl,(function(_,p1,p2,p3){return toAbsoluteURI(p1)+(p2||"")+p3}));media.setAttribute("srcset",newSrcset)}}))},_simplifyNestedElements:function(articleContent){var node=articleContent;while(node){if(node.parentNode&&["DIV","SECTION"].includes(node.tagName)&&!(node.id&&node.id.startsWith("readability"))){if(this._isElementWithoutContent(node)){node=this._removeAndGetNext(node);continue}else if(this._hasSingleTagInsideElement(node,"DIV")||this._hasSingleTagInsideElement(node,"SECTION")){var child=node.children[0];for(var i=0;i»] /.test(curTitle)){titleHadHierarchicalSeparators=/ [\\\/>»] /.test(curTitle);curTitle=origTitle.replace(/(.*)[\|\-\\\/>»] .*/gi,"$1");if(wordCount(curTitle)<3)curTitle=origTitle.replace(/[^\|\-\\\/>»]*[\|\-\\\/>»](.*)/gi,"$1")}else if(curTitle.indexOf(": ")!==-1){var headings=this._concatNodeLists(doc.getElementsByTagName("h1"),doc.getElementsByTagName("h2"));var trimmedTitle=curTitle.trim();var match=this._someNode(headings,(function(heading){return heading.textContent.trim()===trimmedTitle}));if(!match){curTitle=origTitle.substring(origTitle.lastIndexOf(":")+1);if(wordCount(curTitle)<3){curTitle=origTitle.substring(origTitle.indexOf(":")+1)}else if(wordCount(origTitle.substr(0,origTitle.indexOf(":")))>5){curTitle=origTitle}}}else if(curTitle.length>150||curTitle.length<15){var hOnes=doc.getElementsByTagName("h1");if(hOnes.length===1)curTitle=this._getInnerText(hOnes[0])}curTitle=curTitle.trim().replace(this.REGEXPS.normalize," ");var curTitleWordCount=wordCount(curTitle);if(curTitleWordCount<=4&&(!titleHadHierarchicalSeparators||curTitleWordCount!=wordCount(origTitle.replace(/[\|\-\\\/>»]+/g,""))-1)){curTitle=origTitle}return curTitle},_prepDocument:function(){var doc=this._doc;this._removeNodes(this._getAllNodesWithTag(doc,["style"]));if(doc.body){this._replaceBrs(doc.body)}this._replaceNodeTags(this._getAllNodesWithTag(doc,["font"]),"SPAN")},_nextNode:function(node){var next=node;while(next&&next.nodeType!=this.ELEMENT_NODE&&this.REGEXPS.whitespace.test(next.textContent)){next=next.nextSibling}return next},_replaceBrs:function(elem){this._forEachNode(this._getAllNodesWithTag(elem,["br"]),(function(br){var next=br.nextSibling;var replaced=false;while((next=this._nextNode(next))&&next.tagName=="BR"){replaced=true;var brSibling=next.nextSibling;next.parentNode.removeChild(next);next=brSibling}if(replaced){var p=this._doc.createElement("p");br.parentNode.replaceChild(p,br);next=p.nextSibling;while(next){if(next.tagName=="BR"){var nextElem=this._nextNode(next.nextSibling);if(nextElem&&nextElem.tagName=="BR")break}if(!this._isPhrasingContent(next))break;var sibling=next.nextSibling;p.appendChild(next);next=sibling}while(p.lastChild&&this._isWhitespace(p.lastChild)){p.removeChild(p.lastChild)}if(p.parentNode.tagName==="P")this._setNodeTag(p.parentNode,"DIV")}}))},_setNodeTag:function(node,tag){this.log("_setNodeTag",node,tag);if(this._docJSDOMParser){node.localName=tag.toLowerCase();node.tagName=tag.toUpperCase();return node}var replacement=node.ownerDocument.createElement(tag);while(node.firstChild){replacement.appendChild(node.firstChild)}node.parentNode.replaceChild(replacement,node);if(node.readability)replacement.readability=node.readability;for(var i=0;i!tokensA.includes(token)));var distanceB=uniqTokensB.join(" ").length/tokensB.join(" ").length;return 1-distanceB},_checkByline:function(node,matchString){if(this._articleByline){return false}if(node.getAttribute!==undefined){var rel=node.getAttribute("rel");var itemprop=node.getAttribute("itemprop")}if((rel==="author"||itemprop&&itemprop.indexOf("author")!==-1||this.REGEXPS.byline.test(matchString))&&this._isValidByline(node.textContent)){this._articleByline=node.textContent.trim();return true}return false},_getNodeAncestors:function(node,maxDepth){maxDepth=maxDepth||0;var i=0,ancestors=[];while(node.parentNode){ancestors.push(node.parentNode);if(maxDepth&&++i===maxDepth)break;node=node.parentNode}return ancestors},_grabArticle:function(page){this.log("**** grabArticle ****");var doc=this._doc;var isPaging=page!==null;page=page?page:this._doc.body;if(!page){this.log("No body found in document. Abort.");return null}var pageCacheHtml=page.innerHTML;while(true){this.log("Starting grabArticle loop");var stripUnlikelyCandidates=this._flagIsActive(this.FLAG_STRIP_UNLIKELYS);var elementsToScore=[];var node=this._doc.documentElement;let shouldRemoveTitleHeader=true;while(node){if(node.tagName==="HTML"){this._articleLang=node.getAttribute("lang")}var matchString=node.className+" "+node.id;if(!this._isProbablyVisible(node)){this.log("Removing hidden node - "+matchString);node=this._removeAndGetNext(node);continue}if(this._checkByline(node,matchString)){node=this._removeAndGetNext(node);continue}if(shouldRemoveTitleHeader&&this._headerDuplicatesTitle(node)){this.log("Removing header: ",node.textContent.trim(),this._articleTitle.trim());shouldRemoveTitleHeader=false;node=this._removeAndGetNext(node);continue}if(stripUnlikelyCandidates){if(this.REGEXPS.unlikelyCandidates.test(matchString)&&!this.REGEXPS.okMaybeItsACandidate.test(matchString)&&!this._hasAncestorTag(node,"table")&&!this._hasAncestorTag(node,"code")&&node.tagName!=="BODY"&&node.tagName!=="A"){this.log("Removing unlikely candidate - "+matchString);node=this._removeAndGetNext(node);continue}if(this.UNLIKELY_ROLES.includes(node.getAttribute("role"))){this.log("Removing content with role "+node.getAttribute("role")+" - "+matchString);node=this._removeAndGetNext(node);continue}}if((node.tagName==="DIV"||node.tagName==="SECTION"||node.tagName==="HEADER"||node.tagName==="H1"||node.tagName==="H2"||node.tagName==="H3"||node.tagName==="H4"||node.tagName==="H5"||node.tagName==="H6")&&this._isElementWithoutContent(node)){node=this._removeAndGetNext(node);continue}if(this.DEFAULT_TAGS_TO_SCORE.indexOf(node.tagName)!==-1){elementsToScore.push(node)}if(node.tagName==="DIV"){var p=null;var childNode=node.firstChild;while(childNode){var nextSibling=childNode.nextSibling;if(this._isPhrasingContent(childNode)){if(p!==null){p.appendChild(childNode)}else if(!this._isWhitespace(childNode)){p=doc.createElement("p");node.replaceChild(p,childNode);p.appendChild(childNode)}}else if(p!==null){while(p.lastChild&&this._isWhitespace(p.lastChild)){p.removeChild(p.lastChild)}p=null}childNode=nextSibling}if(this._hasSingleTagInsideElement(node,"P")&&this._getLinkDensity(node)<.25){var newNode=node.children[0];node.parentNode.replaceChild(newNode,node);node=newNode;elementsToScore.push(node)}else if(!this._hasChildBlockElement(node)){node=this._setNodeTag(node,"P");elementsToScore.push(node)}}node=this._getNextNode(node)}var candidates=[];this._forEachNode(elementsToScore,(function(elementToScore){if(!elementToScore.parentNode||typeof elementToScore.parentNode.tagName==="undefined")return;var innerText=this._getInnerText(elementToScore);if(innerText.length<25)return;var ancestors=this._getNodeAncestors(elementToScore,5);if(ancestors.length===0)return;var contentScore=0;contentScore+=1;contentScore+=innerText.split(",").length;contentScore+=Math.min(Math.floor(innerText.length/100),3);this._forEachNode(ancestors,(function(ancestor,level){if(!ancestor.tagName||!ancestor.parentNode||typeof ancestor.parentNode.tagName==="undefined")return;if(typeof ancestor.readability==="undefined"){this._initializeNode(ancestor);candidates.push(ancestor)}if(level===0)var scoreDivider=1;else if(level===1)scoreDivider=2;else scoreDivider=level*3;ancestor.readability.contentScore+=contentScore/scoreDivider}))}));var topCandidates=[];for(var c=0,cl=candidates.length;caTopCandidate.readability.contentScore){topCandidates.splice(t,0,candidate);if(topCandidates.length>this._nbTopCandidates)topCandidates.pop();break}}}var topCandidate=topCandidates[0]||null;var neededToCreateTopCandidate=false;var parentOfTopCandidate;if(topCandidate===null||topCandidate.tagName==="BODY"){topCandidate=doc.createElement("DIV");neededToCreateTopCandidate=true;while(page.firstChild){this.log("Moving child out:",page.firstChild);topCandidate.appendChild(page.firstChild)}page.appendChild(topCandidate);this._initializeNode(topCandidate)}else if(topCandidate){var alternativeCandidateAncestors=[];for(var i=1;i=.75){alternativeCandidateAncestors.push(this._getNodeAncestors(topCandidates[i]))}}var MINIMUM_TOPCANDIDATES=3;if(alternativeCandidateAncestors.length>=MINIMUM_TOPCANDIDATES){parentOfTopCandidate=topCandidate.parentNode;while(parentOfTopCandidate.tagName!=="BODY"){var listsContainingThisAncestor=0;for(var ancestorIndex=0;ancestorIndex=MINIMUM_TOPCANDIDATES){topCandidate=parentOfTopCandidate;break}parentOfTopCandidate=parentOfTopCandidate.parentNode}}if(!topCandidate.readability){this._initializeNode(topCandidate)}parentOfTopCandidate=topCandidate.parentNode;var lastScore=topCandidate.readability.contentScore;var scoreThreshold=lastScore/3;while(parentOfTopCandidate.tagName!=="BODY"){if(!parentOfTopCandidate.readability){parentOfTopCandidate=parentOfTopCandidate.parentNode;continue}var parentScore=parentOfTopCandidate.readability.contentScore;if(parentScorelastScore){topCandidate=parentOfTopCandidate;break}lastScore=parentOfTopCandidate.readability.contentScore;parentOfTopCandidate=parentOfTopCandidate.parentNode}parentOfTopCandidate=topCandidate.parentNode;while(parentOfTopCandidate.tagName!="BODY"&&parentOfTopCandidate.children.length==1){topCandidate=parentOfTopCandidate;parentOfTopCandidate=topCandidate.parentNode}if(!topCandidate.readability){this._initializeNode(topCandidate)}}var articleContent=doc.createElement("DIV");if(isPaging)articleContent.id="readability-content";var siblingScoreThreshold=Math.max(10,topCandidate.readability.contentScore*.2);parentOfTopCandidate=topCandidate.parentNode;var siblings=parentOfTopCandidate.children;for(var s=0,sl=siblings.length;s=siblingScoreThreshold){append=true}else if(sibling.nodeName==="P"){var linkDensity=this._getLinkDensity(sibling);var nodeContent=this._getInnerText(sibling);var nodeLength=nodeContent.length;if(nodeLength>80&&linkDensity<.25){append=true}else if(nodeLength<80&&nodeLength>0&&linkDensity===0&&nodeContent.search(/\.( |$)/)!==-1){append=true}}}if(append){this.log("Appending node:",sibling);if(this.ALTER_TO_DIV_EXCEPTIONS.indexOf(sibling.nodeName)===-1){this.log("Altering sibling:",sibling,"to div.");sibling=this._setNodeTag(sibling,"DIV")}articleContent.appendChild(sibling);siblings=parentOfTopCandidate.children;s-=1;sl-=1}}if(this._debug)this.log("Article content pre-prep: "+articleContent.innerHTML);this._prepArticle(articleContent);if(this._debug)this.log("Article content post-prep: "+articleContent.innerHTML);if(neededToCreateTopCandidate){topCandidate.id="readability-page-1";topCandidate.className="page"}else{var div=doc.createElement("DIV");div.id="readability-page-1";div.className="page";while(articleContent.firstChild){div.appendChild(articleContent.firstChild)}articleContent.appendChild(div)}if(this._debug)this.log("Article content after paging: "+articleContent.innerHTML);var parseSuccessful=true;var textLength=this._getInnerText(articleContent,true).length;if(textLength0&&byline.length<100}return false},_unescapeHtmlEntities:function(str){if(!str){return str}var htmlEscapeMap=this.HTML_ESCAPE_MAP;return str.replace(/&(quot|amp|apos|lt|gt);/g,(function(_,tag){return htmlEscapeMap[tag]})).replace(/(?:x([0-9a-z]{1,4})|([0-9]{1,4}));/gi,(function(_,hex,numStr){var num=parseInt(hex||numStr,hex?16:10);return String.fromCharCode(num)}))},_getJSONLD:function(doc){var scripts=this._getAllNodesWithTag(doc,["script"]);var metadata;this._forEachNode(scripts,(function(jsonLdElement){if(!metadata&&jsonLdElement.getAttribute("type")==="application/ld+json"){try{var content=jsonLdElement.textContent.replace(/^\s*\s*$/g,"");var parsed=JSON.parse(content);if(!parsed["@context"]||!parsed["@context"].match(/^https?\:\/\/schema\.org$/)){return}if(!parsed["@type"]&&Array.isArray(parsed["@graph"])){parsed=parsed["@graph"].find((function(it){return(it["@type"]||"").match(this.REGEXPS.jsonLdArticleTypes)}))}if(!parsed||!parsed["@type"]||!parsed["@type"].match(this.REGEXPS.jsonLdArticleTypes)){return}metadata={};if(typeof parsed.name==="string"&&typeof parsed.headline==="string"&&parsed.name!==parsed.headline){var title=this._getArticleTitle();var nameMatches=this._textSimilarity(parsed.name,title)>.75;var headlineMatches=this._textSimilarity(parsed.headline,title)>.75;if(headlineMatches&&!nameMatches){metadata.title=parsed.headline}else{metadata.title=parsed.name}}else if(typeof parsed.name==="string"){metadata.title=parsed.name.trim()}else if(typeof parsed.headline==="string"){metadata.title=parsed.headline.trim()}if(parsed.author){if(typeof parsed.author.name==="string"){metadata.byline=parsed.author.name.trim()}else if(Array.isArray(parsed.author)&&parsed.author[0]&&typeof parsed.author[0].name==="string"){metadata.byline=parsed.author.filter((function(author){return author&&typeof author.name==="string"})).map((function(author){return author.name.trim()})).join(", ")}}if(typeof parsed.description==="string"){metadata.excerpt=parsed.description.trim()}if(parsed.publisher&&typeof parsed.publisher.name==="string"){metadata.siteName=parsed.publisher.name.trim()}return}catch(err){this.log(err.message)}}}));return metadata?metadata:{}},_getArticleMetadata:function(jsonld){var metadata={};var values={};var metaElements=this._doc.getElementsByTagName("meta");var propertyPattern=/\s*(dc|dcterm|og|twitter)\s*:\s*(author|creator|description|title|site_name)\s*/gi;var namePattern=/^\s*(?:(dc|dcterm|og|twitter|weibo:(article|webpage))\s*[\.:]\s*)?(author|creator|description|title|site_name)\s*$/i;this._forEachNode(metaElements,(function(element){var elementName=element.getAttribute("name");var elementProperty=element.getAttribute("property");var content=element.getAttribute("content");if(!content){return}var matches=null;var name=null;if(elementProperty){matches=elementProperty.match(propertyPattern);if(matches){name=matches[0].toLowerCase().replace(/\s/g,"");values[name]=content.trim()}}if(!matches&&elementName&&namePattern.test(elementName)){name=elementName;if(content){name=name.toLowerCase().replace(/\s/g,"").replace(/\./g,":");values[name]=content.trim()}}}));metadata.title=jsonld.title||values["dc:title"]||values["dcterm:title"]||values["og:title"]||values["weibo:article:title"]||values["weibo:webpage:title"]||values["title"]||values["twitter:title"];if(!metadata.title){metadata.title=this._getArticleTitle()}metadata.byline=jsonld.byline||values["dc:creator"]||values["dcterm:creator"]||values["author"];metadata.excerpt=jsonld.excerpt||values["dc:description"]||values["dcterm:description"]||values["og:description"]||values["weibo:article:description"]||values["weibo:webpage:description"]||values["description"]||values["twitter:description"];metadata.siteName=jsonld.siteName||values["og:site_name"];metadata.title=this._unescapeHtmlEntities(metadata.title);metadata.byline=this._unescapeHtmlEntities(metadata.byline);metadata.excerpt=this._unescapeHtmlEntities(metadata.excerpt);metadata.siteName=this._unescapeHtmlEntities(metadata.siteName);return metadata},_isSingleImage:function(node){if(node.tagName==="IMG"){return true}if(node.children.length!==1||node.textContent.trim()!==""){return false}return this._isSingleImage(node.children[0])},_unwrapNoscriptImages:function(doc){var imgs=Array.from(doc.getElementsByTagName("img"));this._forEachNode(imgs,(function(img){for(var i=0;i0&&depth>maxDepth)return false;if(node.parentNode.tagName===tagName&&(!filterFn||filterFn(node.parentNode)))return true;node=node.parentNode;depth++}return false},_getRowAndColumnCount:function(table){var rows=0;var columns=0;var trs=table.getElementsByTagName("tr");for(var i=0;i0){table._readabilityDataTable=true;continue}var dataTableDescendants=["col","colgroup","tfoot","thead","th"];var descendantExists=function(tag){return!!table.getElementsByTagName(tag)[0]};if(dataTableDescendants.some(descendantExists)){this.log("Data table because found data-y descendant");table._readabilityDataTable=true;continue}if(table.getElementsByTagName("table")[0]){table._readabilityDataTable=false;continue}var sizeInfo=this._getRowAndColumnCount(table);if(sizeInfo.rows>=10||sizeInfo.columns>4){table._readabilityDataTable=true;continue}table._readabilityDataTable=sizeInfo.rows*sizeInfo.columns>10}},_fixLazyImages:function(root){this._forEachNode(this._getAllNodesWithTag(root,["img","picture","figure"]),(function(elem){if(elem.src&&this.REGEXPS.b64DataUrl.test(elem.src)){var parts=this.REGEXPS.b64DataUrl.exec(elem.src);if(parts[1]==="image/svg+xml"){return}var srcCouldBeRemoved=false;for(var i=0;ichildrenLength+=this._getInnerText(child,true).length));return childrenLength/textLength},_cleanConditionally:function(e,tag){if(!this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY))return;this._removeNodes(this._getAllNodesWithTag(e,[tag]),(function(node){var isDataTable=function(t){return t._readabilityDataTable};var isList=tag==="ul"||tag==="ol";if(!isList){var listLength=0;var listNodes=this._getAllNodesWithTag(node,["ul","ol"]);this._forEachNode(listNodes,(list=>listLength+=this._getInnerText(list).length));isList=listLength/this._getInnerText(node).length>.9}if(tag==="table"&&isDataTable(node)){return false}if(this._hasAncestorTag(node,"table",-1,isDataTable)){return false}if(this._hasAncestorTag(node,"code")){return false}var weight=this._getClassWeight(node);this.log("Cleaning Conditionally",node);var contentScore=0;if(weight+contentScore<0){return true}if(this._getCharCount(node,",")<10){var p=node.getElementsByTagName("p").length;var img=node.getElementsByTagName("img").length;var li=node.getElementsByTagName("li").length-100;var input=node.getElementsByTagName("input").length;var headingDensity=this._getTextDensity(node,["h1","h2","h3","h4","h5","h6"]);var embedCount=0;var embeds=this._getAllNodesWithTag(node,["object","embed","iframe"]);for(var i=0;i1&&p/img<.5&&!this._hasAncestorTag(node,"figure")||!isList&&li>p||input>Math.floor(p/3)||!isList&&headingDensity<.9&&contentLength<25&&(img===0||img>2)&&!this._hasAncestorTag(node,"figure")||!isList&&weight<25&&linkDensity>.2||weight>=25&&linkDensity>.5||(embedCount===1&&contentLength<75||embedCount>1);return haveToRemove}return false}))},_cleanMatchedNodes:function(e,filter){var endOfSearchMarkerNode=this._getNextNode(e,true);var next=this._getNextNode(e);while(next&&next!=endOfSearchMarkerNode){if(filter.call(this,next,next.className+" "+next.id)){next=this._removeAndGetNext(next)}else{next=this._getNextNode(next)}}},_cleanHeaders:function(e){let headingNodes=this._getAllNodesWithTag(e,["h1","h2"]);this._removeNodes(headingNodes,(function(node){let shouldRemove=this._getClassWeight(node)<0;if(shouldRemove){this.log("Removing header with low class weight:",node)}return shouldRemove}))},_headerDuplicatesTitle:function(node){if(node.tagName!="H1"&&node.tagName!="H2"){return false}var heading=this._getInnerText(node,false);this.log("Evaluating similarity of header:",heading,this._articleTitle);return this._textSimilarity(this._articleTitle,heading)>.75},_flagIsActive:function(flag){return(this._flags&flag)>0},_removeFlag:function(flag){this._flags=this._flags&~flag},_isProbablyVisible:function(node){return(!node.style||node.style.display!="none")&&!node.hasAttribute("hidden")&&(!node.hasAttribute("aria-hidden")||node.getAttribute("aria-hidden")!="true"||node.className&&node.className.indexOf&&node.className.indexOf("fallback-image")!==-1)},parse:function(){if(this._maxElemsToParse>0){var numTags=this._doc.getElementsByTagName("*").length;if(numTags>this._maxElemsToParse){throw new Error("Aborting parsing document; "+numTags+" elements found")}}this._unwrapNoscriptImages(this._doc);var jsonLd=this._disableJSONLD?{}:this._getJSONLD(this._doc);this._removeScripts(this._doc);this._prepDocument();var metadata=this._getArticleMetadata(jsonLd);this._articleTitle=metadata.title;var articleContent=this._grabArticle();if(!articleContent)return null;this.log("Grabbed: "+articleContent.innerHTML);this._postProcessContent(articleContent);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,lang:this._articleLang,content:this._serializer(articleContent),textContent:textContent,length:textContent.length,excerpt:metadata.excerpt,siteName:metadata.siteName||this._articleSiteName}}};if(typeof module==="object"){module.exports=Readability}const article=new Readability(window.document.cloneNode(true)).parse();const utterance=new SpeechSynthesisUtterance(article.textContent.trim());utterance.lang=document.documentElement.lang;speechSynthesis.speak(utterance)}));