@agent-infra/browser-context 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # Browser Context
@@ -0,0 +1,7 @@
1
+ import type { Page } from 'puppeteer-core';
2
+ export declare const extractContent: (page: Page) => Promise<{
3
+ content: any;
4
+ title: any;
5
+ fullContent: any;
6
+ }>;
7
+ //# sourceMappingURL=extract-content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-content.d.ts","sourceRoot":"","sources":["../../src/content/extract-content.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAG3C,eAAO,MAAM,cAAc,GAAU,MAAM,IAAI;;;;EAgC9C,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ "use strict";
6
+ var __webpack_require__ = {};
7
+ (()=>{
8
+ __webpack_require__.d = (exports1, definition)=>{
9
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
10
+ enumerable: true,
11
+ get: definition[key]
12
+ });
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ extractContent: ()=>extractContent
32
+ });
33
+ const external_readability_script_js_namespaceObject = require("./readability-script.js");
34
+ const extractContent = async (page)=>{
35
+ const extractionResult = await page.evaluate((readabilityScript)=>{
36
+ const Readability = new Function('module', `${readabilityScript}\nreturn module.exports`)({});
37
+ const documentClone = document.cloneNode(true);
38
+ documentClone.querySelectorAll("script,noscript,style,link,svg,img,video,iframe,canvas,.reflist").forEach((el)=>el.remove());
39
+ const article = new Readability(documentClone).parse();
40
+ const content = (null == article ? void 0 : article.content) || '';
41
+ const title = document.title;
42
+ return {
43
+ content,
44
+ title: (null == article ? void 0 : article.title) || title,
45
+ fullContent: content
46
+ };
47
+ }, external_readability_script_js_namespaceObject.READABILITY_SCRIPT);
48
+ return extractionResult;
49
+ };
50
+ exports.extractContent = __webpack_exports__.extractContent;
51
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
52
+ "extractContent"
53
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
54
+ Object.defineProperty(exports, '__esModule', {
55
+ value: true
56
+ });
57
+
58
+ //# sourceMappingURL=extract-content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content/extract-content.js","sources":["webpack://@agent-infra/browser-context/webpack/runtime/define_property_getters","webpack://@agent-infra/browser-context/webpack/runtime/has_own_property","webpack://@agent-infra/browser-context/webpack/runtime/make_namespace_object","webpack://@agent-infra/browser-context/./src/content/extract-content.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/*\n * Copyright (c) 2025 Bytedance, Inc. and its affiliates.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { Page } from 'puppeteer-core';\nimport { READABILITY_SCRIPT } from './readability-script.js';\n\nexport const extractContent = async (page: Page) => {\n // Extract content using Readability algorithm on a document clone to prevent DOM flickering\n const extractionResult = await page.evaluate((readabilityScript) => {\n // Initialize Readability from script\n const Readability = new Function(\n 'module',\n `${readabilityScript}\\nreturn module.exports`,\n )({});\n\n // Create a deep clone of the document to avoid modifying the visible DOM\n const documentClone = document.cloneNode(true) as Document;\n\n // Clean up the cloned document\n documentClone\n .querySelectorAll(\n 'script,noscript,style,link,svg,img,video,iframe,canvas,.reflist',\n )\n .forEach((el) => el.remove());\n\n // Parse content from the clone\n const article = new Readability(documentClone).parse();\n const content = article?.content || '';\n const title = document.title;\n\n return {\n content,\n title: article?.title || title,\n fullContent: content,\n };\n }, READABILITY_SCRIPT);\n\n return extractionResult;\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","extractContent","page","extractionResult","readabilityScript","Readability","Function","documentClone","document","el","article","content","title","READABILITY_SCRIPT"],"mappings":";;;;;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;ACCO,MAAMI,iBAAiB,OAAOC;IAEnC,MAAMC,mBAAmB,MAAMD,KAAK,QAAQ,CAAC,CAACE;QAE5C,MAAMC,cAAc,IAAIC,SACtB,UACA,GAAGF,kBAAkB,uBAAuB,CAAC,EAC7C,CAAC;QAGH,MAAMG,gBAAgBC,SAAS,SAAS,CAAC;QAGzCD,cACG,gBAAgB,CACf,mEAED,OAAO,CAAC,CAACE,KAAOA,GAAG,MAAM;QAG5B,MAAMC,UAAU,IAAIL,YAAYE,eAAe,KAAK;QACpD,MAAMI,UAAUD,AAAAA,CAAAA,QAAAA,UAAAA,KAAAA,IAAAA,QAAS,OAAO,AAAD,KAAK;QACpC,MAAME,QAAQJ,SAAS,KAAK;QAE5B,OAAO;YACLG;YACA,OAAOD,AAAAA,CAAAA,QAAAA,UAAAA,KAAAA,IAAAA,QAAS,KAAK,AAAD,KAAKE;YACzB,aAAaD;QACf;IACF,GAAGE,+CAAAA,kBAAkBA;IAErB,OAAOV;AACT"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { READABILITY_SCRIPT } from "./readability-script.mjs";
6
+ const extractContent = async (page)=>{
7
+ const extractionResult = await page.evaluate((readabilityScript)=>{
8
+ const Readability = new Function('module', `${readabilityScript}\nreturn module.exports`)({});
9
+ const documentClone = document.cloneNode(true);
10
+ documentClone.querySelectorAll("script,noscript,style,link,svg,img,video,iframe,canvas,.reflist").forEach((el)=>el.remove());
11
+ const article = new Readability(documentClone).parse();
12
+ const content = (null == article ? void 0 : article.content) || '';
13
+ const title = document.title;
14
+ return {
15
+ content,
16
+ title: (null == article ? void 0 : article.title) || title,
17
+ fullContent: content
18
+ };
19
+ }, READABILITY_SCRIPT);
20
+ return extractionResult;
21
+ };
22
+ export { extractContent };
23
+
24
+ //# sourceMappingURL=extract-content.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content/extract-content.mjs","sources":["webpack://@agent-infra/browser-context/./src/content/extract-content.ts"],"sourcesContent":["/*\n * Copyright (c) 2025 Bytedance, Inc. and its affiliates.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { Page } from 'puppeteer-core';\nimport { READABILITY_SCRIPT } from './readability-script.js';\n\nexport const extractContent = async (page: Page) => {\n // Extract content using Readability algorithm on a document clone to prevent DOM flickering\n const extractionResult = await page.evaluate((readabilityScript) => {\n // Initialize Readability from script\n const Readability = new Function(\n 'module',\n `${readabilityScript}\\nreturn module.exports`,\n )({});\n\n // Create a deep clone of the document to avoid modifying the visible DOM\n const documentClone = document.cloneNode(true) as Document;\n\n // Clean up the cloned document\n documentClone\n .querySelectorAll(\n 'script,noscript,style,link,svg,img,video,iframe,canvas,.reflist',\n )\n .forEach((el) => el.remove());\n\n // Parse content from the clone\n const article = new Readability(documentClone).parse();\n const content = article?.content || '';\n const title = document.title;\n\n return {\n content,\n title: article?.title || title,\n fullContent: content,\n };\n }, READABILITY_SCRIPT);\n\n return extractionResult;\n};\n"],"names":["extractContent","page","extractionResult","readabilityScript","Readability","Function","documentClone","document","el","article","content","title","READABILITY_SCRIPT"],"mappings":";;;;;AAOO,MAAMA,iBAAiB,OAAOC;IAEnC,MAAMC,mBAAmB,MAAMD,KAAK,QAAQ,CAAC,CAACE;QAE5C,MAAMC,cAAc,IAAIC,SACtB,UACA,GAAGF,kBAAkB,uBAAuB,CAAC,EAC7C,CAAC;QAGH,MAAMG,gBAAgBC,SAAS,SAAS,CAAC;QAGzCD,cACG,gBAAgB,CACf,mEAED,OAAO,CAAC,CAACE,KAAOA,GAAG,MAAM;QAG5B,MAAMC,UAAU,IAAIL,YAAYE,eAAe,KAAK;QACpD,MAAMI,UAAUD,AAAAA,CAAAA,QAAAA,UAAAA,KAAAA,IAAAA,QAAS,OAAO,AAAD,KAAK;QACpC,MAAME,QAAQJ,SAAS,KAAK;QAE5B,OAAO;YACLG;YACA,OAAOD,AAAAA,CAAAA,QAAAA,UAAAA,KAAAA,IAAAA,QAAS,KAAK,AAAD,KAAKE;YACzB,aAAaD;QACf;IACF,GAAGE;IAEH,OAAOV;AACT"}
@@ -0,0 +1,3 @@
1
+ export * from './extract-content.js';
2
+ export * from './to-markdown.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/content/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ "use strict";
6
+ var __webpack_modules__ = {
7
+ "./extract-content.js": function(module) {
8
+ module.exports = require("./extract-content.js");
9
+ },
10
+ "./to-markdown.js": function(module) {
11
+ module.exports = require("./to-markdown.js");
12
+ }
13
+ };
14
+ var __webpack_module_cache__ = {};
15
+ function __webpack_require__(moduleId) {
16
+ var cachedModule = __webpack_module_cache__[moduleId];
17
+ if (void 0 !== cachedModule) return cachedModule.exports;
18
+ var module = __webpack_module_cache__[moduleId] = {
19
+ exports: {}
20
+ };
21
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
22
+ return module.exports;
23
+ }
24
+ (()=>{
25
+ __webpack_require__.n = (module)=>{
26
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
27
+ __webpack_require__.d(getter, {
28
+ a: getter
29
+ });
30
+ return getter;
31
+ };
32
+ })();
33
+ (()=>{
34
+ __webpack_require__.d = (exports1, definition)=>{
35
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
36
+ enumerable: true,
37
+ get: definition[key]
38
+ });
39
+ };
40
+ })();
41
+ (()=>{
42
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
43
+ })();
44
+ (()=>{
45
+ __webpack_require__.r = (exports1)=>{
46
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
47
+ value: 'Module'
48
+ });
49
+ Object.defineProperty(exports1, '__esModule', {
50
+ value: true
51
+ });
52
+ };
53
+ })();
54
+ var __webpack_exports__ = {};
55
+ (()=>{
56
+ __webpack_require__.r(__webpack_exports__);
57
+ var _extract_content_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./extract-content.js");
58
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
59
+ for(var __WEBPACK_IMPORT_KEY__ in _extract_content_js__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
60
+ return _extract_content_js__WEBPACK_IMPORTED_MODULE_0__[key];
61
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
62
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
63
+ var _to_markdown_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./to-markdown.js");
64
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
65
+ for(var __WEBPACK_IMPORT_KEY__ in _to_markdown_js__WEBPACK_IMPORTED_MODULE_1__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
66
+ return _to_markdown_js__WEBPACK_IMPORTED_MODULE_1__[key];
67
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
68
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
69
+ })();
70
+ for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
71
+ Object.defineProperty(exports, '__esModule', {
72
+ value: true
73
+ });
74
+
75
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content/index.js","sources":["webpack://@agent-infra/browser-context/webpack/runtime/compat_get_default_export","webpack://@agent-infra/browser-context/webpack/runtime/define_property_getters","webpack://@agent-infra/browser-context/webpack/runtime/has_own_property","webpack://@agent-infra/browser-context/webpack/runtime/make_namespace_object"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACM,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFP,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOQ,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ export * from "./extract-content.mjs";
6
+ export * from "./to-markdown.mjs";
@@ -0,0 +1,23 @@
1
+ /**
2
+ * PLEASE DO NOT MODIFY IT as it is generated by the build script
3
+ *
4
+ * Build: scripts/build-readability.ts
5
+ * Source: https://github.com/mozilla/readability/blob/main/Readability.js
6
+ */
7
+ /**
8
+ * Copyright (c) 2010 Arc90 Inc
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+ export declare const READABILITY_SCRIPT = "function q(t,e){if(e&&e.documentElement)t=e,e=arguments[2];else if(!t||!t.documentElement)throw new Error(\"First argument to Readability constructor should be a document object.\");if(e=e||{},this._doc=t,this._docJSDOMParser=this._doc.firstChild.__JSDOMParser__,this._articleTitle=null,this._articleByline=null,this._articleDir=null,this._articleSiteName=null,this._attempts=[],this._debug=!!e.debug,this._maxElemsToParse=e.maxElemsToParse||this.DEFAULT_MAX_ELEMS_TO_PARSE,this._nbTopCandidates=e.nbTopCandidates||this.DEFAULT_N_TOP_CANDIDATES,this._charThreshold=e.charThreshold||this.DEFAULT_CHAR_THRESHOLD,this._classesToPreserve=this.CLASSES_TO_PRESERVE.concat(e.classesToPreserve||[]),this._keepClasses=!!e.keepClasses,this._serializer=e.serializer||function(i){return i.innerHTML},this._disableJSONLD=!!e.disableJSONLD,this._allowedVideoRegex=e.allowedVideoRegex||this.REGEXPS.videos,this._flags=this.FLAG_STRIP_UNLIKELYS|this.FLAG_WEIGHT_CLASSES|this.FLAG_CLEAN_CONDITIONALLY,this._debug){let i=function(r){if(r.nodeType==r.TEXT_NODE)return`${r.nodeName} (\"${r.textContent}\")`;let l=Array.from(r.attributes||[],function(a){return`${a.name}=\"${a.value}\"`}).join(\" \");return`<${r.localName} ${l}>`};this.log=function(){if(typeof console!=\"undefined\"){let l=Array.from(arguments,a=>a&&a.nodeType==this.ELEMENT_NODE?i(a):a);l.unshift(\"Reader: (Readability)\"),console.log.apply(console,l)}else if(typeof dump!=\"undefined\"){var r=Array.prototype.map.call(arguments,function(l){return l&&l.nodeName?i(l):l}).join(\" \");dump(\"Reader: (Readability) \"+r+`\n`)}}}else this.log=function(){}}q.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|>([^\\|]|$)|\u00BB([^\\|]|$))/i,prevLink:/(prev|earl|old|new|<|\u00AB)/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,commas:/\\u002C|\\u060C|\\uFE50|\\uFE10|\\uFE11|\\u2E41|\\u2E34|\\u2E32|\\uFF0C/g,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(t){this._fixRelativeUris(t),this._simplifyNestedElements(t),this._keepClasses||this._cleanClasses(t)},_removeNodes:function(t,e){if(this._docJSDOMParser&&t._isLiveNodeList)throw new Error(\"Do not pass live node lists to _removeNodes\");for(var i=t.length-1;i>=0;i--){var r=t[i],l=r.parentNode;l&&(!e||e.call(this,r,i,t))&&l.removeChild(r)}},_replaceNodeTags:function(t,e){if(this._docJSDOMParser&&t._isLiveNodeList)throw new Error(\"Do not pass live node lists to _replaceNodeTags\");for(let i of t)this._setNodeTag(i,e)},_forEachNode:function(t,e){Array.prototype.forEach.call(t,e,this)},_findNode:function(t,e){return Array.prototype.find.call(t,e,this)},_someNode:function(t,e){return Array.prototype.some.call(t,e,this)},_everyNode:function(t,e){return Array.prototype.every.call(t,e,this)},_concatNodeLists:function(){var t=Array.prototype.slice,e=t.call(arguments),i=e.map(function(r){return t.call(r)});return Array.prototype.concat.apply([],i)},_getAllNodesWithTag:function(t,e){return t.querySelectorAll?t.querySelectorAll(e.join(\",\")):[].concat.apply([],e.map(function(i){var r=t.getElementsByTagName(i);return Array.isArray(r)?r:Array.from(r)}))},_cleanClasses:function(t){var e=this._classesToPreserve,i=(t.getAttribute(\"class\")||\"\").split(/\\s+/).filter(function(r){return e.indexOf(r)!=-1}).join(\" \");for(i?t.setAttribute(\"class\",i):t.removeAttribute(\"class\"),t=t.firstElementChild;t;t=t.nextElementSibling)this._cleanClasses(t)},_fixRelativeUris:function(t){var e=this._doc.baseURI,i=this._doc.documentURI;function r(s){if(e==i&&s.charAt(0)==\"#\")return s;try{return new URL(s,e).href}catch(h){}return s}var l=this._getAllNodesWithTag(t,[\"a\"]);this._forEachNode(l,function(s){var h=s.getAttribute(\"href\");if(h)if(h.indexOf(\"javascript:\")===0)if(s.childNodes.length===1&&s.childNodes[0].nodeType===this.TEXT_NODE){var c=this._doc.createTextNode(s.textContent);s.parentNode.replaceChild(c,s)}else{for(var n=this._doc.createElement(\"span\");s.firstChild;)n.appendChild(s.firstChild);s.parentNode.replaceChild(n,s)}else s.setAttribute(\"href\",r(h))});var a=this._getAllNodesWithTag(t,[\"img\",\"picture\",\"figure\",\"video\",\"audio\",\"source\"]);this._forEachNode(a,function(s){var h=s.getAttribute(\"src\"),c=s.getAttribute(\"poster\"),n=s.getAttribute(\"srcset\");if(h&&s.setAttribute(\"src\",r(h)),c&&s.setAttribute(\"poster\",r(c)),n){var u=n.replace(this.REGEXPS.srcsetUrl,function(m,b,N,v){return r(b)+(N||\"\")+v});s.setAttribute(\"srcset\",u)}})},_simplifyNestedElements:function(t){for(var e=t;e;){if(e.parentNode&&[\"DIV\",\"SECTION\"].includes(e.tagName)&&!(e.id&&e.id.startsWith(\"readability\"))){if(this._isElementWithoutContent(e)){e=this._removeAndGetNext(e);continue}else if(this._hasSingleTagInsideElement(e,\"DIV\")||this._hasSingleTagInsideElement(e,\"SECTION\")){for(var i=e.children[0],r=0;r<e.attributes.length;r++)i.setAttribute(e.attributes[r].name,e.attributes[r].value);e.parentNode.replaceChild(i,e),e=i;continue}}e=this._getNextNode(e)}},_getArticleTitle:function(){var t=this._doc,e=\"\",i=\"\";try{e=i=t.title.trim(),typeof e!=\"string\"&&(e=i=this._getInnerText(t.getElementsByTagName(\"title\")[0]))}catch(u){}var r=!1;function l(u){return u.split(/\\s+/).length}if(/ [\\|\\-\\\\\\/>\u00BB] /.test(e))r=/ [\\\\\\/>\u00BB] /.test(e),e=i.replace(/(.*)[\\|\\-\\\\\\/>\u00BB] .*/gi,\"$1\"),l(e)<3&&(e=i.replace(/[^\\|\\-\\\\\\/>\u00BB]*[\\|\\-\\\\\\/>\u00BB](.*)/gi,\"$1\"));else if(e.indexOf(\": \")!==-1){var a=this._concatNodeLists(t.getElementsByTagName(\"h1\"),t.getElementsByTagName(\"h2\")),s=e.trim(),h=this._someNode(a,function(u){return u.textContent.trim()===s});h||(e=i.substring(i.lastIndexOf(\":\")+1),l(e)<3?e=i.substring(i.indexOf(\":\")+1):l(i.substr(0,i.indexOf(\":\")))>5&&(e=i))}else if(e.length>150||e.length<15){var c=t.getElementsByTagName(\"h1\");c.length===1&&(e=this._getInnerText(c[0]))}e=e.trim().replace(this.REGEXPS.normalize,\" \");var n=l(e);return n<=4&&(!r||n!=l(i.replace(/[\\|\\-\\\\\\/>\u00BB]+/g,\"\"))-1)&&(e=i),e},_prepDocument:function(){var t=this._doc;this._removeNodes(this._getAllNodesWithTag(t,[\"style\"])),t.body&&this._replaceBrs(t.body),this._replaceNodeTags(this._getAllNodesWithTag(t,[\"font\"]),\"SPAN\")},_nextNode:function(t){for(var e=t;e&&e.nodeType!=this.ELEMENT_NODE&&this.REGEXPS.whitespace.test(e.textContent);)e=e.nextSibling;return e},_replaceBrs:function(t){this._forEachNode(this._getAllNodesWithTag(t,[\"br\"]),function(e){for(var i=e.nextSibling,r=!1;(i=this._nextNode(i))&&i.tagName==\"BR\";){r=!0;var l=i.nextSibling;i.parentNode.removeChild(i),i=l}if(r){var a=this._doc.createElement(\"p\");for(e.parentNode.replaceChild(a,e),i=a.nextSibling;i;){if(i.tagName==\"BR\"){var s=this._nextNode(i.nextSibling);if(s&&s.tagName==\"BR\")break}if(!this._isPhrasingContent(i))break;var h=i.nextSibling;a.appendChild(i),i=h}for(;a.lastChild&&this._isWhitespace(a.lastChild);)a.removeChild(a.lastChild);a.parentNode.tagName===\"P\"&&this._setNodeTag(a.parentNode,\"DIV\")}})},_setNodeTag:function(t,e){if(this.log(\"_setNodeTag\",t,e),this._docJSDOMParser)return t.localName=e.toLowerCase(),t.tagName=e.toUpperCase(),t;for(var i=t.ownerDocument.createElement(e);t.firstChild;)i.appendChild(t.firstChild);t.parentNode.replaceChild(i,t),t.readability&&(i.readability=t.readability);for(var r=0;r<t.attributes.length;r++)try{i.setAttribute(t.attributes[r].name,t.attributes[r].value)}catch(l){}return i},_prepArticle:function(t){this._cleanStyles(t),this._markDataTables(t),this._fixLazyImages(t),this._cleanConditionally(t,\"form\"),this._cleanConditionally(t,\"fieldset\"),this._clean(t,\"object\"),this._clean(t,\"embed\"),this._clean(t,\"footer\"),this._clean(t,\"link\"),this._clean(t,\"aside\");var e=this.DEFAULT_CHAR_THRESHOLD;this._forEachNode(t.children,function(i){this._cleanMatchedNodes(i,function(r,l){return this.REGEXPS.shareElements.test(l)&&r.textContent.length<e})}),this._clean(t,\"iframe\"),this._clean(t,\"input\"),this._clean(t,\"textarea\"),this._clean(t,\"select\"),this._clean(t,\"button\"),this._cleanHeaders(t),this._cleanConditionally(t,\"table\"),this._cleanConditionally(t,\"ul\"),this._cleanConditionally(t,\"div\"),this._replaceNodeTags(this._getAllNodesWithTag(t,[\"h1\"]),\"h2\"),this._removeNodes(this._getAllNodesWithTag(t,[\"p\"]),function(i){var r=i.getElementsByTagName(\"img\").length,l=i.getElementsByTagName(\"embed\").length,a=i.getElementsByTagName(\"object\").length,s=i.getElementsByTagName(\"iframe\").length,h=r+l+a+s;return h===0&&!this._getInnerText(i,!1)}),this._forEachNode(this._getAllNodesWithTag(t,[\"br\"]),function(i){var r=this._nextNode(i.nextSibling);r&&r.tagName==\"P\"&&i.parentNode.removeChild(i)}),this._forEachNode(this._getAllNodesWithTag(t,[\"table\"]),function(i){var r=this._hasSingleTagInsideElement(i,\"TBODY\")?i.firstElementChild:i;if(this._hasSingleTagInsideElement(r,\"TR\")){var l=r.firstElementChild;if(this._hasSingleTagInsideElement(l,\"TD\")){var a=l.firstElementChild;a=this._setNodeTag(a,this._everyNode(a.childNodes,this._isPhrasingContent)?\"P\":\"DIV\"),i.parentNode.replaceChild(a,i)}}})},_initializeNode:function(t){switch(t.readability={contentScore:0},t.tagName){case\"DIV\":t.readability.contentScore+=5;break;case\"PRE\":case\"TD\":case\"BLOCKQUOTE\":t.readability.contentScore+=3;break;case\"ADDRESS\":case\"OL\":case\"UL\":case\"DL\":case\"DD\":case\"DT\":case\"LI\":case\"FORM\":t.readability.contentScore-=3;break;case\"H1\":case\"H2\":case\"H3\":case\"H4\":case\"H5\":case\"H6\":case\"TH\":t.readability.contentScore-=5;break}t.readability.contentScore+=this._getClassWeight(t)},_removeAndGetNext:function(t){var e=this._getNextNode(t,!0);return t.parentNode.removeChild(t),e},_getNextNode:function(t,e){if(!e&&t.firstElementChild)return t.firstElementChild;if(t.nextElementSibling)return t.nextElementSibling;do t=t.parentNode;while(t&&!t.nextElementSibling);return t&&t.nextElementSibling},_textSimilarity:function(t,e){var i=t.toLowerCase().split(this.REGEXPS.tokenize).filter(Boolean),r=e.toLowerCase().split(this.REGEXPS.tokenize).filter(Boolean);if(!i.length||!r.length)return 0;var l=r.filter(s=>!i.includes(s)),a=l.join(\" \").length/r.join(\" \").length;return 1-a},_checkByline:function(t,e){if(this._articleByline)return!1;if(t.getAttribute!==void 0)var i=t.getAttribute(\"rel\"),r=t.getAttribute(\"itemprop\");return(i===\"author\"||r&&r.indexOf(\"author\")!==-1||this.REGEXPS.byline.test(e))&&this._isValidByline(t.textContent)?(this._articleByline=t.textContent.trim(),!0):!1},_getNodeAncestors:function(t,e){e=e||0;for(var i=0,r=[];t.parentNode&&(r.push(t.parentNode),!(e&&++i===e));)t=t.parentNode;return r},_grabArticle:function(t){this.log(\"**** grabArticle ****\");var e=this._doc,i=t!==null;if(t=t||this._doc.body,!t)return this.log(\"No body found in document. Abort.\"),null;for(var r=t.innerHTML;;){this.log(\"Starting grabArticle loop\");var l=this._flagIsActive(this.FLAG_STRIP_UNLIKELYS),a=[],s=this._doc.documentElement;let J=!0;for(;s;){s.tagName===\"HTML\"&&(this._articleLang=s.getAttribute(\"lang\"));var h=s.className+\" \"+s.id;if(!this._isProbablyVisible(s)){this.log(\"Removing hidden node - \"+h),s=this._removeAndGetNext(s);continue}if(s.getAttribute(\"aria-modal\")==\"true\"&&s.getAttribute(\"role\")==\"dialog\"){s=this._removeAndGetNext(s);continue}if(this._checkByline(s,h)){s=this._removeAndGetNext(s);continue}if(J&&this._headerDuplicatesTitle(s)){this.log(\"Removing header: \",s.textContent.trim(),this._articleTitle.trim()),J=!1,s=this._removeAndGetNext(s);continue}if(l){if(this.REGEXPS.unlikelyCandidates.test(h)&&!this.REGEXPS.okMaybeItsACandidate.test(h)&&!this._hasAncestorTag(s,\"table\")&&!this._hasAncestorTag(s,\"code\")&&s.tagName!==\"BODY\"&&s.tagName!==\"A\"){this.log(\"Removing unlikely candidate - \"+h),s=this._removeAndGetNext(s);continue}if(this.UNLIKELY_ROLES.includes(s.getAttribute(\"role\"))){this.log(\"Removing content with role \"+s.getAttribute(\"role\")+\" - \"+h),s=this._removeAndGetNext(s);continue}}if((s.tagName===\"DIV\"||s.tagName===\"SECTION\"||s.tagName===\"HEADER\"||s.tagName===\"H1\"||s.tagName===\"H2\"||s.tagName===\"H3\"||s.tagName===\"H4\"||s.tagName===\"H5\"||s.tagName===\"H6\")&&this._isElementWithoutContent(s)){s=this._removeAndGetNext(s);continue}if(this.DEFAULT_TAGS_TO_SCORE.indexOf(s.tagName)!==-1&&a.push(s),s.tagName===\"DIV\"){for(var c=null,n=s.firstChild;n;){var u=n.nextSibling;if(this._isPhrasingContent(n))c!==null?c.appendChild(n):this._isWhitespace(n)||(c=e.createElement(\"p\"),s.replaceChild(c,n),c.appendChild(n));else if(c!==null){for(;c.lastChild&&this._isWhitespace(c.lastChild);)c.removeChild(c.lastChild);c=null}n=u}if(this._hasSingleTagInsideElement(s,\"P\")&&this._getLinkDensity(s)<.25){var m=s.children[0];s.parentNode.replaceChild(m,s),s=m,a.push(s)}else this._hasChildBlockElement(s)||(s=this._setNodeTag(s,\"P\"),a.push(s))}s=this._getNextNode(s)}var b=[];this._forEachNode(a,function(A){if(!(!A.parentNode||typeof A.parentNode.tagName==\"undefined\")){var T=this._getInnerText(A);if(!(T.length<25)){var K=this._getNodeAncestors(A,5);if(K.length!==0){var C=0;C+=1,C+=T.split(this.REGEXPS.commas).length,C+=Math.min(Math.floor(T.length/100),3),this._forEachNode(K,function(S,F){if(!(!S.tagName||!S.parentNode||typeof S.parentNode.tagName==\"undefined\")){if(typeof S.readability==\"undefined\"&&(this._initializeNode(S),b.push(S)),F===0)var X=1;else F===1?X=2:X=F*3;S.readability.contentScore+=C/X}})}}}});for(var N=[],v=0,y=b.length;v<y;v+=1){var E=b[v],d=E.readability.contentScore*(1-this._getLinkDensity(E));E.readability.contentScore=d,this.log(\"Candidate:\",E,\"with score \"+d);for(var p=0;p<this._nbTopCandidates;p++){var x=N[p];if(!x||d>x.readability.contentScore){N.splice(p,0,E),N.length>this._nbTopCandidates&&N.pop();break}}}var o=N[0]||null,L=!1,g;if(o===null||o.tagName===\"BODY\"){for(o=e.createElement(\"DIV\"),L=!0;t.firstChild;)this.log(\"Moving child out:\",t.firstChild),o.appendChild(t.firstChild);t.appendChild(o),this._initializeNode(o)}else if(o){for(var I=[],P=1;P<N.length;P++)N[P].readability.contentScore/o.readability.contentScore>=.75&&I.push(this._getNodeAncestors(N[P]));var O=3;if(I.length>=O)for(g=o.parentNode;g.tagName!==\"BODY\";){for(var G=0,H=0;H<I.length&&G<O;H++)G+=Number(I[H].includes(g));if(G>=O){o=g;break}g=g.parentNode}o.readability||this._initializeNode(o),g=o.parentNode;for(var M=o.readability.contentScore,Q=M/3;g.tagName!==\"BODY\";){if(!g.readability){g=g.parentNode;continue}var V=g.readability.contentScore;if(V<Q)break;if(V>M){o=g;break}M=g.readability.contentScore,g=g.parentNode}for(g=o.parentNode;g.tagName!=\"BODY\"&&g.children.length==1;)o=g,g=o.parentNode;o.readability||this._initializeNode(o)}var _=e.createElement(\"DIV\");i&&(_.id=\"readability-content\");var Z=Math.max(10,o.readability.contentScore*.2);g=o.parentNode;for(var U=g.children,w=0,j=U.length;w<j;w++){var f=U[w],R=!1;if(this.log(\"Looking at sibling node:\",f,f.readability?\"with score \"+f.readability.contentScore:\"\"),this.log(\"Sibling has score\",f.readability?f.readability.contentScore:\"Unknown\"),f===o)R=!0;else{var $=0;if(f.className===o.className&&o.className!==\"\"&&($+=o.readability.contentScore*.2),f.readability&&f.readability.contentScore+$>=Z)R=!0;else if(f.nodeName===\"P\"){var Y=this._getLinkDensity(f),z=this._getInnerText(f),k=z.length;(k>80&&Y<.25||k<80&&k>0&&Y===0&&z.search(/\\.( |$)/)!==-1)&&(R=!0)}}R&&(this.log(\"Appending node:\",f),this.ALTER_TO_DIV_EXCEPTIONS.indexOf(f.nodeName)===-1&&(this.log(\"Altering sibling:\",f,\"to div.\"),f=this._setNodeTag(f,\"DIV\")),_.appendChild(f),U=g.children,w-=1,j-=1)}if(this._debug&&this.log(\"Article content pre-prep: \"+_.innerHTML),this._prepArticle(_),this._debug&&this.log(\"Article content post-prep: \"+_.innerHTML),L)o.id=\"readability-page-1\",o.className=\"page\";else{var B=e.createElement(\"DIV\");for(B.id=\"readability-page-1\",B.className=\"page\";_.firstChild;)B.appendChild(_.firstChild);_.appendChild(B)}this._debug&&this.log(\"Article content after paging: \"+_.innerHTML);var W=!0,D=this._getInnerText(_,!0).length;if(D<this._charThreshold)if(W=!1,t.innerHTML=r,this._flagIsActive(this.FLAG_STRIP_UNLIKELYS))this._removeFlag(this.FLAG_STRIP_UNLIKELYS),this._attempts.push({articleContent:_,textLength:D});else if(this._flagIsActive(this.FLAG_WEIGHT_CLASSES))this._removeFlag(this.FLAG_WEIGHT_CLASSES),this._attempts.push({articleContent:_,textLength:D});else if(this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY))this._removeFlag(this.FLAG_CLEAN_CONDITIONALLY),this._attempts.push({articleContent:_,textLength:D});else{if(this._attempts.push({articleContent:_,textLength:D}),this._attempts.sort(function(A,T){return T.textLength-A.textLength}),!this._attempts[0].textLength)return null;_=this._attempts[0].articleContent,W=!0}if(W){var tt=[g,o].concat(this._getNodeAncestors(g));return this._someNode(tt,function(A){if(!A.tagName)return!1;var T=A.getAttribute(\"dir\");return T?(this._articleDir=T,!0):!1}),_}}},_isValidByline:function(t){return typeof t==\"string\"||t instanceof String?(t=t.trim(),t.length>0&&t.length<100):!1},_unescapeHtmlEntities:function(t){if(!t)return t;var e=this.HTML_ESCAPE_MAP;return t.replace(/&(quot|amp|apos|lt|gt);/g,function(i,r){return e[r]}).replace(/&#(?:x([0-9a-z]{1,4})|([0-9]{1,4}));/gi,function(i,r,l){var a=parseInt(r||l,r?16:10);return String.fromCharCode(a)})},_getJSONLD:function(t){var e=this._getAllNodesWithTag(t,[\"script\"]),i;return this._forEachNode(e,function(r){if(!i&&r.getAttribute(\"type\")===\"application/ld+json\")try{var l=r.textContent.replace(/^\\s*<!\\[CDATA\\[|\\]\\]>\\s*$/g,\"\"),a=JSON.parse(l);if(!a[\"@context\"]||!a[\"@context\"].match(/^https?\\:\\/\\/schema\\.org$/)||(!a[\"@type\"]&&Array.isArray(a[\"@graph\"])&&(a=a[\"@graph\"].find(function(n){return(n[\"@type\"]||\"\").match(this.REGEXPS.jsonLdArticleTypes)})),!a||!a[\"@type\"]||!a[\"@type\"].match(this.REGEXPS.jsonLdArticleTypes)))return;if(i={},typeof a.name==\"string\"&&typeof a.headline==\"string\"&&a.name!==a.headline){var s=this._getArticleTitle(),h=this._textSimilarity(a.name,s)>.75,c=this._textSimilarity(a.headline,s)>.75;c&&!h?i.title=a.headline:i.title=a.name}else typeof a.name==\"string\"?i.title=a.name.trim():typeof a.headline==\"string\"&&(i.title=a.headline.trim());a.author&&(typeof a.author.name==\"string\"?i.byline=a.author.name.trim():Array.isArray(a.author)&&a.author[0]&&typeof a.author[0].name==\"string\"&&(i.byline=a.author.filter(function(n){return n&&typeof n.name==\"string\"}).map(function(n){return n.name.trim()}).join(\", \"))),typeof a.description==\"string\"&&(i.excerpt=a.description.trim()),a.publisher&&typeof a.publisher.name==\"string\"&&(i.siteName=a.publisher.name.trim()),typeof a.datePublished==\"string\"&&(i.datePublished=a.datePublished.trim());return}catch(n){this.log(n.message)}}),i||{}},_getArticleMetadata:function(t){var e={},i={},r=this._doc.getElementsByTagName(\"meta\"),l=/\\s*(article|dc|dcterm|og|twitter)\\s*:\\s*(author|creator|description|published_time|title|site_name)\\s*/gi,a=/^\\s*(?:(dc|dcterm|og|twitter|weibo:(article|webpage))\\s*[\\.:]\\s*)?(author|creator|description|title|site_name)\\s*$/i;return this._forEachNode(r,function(s){var h=s.getAttribute(\"name\"),c=s.getAttribute(\"property\"),n=s.getAttribute(\"content\");if(n){var u=null,m=null;c&&(u=c.match(l),u&&(m=u[0].toLowerCase().replace(/\\s/g,\"\"),i[m]=n.trim())),!u&&h&&a.test(h)&&(m=h,n&&(m=m.toLowerCase().replace(/\\s/g,\"\").replace(/\\./g,\":\"),i[m]=n.trim()))}}),e.title=t.title||i[\"dc:title\"]||i[\"dcterm:title\"]||i[\"og:title\"]||i[\"weibo:article:title\"]||i[\"weibo:webpage:title\"]||i.title||i[\"twitter:title\"],e.title||(e.title=this._getArticleTitle()),e.byline=t.byline||i[\"dc:creator\"]||i[\"dcterm:creator\"]||i.author,e.excerpt=t.excerpt||i[\"dc:description\"]||i[\"dcterm:description\"]||i[\"og:description\"]||i[\"weibo:article:description\"]||i[\"weibo:webpage:description\"]||i.description||i[\"twitter:description\"],e.siteName=t.siteName||i[\"og:site_name\"],e.publishedTime=t.datePublished||i[\"article:published_time\"]||null,e.title=this._unescapeHtmlEntities(e.title),e.byline=this._unescapeHtmlEntities(e.byline),e.excerpt=this._unescapeHtmlEntities(e.excerpt),e.siteName=this._unescapeHtmlEntities(e.siteName),e.publishedTime=this._unescapeHtmlEntities(e.publishedTime),e},_isSingleImage:function(t){return t.tagName===\"IMG\"?!0:t.children.length!==1||t.textContent.trim()!==\"\"?!1:this._isSingleImage(t.children[0])},_unwrapNoscriptImages:function(t){var e=Array.from(t.getElementsByTagName(\"img\"));this._forEachNode(e,function(r){for(var l=0;l<r.attributes.length;l++){var a=r.attributes[l];switch(a.name){case\"src\":case\"srcset\":case\"data-src\":case\"data-srcset\":return}if(/\\.(jpg|jpeg|png|webp)/i.test(a.value))return}r.parentNode.removeChild(r)});var i=Array.from(t.getElementsByTagName(\"noscript\"));this._forEachNode(i,function(r){var l=t.createElement(\"div\");if(l.innerHTML=r.innerHTML,!!this._isSingleImage(l)){var a=r.previousElementSibling;if(a&&this._isSingleImage(a)){var s=a;s.tagName!==\"IMG\"&&(s=a.getElementsByTagName(\"img\")[0]);for(var h=l.getElementsByTagName(\"img\")[0],c=0;c<s.attributes.length;c++){var n=s.attributes[c];if(n.value!==\"\"&&(n.name===\"src\"||n.name===\"srcset\"||/\\.(jpg|jpeg|png|webp)/i.test(n.value))){if(h.getAttribute(n.name)===n.value)continue;var u=n.name;h.hasAttribute(u)&&(u=\"data-old-\"+u),h.setAttribute(u,n.value)}}r.parentNode.replaceChild(l.firstElementChild,a)}}})},_removeScripts:function(t){this._removeNodes(this._getAllNodesWithTag(t,[\"script\",\"noscript\"]))},_hasSingleTagInsideElement:function(t,e){return t.children.length!=1||t.children[0].tagName!==e?!1:!this._someNode(t.childNodes,function(i){return i.nodeType===this.TEXT_NODE&&this.REGEXPS.hasContent.test(i.textContent)})},_isElementWithoutContent:function(t){return t.nodeType===this.ELEMENT_NODE&&t.textContent.trim().length==0&&(t.children.length==0||t.children.length==t.getElementsByTagName(\"br\").length+t.getElementsByTagName(\"hr\").length)},_hasChildBlockElement:function(t){return this._someNode(t.childNodes,function(e){return this.DIV_TO_P_ELEMS.has(e.tagName)||this._hasChildBlockElement(e)})},_isPhrasingContent:function(t){return t.nodeType===this.TEXT_NODE||this.PHRASING_ELEMS.indexOf(t.tagName)!==-1||(t.tagName===\"A\"||t.tagName===\"DEL\"||t.tagName===\"INS\")&&this._everyNode(t.childNodes,this._isPhrasingContent)},_isWhitespace:function(t){return t.nodeType===this.TEXT_NODE&&t.textContent.trim().length===0||t.nodeType===this.ELEMENT_NODE&&t.tagName===\"BR\"},_getInnerText:function(t,e){e=typeof e==\"undefined\"?!0:e;var i=t.textContent.trim();return e?i.replace(this.REGEXPS.normalize,\" \"):i},_getCharCount:function(t,e){return e=e||\",\",this._getInnerText(t).split(e).length-1},_cleanStyles:function(t){if(!(!t||t.tagName.toLowerCase()===\"svg\")){for(var e=0;e<this.PRESENTATIONAL_ATTRIBUTES.length;e++)t.removeAttribute(this.PRESENTATIONAL_ATTRIBUTES[e]);this.DEPRECATED_SIZE_ATTRIBUTE_ELEMS.indexOf(t.tagName)!==-1&&(t.removeAttribute(\"width\"),t.removeAttribute(\"height\"));for(var i=t.firstElementChild;i!==null;)this._cleanStyles(i),i=i.nextElementSibling}},_getLinkDensity:function(t){var e=this._getInnerText(t).length;if(e===0)return 0;var i=0;return this._forEachNode(t.getElementsByTagName(\"a\"),function(r){var l=r.getAttribute(\"href\"),a=l&&this.REGEXPS.hashUrl.test(l)?.3:1;i+=this._getInnerText(r).length*a}),i/e},_getClassWeight:function(t){if(!this._flagIsActive(this.FLAG_WEIGHT_CLASSES))return 0;var e=0;return typeof t.className==\"string\"&&t.className!==\"\"&&(this.REGEXPS.negative.test(t.className)&&(e-=25),this.REGEXPS.positive.test(t.className)&&(e+=25)),typeof t.id==\"string\"&&t.id!==\"\"&&(this.REGEXPS.negative.test(t.id)&&(e-=25),this.REGEXPS.positive.test(t.id)&&(e+=25)),e},_clean:function(t,e){var i=[\"object\",\"embed\",\"iframe\"].indexOf(e)!==-1;this._removeNodes(this._getAllNodesWithTag(t,[e]),function(r){if(i){for(var l=0;l<r.attributes.length;l++)if(this._allowedVideoRegex.test(r.attributes[l].value))return!1;if(r.tagName===\"object\"&&this._allowedVideoRegex.test(r.innerHTML))return!1}return!0})},_hasAncestorTag:function(t,e,i,r){i=i||3,e=e.toUpperCase();for(var l=0;t.parentNode;){if(i>0&&l>i)return!1;if(t.parentNode.tagName===e&&(!r||r(t.parentNode)))return!0;t=t.parentNode,l++}return!1},_getRowAndColumnCount:function(t){for(var e=0,i=0,r=t.getElementsByTagName(\"tr\"),l=0;l<r.length;l++){var a=r[l].getAttribute(\"rowspan\")||0;a&&(a=parseInt(a,10)),e+=a||1;for(var s=0,h=r[l].getElementsByTagName(\"td\"),c=0;c<h.length;c++){var n=h[c].getAttribute(\"colspan\")||0;n&&(n=parseInt(n,10)),s+=n||1}i=Math.max(i,s)}return{rows:e,columns:i}},_markDataTables:function(t){for(var e=t.getElementsByTagName(\"table\"),i=0;i<e.length;i++){var r=e[i],l=r.getAttribute(\"role\");if(l==\"presentation\"){r._readabilityDataTable=!1;continue}var a=r.getAttribute(\"datatable\");if(a==\"0\"){r._readabilityDataTable=!1;continue}var s=r.getAttribute(\"summary\");if(s){r._readabilityDataTable=!0;continue}var h=r.getElementsByTagName(\"caption\")[0];if(h&&h.childNodes.length>0){r._readabilityDataTable=!0;continue}var c=[\"col\",\"colgroup\",\"tfoot\",\"thead\",\"th\"],n=function(m){return!!r.getElementsByTagName(m)[0]};if(c.some(n)){this.log(\"Data table because found data-y descendant\"),r._readabilityDataTable=!0;continue}if(r.getElementsByTagName(\"table\")[0]){r._readabilityDataTable=!1;continue}var u=this._getRowAndColumnCount(r);if(u.rows>=10||u.columns>4){r._readabilityDataTable=!0;continue}r._readabilityDataTable=u.rows*u.columns>10}},_fixLazyImages:function(t){this._forEachNode(this._getAllNodesWithTag(t,[\"img\",\"picture\",\"figure\"]),function(e){if(e.src&&this.REGEXPS.b64DataUrl.test(e.src)){var i=this.REGEXPS.b64DataUrl.exec(e.src);if(i[1]===\"image/svg+xml\")return;for(var r=!1,l=0;l<e.attributes.length;l++){var a=e.attributes[l];if(a.name!==\"src\"&&/\\.(jpg|jpeg|png|webp)/i.test(a.value)){r=!0;break}}if(r){var s=e.src.search(/base64\\s*/i)+7,h=e.src.length-s;h<133&&e.removeAttribute(\"src\")}}if(!((e.src||e.srcset&&e.srcset!=\"null\")&&e.className.toLowerCase().indexOf(\"lazy\")===-1)){for(var c=0;c<e.attributes.length;c++)if(a=e.attributes[c],!(a.name===\"src\"||a.name===\"srcset\"||a.name===\"alt\")){var n=null;if(/\\.(jpg|jpeg|png|webp)\\s+\\d/.test(a.value)?n=\"srcset\":/^\\s*\\S+\\.(jpg|jpeg|png|webp)\\S*\\s*$/.test(a.value)&&(n=\"src\"),n){if(e.tagName===\"IMG\"||e.tagName===\"PICTURE\")e.setAttribute(n,a.value);else if(e.tagName===\"FIGURE\"&&!this._getAllNodesWithTag(e,[\"img\",\"picture\"]).length){var u=this._doc.createElement(\"img\");u.setAttribute(n,a.value),e.appendChild(u)}}}}})},_getTextDensity:function(t,e){var i=this._getInnerText(t,!0).length;if(i===0)return 0;var r=0,l=this._getAllNodesWithTag(t,e);return this._forEachNode(l,a=>r+=this._getInnerText(a,!0).length),r/i},_cleanConditionally:function(t,e){this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY)&&this._removeNodes(this._getAllNodesWithTag(t,[e]),function(i){var r=function(g){return g._readabilityDataTable},l=e===\"ul\"||e===\"ol\";if(!l){var a=0,s=this._getAllNodesWithTag(i,[\"ul\",\"ol\"]);this._forEachNode(s,g=>a+=this._getInnerText(g).length),l=a/this._getInnerText(i).length>.9}if(e===\"table\"&&r(i)||this._hasAncestorTag(i,\"table\",-1,r)||this._hasAncestorTag(i,\"code\"))return!1;var h=this._getClassWeight(i);this.log(\"Cleaning Conditionally\",i);var c=0;if(h+c<0)return!0;if(this._getCharCount(i,\",\")<10){for(var n=i.getElementsByTagName(\"p\").length,u=i.getElementsByTagName(\"img\").length,m=i.getElementsByTagName(\"li\").length-100,b=i.getElementsByTagName(\"input\").length,N=this._getTextDensity(i,[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"]),v=0,y=this._getAllNodesWithTag(i,[\"object\",\"embed\",\"iframe\"]),E=0;E<y.length;E++){for(var d=0;d<y[E].attributes.length;d++)if(this._allowedVideoRegex.test(y[E].attributes[d].value))return!1;if(y[E].tagName===\"object\"&&this._allowedVideoRegex.test(y[E].innerHTML))return!1;v++}var p=this._getLinkDensity(i),x=this._getInnerText(i).length,o=u>1&&n/u<.5&&!this._hasAncestorTag(i,\"figure\")||!l&&m>n||b>Math.floor(n/3)||!l&&N<.9&&x<25&&(u===0||u>2)&&!this._hasAncestorTag(i,\"figure\")||!l&&h<25&&p>.2||h>=25&&p>.5||v===1&&x<75||v>1;if(l&&o){for(var L=0;L<i.children.length;L++)if(i.children[L].children.length>1)return o;let g=i.getElementsByTagName(\"li\").length;if(u==g)return!1}return o}return!1})},_cleanMatchedNodes:function(t,e){for(var i=this._getNextNode(t,!0),r=this._getNextNode(t);r&&r!=i;)e.call(this,r,r.className+\" \"+r.id)?r=this._removeAndGetNext(r):r=this._getNextNode(r)},_cleanHeaders:function(t){let e=this._getAllNodesWithTag(t,[\"h1\",\"h2\"]);this._removeNodes(e,function(i){let r=this._getClassWeight(i)<0;return r&&this.log(\"Removing header with low class weight:\",i),r})},_headerDuplicatesTitle:function(t){if(t.tagName!=\"H1\"&&t.tagName!=\"H2\")return!1;var e=this._getInnerText(t,!1);return this.log(\"Evaluating similarity of header:\",e,this._articleTitle),this._textSimilarity(this._articleTitle,e)>.75},_flagIsActive:function(t){return(this._flags&t)>0},_removeFlag:function(t){this._flags=this._flags&~t},_isProbablyVisible:function(t){return(!t.style||t.style.display!=\"none\")&&(!t.style||t.style.visibility!=\"hidden\")&&!t.hasAttribute(\"hidden\")&&(!t.hasAttribute(\"aria-hidden\")||t.getAttribute(\"aria-hidden\")!=\"true\"||t.className&&t.className.indexOf&&t.className.indexOf(\"fallback-image\")!==-1)},parse:function(){if(this._maxElemsToParse>0){var t=this._doc.getElementsByTagName(\"*\").length;if(t>this._maxElemsToParse)throw new Error(\"Aborting parsing document; \"+t+\" elements found\")}this._unwrapNoscriptImages(this._doc);var e=this._disableJSONLD?{}:this._getJSONLD(this._doc);this._removeScripts(this._doc),this._prepDocument();var i=this._getArticleMetadata(e);this._articleTitle=i.title;var r=this._grabArticle();if(!r)return null;if(this.log(\"Grabbed: \"+r.innerHTML),this._postProcessContent(r),!i.excerpt){var l=r.getElementsByTagName(\"p\");l.length>0&&(i.excerpt=l[0].textContent.trim())}var a=r.textContent;return{title:this._articleTitle,byline:i.byline||this._articleByline,dir:this._articleDir,lang:this._articleLang,content:this._serializer(r),textContent:a,length:a.length,excerpt:i.excerpt,siteName:i.siteName||this._articleSiteName,publishedTime:i.publishedTime}}};typeof module==\"object\"&&(module.exports=q);\n";
23
+ //# sourceMappingURL=readability-script.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readability-script.d.ts","sourceRoot":"","sources":["../../src/content/readability-script.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,kBAAkB,+5gCACm++B,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ "use strict";
6
+ var __webpack_require__ = {};
7
+ (()=>{
8
+ __webpack_require__.d = (exports1, definition)=>{
9
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
10
+ enumerable: true,
11
+ get: definition[key]
12
+ });
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ READABILITY_SCRIPT: ()=>READABILITY_SCRIPT
32
+ });
33
+ const READABILITY_SCRIPT = 'function q(t,e){if(e&&e.documentElement)t=e,e=arguments[2];else if(!t||!t.documentElement)throw new Error("First argument to Readability constructor should be a document object.");if(e=e||{},this._doc=t,this._docJSDOMParser=this._doc.firstChild.__JSDOMParser__,this._articleTitle=null,this._articleByline=null,this._articleDir=null,this._articleSiteName=null,this._attempts=[],this._debug=!!e.debug,this._maxElemsToParse=e.maxElemsToParse||this.DEFAULT_MAX_ELEMS_TO_PARSE,this._nbTopCandidates=e.nbTopCandidates||this.DEFAULT_N_TOP_CANDIDATES,this._charThreshold=e.charThreshold||this.DEFAULT_CHAR_THRESHOLD,this._classesToPreserve=this.CLASSES_TO_PRESERVE.concat(e.classesToPreserve||[]),this._keepClasses=!!e.keepClasses,this._serializer=e.serializer||function(i){return i.innerHTML},this._disableJSONLD=!!e.disableJSONLD,this._allowedVideoRegex=e.allowedVideoRegex||this.REGEXPS.videos,this._flags=this.FLAG_STRIP_UNLIKELYS|this.FLAG_WEIGHT_CLASSES|this.FLAG_CLEAN_CONDITIONALLY,this._debug){let i=function(r){if(r.nodeType==r.TEXT_NODE)return`${r.nodeName} ("${r.textContent}")`;let l=Array.from(r.attributes||[],function(a){return`${a.name}="${a.value}"`}).join(" ");return`<${r.localName} ${l}>`};this.log=function(){if(typeof console!="undefined"){let l=Array.from(arguments,a=>a&&a.nodeType==this.ELEMENT_NODE?i(a):a);l.unshift("Reader: (Readability)"),console.log.apply(console,l)}else if(typeof dump!="undefined"){var r=Array.prototype.map.call(arguments,function(l){return l&&l.nodeName?i(l):l}).join(" ");dump("Reader: (Readability) "+r+`\n`)}}}else this.log=function(){}}q.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|>([^\\|]|$)|\xbb([^\\|]|$))/i,prevLink:/(prev|earl|old|new|<|\xab)/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,commas:/\\u002C|\\u060C|\\uFE50|\\uFE10|\\uFE11|\\u2E41|\\u2E34|\\u2E32|\\uFF0C/g,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(t){this._fixRelativeUris(t),this._simplifyNestedElements(t),this._keepClasses||this._cleanClasses(t)},_removeNodes:function(t,e){if(this._docJSDOMParser&&t._isLiveNodeList)throw new Error("Do not pass live node lists to _removeNodes");for(var i=t.length-1;i>=0;i--){var r=t[i],l=r.parentNode;l&&(!e||e.call(this,r,i,t))&&l.removeChild(r)}},_replaceNodeTags:function(t,e){if(this._docJSDOMParser&&t._isLiveNodeList)throw new Error("Do not pass live node lists to _replaceNodeTags");for(let i of t)this._setNodeTag(i,e)},_forEachNode:function(t,e){Array.prototype.forEach.call(t,e,this)},_findNode:function(t,e){return Array.prototype.find.call(t,e,this)},_someNode:function(t,e){return Array.prototype.some.call(t,e,this)},_everyNode:function(t,e){return Array.prototype.every.call(t,e,this)},_concatNodeLists:function(){var t=Array.prototype.slice,e=t.call(arguments),i=e.map(function(r){return t.call(r)});return Array.prototype.concat.apply([],i)},_getAllNodesWithTag:function(t,e){return t.querySelectorAll?t.querySelectorAll(e.join(",")):[].concat.apply([],e.map(function(i){var r=t.getElementsByTagName(i);return Array.isArray(r)?r:Array.from(r)}))},_cleanClasses:function(t){var e=this._classesToPreserve,i=(t.getAttribute("class")||"").split(/\\s+/).filter(function(r){return e.indexOf(r)!=-1}).join(" ");for(i?t.setAttribute("class",i):t.removeAttribute("class"),t=t.firstElementChild;t;t=t.nextElementSibling)this._cleanClasses(t)},_fixRelativeUris:function(t){var e=this._doc.baseURI,i=this._doc.documentURI;function r(s){if(e==i&&s.charAt(0)=="#")return s;try{return new URL(s,e).href}catch(h){}return s}var l=this._getAllNodesWithTag(t,["a"]);this._forEachNode(l,function(s){var h=s.getAttribute("href");if(h)if(h.indexOf("javascript:")===0)if(s.childNodes.length===1&&s.childNodes[0].nodeType===this.TEXT_NODE){var c=this._doc.createTextNode(s.textContent);s.parentNode.replaceChild(c,s)}else{for(var n=this._doc.createElement("span");s.firstChild;)n.appendChild(s.firstChild);s.parentNode.replaceChild(n,s)}else s.setAttribute("href",r(h))});var a=this._getAllNodesWithTag(t,["img","picture","figure","video","audio","source"]);this._forEachNode(a,function(s){var h=s.getAttribute("src"),c=s.getAttribute("poster"),n=s.getAttribute("srcset");if(h&&s.setAttribute("src",r(h)),c&&s.setAttribute("poster",r(c)),n){var u=n.replace(this.REGEXPS.srcsetUrl,function(m,b,N,v){return r(b)+(N||"")+v});s.setAttribute("srcset",u)}})},_simplifyNestedElements:function(t){for(var e=t;e;){if(e.parentNode&&["DIV","SECTION"].includes(e.tagName)&&!(e.id&&e.id.startsWith("readability"))){if(this._isElementWithoutContent(e)){e=this._removeAndGetNext(e);continue}else if(this._hasSingleTagInsideElement(e,"DIV")||this._hasSingleTagInsideElement(e,"SECTION")){for(var i=e.children[0],r=0;r<e.attributes.length;r++)i.setAttribute(e.attributes[r].name,e.attributes[r].value);e.parentNode.replaceChild(i,e),e=i;continue}}e=this._getNextNode(e)}},_getArticleTitle:function(){var t=this._doc,e="",i="";try{e=i=t.title.trim(),typeof e!="string"&&(e=i=this._getInnerText(t.getElementsByTagName("title")[0]))}catch(u){}var r=!1;function l(u){return u.split(/\\s+/).length}if(/ [\\|\\-\\\\\\/>\xbb] /.test(e))r=/ [\\\\\\/>\xbb] /.test(e),e=i.replace(/(.*)[\\|\\-\\\\\\/>\xbb] .*/gi,"$1"),l(e)<3&&(e=i.replace(/[^\\|\\-\\\\\\/>\xbb]*[\\|\\-\\\\\\/>\xbb](.*)/gi,"$1"));else if(e.indexOf(": ")!==-1){var a=this._concatNodeLists(t.getElementsByTagName("h1"),t.getElementsByTagName("h2")),s=e.trim(),h=this._someNode(a,function(u){return u.textContent.trim()===s});h||(e=i.substring(i.lastIndexOf(":")+1),l(e)<3?e=i.substring(i.indexOf(":")+1):l(i.substr(0,i.indexOf(":")))>5&&(e=i))}else if(e.length>150||e.length<15){var c=t.getElementsByTagName("h1");c.length===1&&(e=this._getInnerText(c[0]))}e=e.trim().replace(this.REGEXPS.normalize," ");var n=l(e);return n<=4&&(!r||n!=l(i.replace(/[\\|\\-\\\\\\/>\xbb]+/g,""))-1)&&(e=i),e},_prepDocument:function(){var t=this._doc;this._removeNodes(this._getAllNodesWithTag(t,["style"])),t.body&&this._replaceBrs(t.body),this._replaceNodeTags(this._getAllNodesWithTag(t,["font"]),"SPAN")},_nextNode:function(t){for(var e=t;e&&e.nodeType!=this.ELEMENT_NODE&&this.REGEXPS.whitespace.test(e.textContent);)e=e.nextSibling;return e},_replaceBrs:function(t){this._forEachNode(this._getAllNodesWithTag(t,["br"]),function(e){for(var i=e.nextSibling,r=!1;(i=this._nextNode(i))&&i.tagName=="BR";){r=!0;var l=i.nextSibling;i.parentNode.removeChild(i),i=l}if(r){var a=this._doc.createElement("p");for(e.parentNode.replaceChild(a,e),i=a.nextSibling;i;){if(i.tagName=="BR"){var s=this._nextNode(i.nextSibling);if(s&&s.tagName=="BR")break}if(!this._isPhrasingContent(i))break;var h=i.nextSibling;a.appendChild(i),i=h}for(;a.lastChild&&this._isWhitespace(a.lastChild);)a.removeChild(a.lastChild);a.parentNode.tagName==="P"&&this._setNodeTag(a.parentNode,"DIV")}})},_setNodeTag:function(t,e){if(this.log("_setNodeTag",t,e),this._docJSDOMParser)return t.localName=e.toLowerCase(),t.tagName=e.toUpperCase(),t;for(var i=t.ownerDocument.createElement(e);t.firstChild;)i.appendChild(t.firstChild);t.parentNode.replaceChild(i,t),t.readability&&(i.readability=t.readability);for(var r=0;r<t.attributes.length;r++)try{i.setAttribute(t.attributes[r].name,t.attributes[r].value)}catch(l){}return i},_prepArticle:function(t){this._cleanStyles(t),this._markDataTables(t),this._fixLazyImages(t),this._cleanConditionally(t,"form"),this._cleanConditionally(t,"fieldset"),this._clean(t,"object"),this._clean(t,"embed"),this._clean(t,"footer"),this._clean(t,"link"),this._clean(t,"aside");var e=this.DEFAULT_CHAR_THRESHOLD;this._forEachNode(t.children,function(i){this._cleanMatchedNodes(i,function(r,l){return this.REGEXPS.shareElements.test(l)&&r.textContent.length<e})}),this._clean(t,"iframe"),this._clean(t,"input"),this._clean(t,"textarea"),this._clean(t,"select"),this._clean(t,"button"),this._cleanHeaders(t),this._cleanConditionally(t,"table"),this._cleanConditionally(t,"ul"),this._cleanConditionally(t,"div"),this._replaceNodeTags(this._getAllNodesWithTag(t,["h1"]),"h2"),this._removeNodes(this._getAllNodesWithTag(t,["p"]),function(i){var r=i.getElementsByTagName("img").length,l=i.getElementsByTagName("embed").length,a=i.getElementsByTagName("object").length,s=i.getElementsByTagName("iframe").length,h=r+l+a+s;return h===0&&!this._getInnerText(i,!1)}),this._forEachNode(this._getAllNodesWithTag(t,["br"]),function(i){var r=this._nextNode(i.nextSibling);r&&r.tagName=="P"&&i.parentNode.removeChild(i)}),this._forEachNode(this._getAllNodesWithTag(t,["table"]),function(i){var r=this._hasSingleTagInsideElement(i,"TBODY")?i.firstElementChild:i;if(this._hasSingleTagInsideElement(r,"TR")){var l=r.firstElementChild;if(this._hasSingleTagInsideElement(l,"TD")){var a=l.firstElementChild;a=this._setNodeTag(a,this._everyNode(a.childNodes,this._isPhrasingContent)?"P":"DIV"),i.parentNode.replaceChild(a,i)}}})},_initializeNode:function(t){switch(t.readability={contentScore:0},t.tagName){case"DIV":t.readability.contentScore+=5;break;case"PRE":case"TD":case"BLOCKQUOTE":t.readability.contentScore+=3;break;case"ADDRESS":case"OL":case"UL":case"DL":case"DD":case"DT":case"LI":case"FORM":t.readability.contentScore-=3;break;case"H1":case"H2":case"H3":case"H4":case"H5":case"H6":case"TH":t.readability.contentScore-=5;break}t.readability.contentScore+=this._getClassWeight(t)},_removeAndGetNext:function(t){var e=this._getNextNode(t,!0);return t.parentNode.removeChild(t),e},_getNextNode:function(t,e){if(!e&&t.firstElementChild)return t.firstElementChild;if(t.nextElementSibling)return t.nextElementSibling;do t=t.parentNode;while(t&&!t.nextElementSibling);return t&&t.nextElementSibling},_textSimilarity:function(t,e){var i=t.toLowerCase().split(this.REGEXPS.tokenize).filter(Boolean),r=e.toLowerCase().split(this.REGEXPS.tokenize).filter(Boolean);if(!i.length||!r.length)return 0;var l=r.filter(s=>!i.includes(s)),a=l.join(" ").length/r.join(" ").length;return 1-a},_checkByline:function(t,e){if(this._articleByline)return!1;if(t.getAttribute!==void 0)var i=t.getAttribute("rel"),r=t.getAttribute("itemprop");return(i==="author"||r&&r.indexOf("author")!==-1||this.REGEXPS.byline.test(e))&&this._isValidByline(t.textContent)?(this._articleByline=t.textContent.trim(),!0):!1},_getNodeAncestors:function(t,e){e=e||0;for(var i=0,r=[];t.parentNode&&(r.push(t.parentNode),!(e&&++i===e));)t=t.parentNode;return r},_grabArticle:function(t){this.log("**** grabArticle ****");var e=this._doc,i=t!==null;if(t=t||this._doc.body,!t)return this.log("No body found in document. Abort."),null;for(var r=t.innerHTML;;){this.log("Starting grabArticle loop");var l=this._flagIsActive(this.FLAG_STRIP_UNLIKELYS),a=[],s=this._doc.documentElement;let J=!0;for(;s;){s.tagName==="HTML"&&(this._articleLang=s.getAttribute("lang"));var h=s.className+" "+s.id;if(!this._isProbablyVisible(s)){this.log("Removing hidden node - "+h),s=this._removeAndGetNext(s);continue}if(s.getAttribute("aria-modal")=="true"&&s.getAttribute("role")=="dialog"){s=this._removeAndGetNext(s);continue}if(this._checkByline(s,h)){s=this._removeAndGetNext(s);continue}if(J&&this._headerDuplicatesTitle(s)){this.log("Removing header: ",s.textContent.trim(),this._articleTitle.trim()),J=!1,s=this._removeAndGetNext(s);continue}if(l){if(this.REGEXPS.unlikelyCandidates.test(h)&&!this.REGEXPS.okMaybeItsACandidate.test(h)&&!this._hasAncestorTag(s,"table")&&!this._hasAncestorTag(s,"code")&&s.tagName!=="BODY"&&s.tagName!=="A"){this.log("Removing unlikely candidate - "+h),s=this._removeAndGetNext(s);continue}if(this.UNLIKELY_ROLES.includes(s.getAttribute("role"))){this.log("Removing content with role "+s.getAttribute("role")+" - "+h),s=this._removeAndGetNext(s);continue}}if((s.tagName==="DIV"||s.tagName==="SECTION"||s.tagName==="HEADER"||s.tagName==="H1"||s.tagName==="H2"||s.tagName==="H3"||s.tagName==="H4"||s.tagName==="H5"||s.tagName==="H6")&&this._isElementWithoutContent(s)){s=this._removeAndGetNext(s);continue}if(this.DEFAULT_TAGS_TO_SCORE.indexOf(s.tagName)!==-1&&a.push(s),s.tagName==="DIV"){for(var c=null,n=s.firstChild;n;){var u=n.nextSibling;if(this._isPhrasingContent(n))c!==null?c.appendChild(n):this._isWhitespace(n)||(c=e.createElement("p"),s.replaceChild(c,n),c.appendChild(n));else if(c!==null){for(;c.lastChild&&this._isWhitespace(c.lastChild);)c.removeChild(c.lastChild);c=null}n=u}if(this._hasSingleTagInsideElement(s,"P")&&this._getLinkDensity(s)<.25){var m=s.children[0];s.parentNode.replaceChild(m,s),s=m,a.push(s)}else this._hasChildBlockElement(s)||(s=this._setNodeTag(s,"P"),a.push(s))}s=this._getNextNode(s)}var b=[];this._forEachNode(a,function(A){if(!(!A.parentNode||typeof A.parentNode.tagName=="undefined")){var T=this._getInnerText(A);if(!(T.length<25)){var K=this._getNodeAncestors(A,5);if(K.length!==0){var C=0;C+=1,C+=T.split(this.REGEXPS.commas).length,C+=Math.min(Math.floor(T.length/100),3),this._forEachNode(K,function(S,F){if(!(!S.tagName||!S.parentNode||typeof S.parentNode.tagName=="undefined")){if(typeof S.readability=="undefined"&&(this._initializeNode(S),b.push(S)),F===0)var X=1;else F===1?X=2:X=F*3;S.readability.contentScore+=C/X}})}}}});for(var N=[],v=0,y=b.length;v<y;v+=1){var E=b[v],d=E.readability.contentScore*(1-this._getLinkDensity(E));E.readability.contentScore=d,this.log("Candidate:",E,"with score "+d);for(var p=0;p<this._nbTopCandidates;p++){var x=N[p];if(!x||d>x.readability.contentScore){N.splice(p,0,E),N.length>this._nbTopCandidates&&N.pop();break}}}var o=N[0]||null,L=!1,g;if(o===null||o.tagName==="BODY"){for(o=e.createElement("DIV"),L=!0;t.firstChild;)this.log("Moving child out:",t.firstChild),o.appendChild(t.firstChild);t.appendChild(o),this._initializeNode(o)}else if(o){for(var I=[],P=1;P<N.length;P++)N[P].readability.contentScore/o.readability.contentScore>=.75&&I.push(this._getNodeAncestors(N[P]));var O=3;if(I.length>=O)for(g=o.parentNode;g.tagName!=="BODY";){for(var G=0,H=0;H<I.length&&G<O;H++)G+=Number(I[H].includes(g));if(G>=O){o=g;break}g=g.parentNode}o.readability||this._initializeNode(o),g=o.parentNode;for(var M=o.readability.contentScore,Q=M/3;g.tagName!=="BODY";){if(!g.readability){g=g.parentNode;continue}var V=g.readability.contentScore;if(V<Q)break;if(V>M){o=g;break}M=g.readability.contentScore,g=g.parentNode}for(g=o.parentNode;g.tagName!="BODY"&&g.children.length==1;)o=g,g=o.parentNode;o.readability||this._initializeNode(o)}var _=e.createElement("DIV");i&&(_.id="readability-content");var Z=Math.max(10,o.readability.contentScore*.2);g=o.parentNode;for(var U=g.children,w=0,j=U.length;w<j;w++){var f=U[w],R=!1;if(this.log("Looking at sibling node:",f,f.readability?"with score "+f.readability.contentScore:""),this.log("Sibling has score",f.readability?f.readability.contentScore:"Unknown"),f===o)R=!0;else{var $=0;if(f.className===o.className&&o.className!==""&&($+=o.readability.contentScore*.2),f.readability&&f.readability.contentScore+$>=Z)R=!0;else if(f.nodeName==="P"){var Y=this._getLinkDensity(f),z=this._getInnerText(f),k=z.length;(k>80&&Y<.25||k<80&&k>0&&Y===0&&z.search(/\\.( |$)/)!==-1)&&(R=!0)}}R&&(this.log("Appending node:",f),this.ALTER_TO_DIV_EXCEPTIONS.indexOf(f.nodeName)===-1&&(this.log("Altering sibling:",f,"to div."),f=this._setNodeTag(f,"DIV")),_.appendChild(f),U=g.children,w-=1,j-=1)}if(this._debug&&this.log("Article content pre-prep: "+_.innerHTML),this._prepArticle(_),this._debug&&this.log("Article content post-prep: "+_.innerHTML),L)o.id="readability-page-1",o.className="page";else{var B=e.createElement("DIV");for(B.id="readability-page-1",B.className="page";_.firstChild;)B.appendChild(_.firstChild);_.appendChild(B)}this._debug&&this.log("Article content after paging: "+_.innerHTML);var W=!0,D=this._getInnerText(_,!0).length;if(D<this._charThreshold)if(W=!1,t.innerHTML=r,this._flagIsActive(this.FLAG_STRIP_UNLIKELYS))this._removeFlag(this.FLAG_STRIP_UNLIKELYS),this._attempts.push({articleContent:_,textLength:D});else if(this._flagIsActive(this.FLAG_WEIGHT_CLASSES))this._removeFlag(this.FLAG_WEIGHT_CLASSES),this._attempts.push({articleContent:_,textLength:D});else if(this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY))this._removeFlag(this.FLAG_CLEAN_CONDITIONALLY),this._attempts.push({articleContent:_,textLength:D});else{if(this._attempts.push({articleContent:_,textLength:D}),this._attempts.sort(function(A,T){return T.textLength-A.textLength}),!this._attempts[0].textLength)return null;_=this._attempts[0].articleContent,W=!0}if(W){var tt=[g,o].concat(this._getNodeAncestors(g));return this._someNode(tt,function(A){if(!A.tagName)return!1;var T=A.getAttribute("dir");return T?(this._articleDir=T,!0):!1}),_}}},_isValidByline:function(t){return typeof t=="string"||t instanceof String?(t=t.trim(),t.length>0&&t.length<100):!1},_unescapeHtmlEntities:function(t){if(!t)return t;var e=this.HTML_ESCAPE_MAP;return t.replace(/&(quot|amp|apos|lt|gt);/g,function(i,r){return e[r]}).replace(/&#(?:x([0-9a-z]{1,4})|([0-9]{1,4}));/gi,function(i,r,l){var a=parseInt(r||l,r?16:10);return String.fromCharCode(a)})},_getJSONLD:function(t){var e=this._getAllNodesWithTag(t,["script"]),i;return this._forEachNode(e,function(r){if(!i&&r.getAttribute("type")==="application/ld+json")try{var l=r.textContent.replace(/^\\s*<!\\[CDATA\\[|\\]\\]>\\s*$/g,""),a=JSON.parse(l);if(!a["@context"]||!a["@context"].match(/^https?\\:\\/\\/schema\\.org$/)||(!a["@type"]&&Array.isArray(a["@graph"])&&(a=a["@graph"].find(function(n){return(n["@type"]||"").match(this.REGEXPS.jsonLdArticleTypes)})),!a||!a["@type"]||!a["@type"].match(this.REGEXPS.jsonLdArticleTypes)))return;if(i={},typeof a.name=="string"&&typeof a.headline=="string"&&a.name!==a.headline){var s=this._getArticleTitle(),h=this._textSimilarity(a.name,s)>.75,c=this._textSimilarity(a.headline,s)>.75;c&&!h?i.title=a.headline:i.title=a.name}else typeof a.name=="string"?i.title=a.name.trim():typeof a.headline=="string"&&(i.title=a.headline.trim());a.author&&(typeof a.author.name=="string"?i.byline=a.author.name.trim():Array.isArray(a.author)&&a.author[0]&&typeof a.author[0].name=="string"&&(i.byline=a.author.filter(function(n){return n&&typeof n.name=="string"}).map(function(n){return n.name.trim()}).join(", "))),typeof a.description=="string"&&(i.excerpt=a.description.trim()),a.publisher&&typeof a.publisher.name=="string"&&(i.siteName=a.publisher.name.trim()),typeof a.datePublished=="string"&&(i.datePublished=a.datePublished.trim());return}catch(n){this.log(n.message)}}),i||{}},_getArticleMetadata:function(t){var e={},i={},r=this._doc.getElementsByTagName("meta"),l=/\\s*(article|dc|dcterm|og|twitter)\\s*:\\s*(author|creator|description|published_time|title|site_name)\\s*/gi,a=/^\\s*(?:(dc|dcterm|og|twitter|weibo:(article|webpage))\\s*[\\.:]\\s*)?(author|creator|description|title|site_name)\\s*$/i;return this._forEachNode(r,function(s){var h=s.getAttribute("name"),c=s.getAttribute("property"),n=s.getAttribute("content");if(n){var u=null,m=null;c&&(u=c.match(l),u&&(m=u[0].toLowerCase().replace(/\\s/g,""),i[m]=n.trim())),!u&&h&&a.test(h)&&(m=h,n&&(m=m.toLowerCase().replace(/\\s/g,"").replace(/\\./g,":"),i[m]=n.trim()))}}),e.title=t.title||i["dc:title"]||i["dcterm:title"]||i["og:title"]||i["weibo:article:title"]||i["weibo:webpage:title"]||i.title||i["twitter:title"],e.title||(e.title=this._getArticleTitle()),e.byline=t.byline||i["dc:creator"]||i["dcterm:creator"]||i.author,e.excerpt=t.excerpt||i["dc:description"]||i["dcterm:description"]||i["og:description"]||i["weibo:article:description"]||i["weibo:webpage:description"]||i.description||i["twitter:description"],e.siteName=t.siteName||i["og:site_name"],e.publishedTime=t.datePublished||i["article:published_time"]||null,e.title=this._unescapeHtmlEntities(e.title),e.byline=this._unescapeHtmlEntities(e.byline),e.excerpt=this._unescapeHtmlEntities(e.excerpt),e.siteName=this._unescapeHtmlEntities(e.siteName),e.publishedTime=this._unescapeHtmlEntities(e.publishedTime),e},_isSingleImage:function(t){return t.tagName==="IMG"?!0:t.children.length!==1||t.textContent.trim()!==""?!1:this._isSingleImage(t.children[0])},_unwrapNoscriptImages:function(t){var e=Array.from(t.getElementsByTagName("img"));this._forEachNode(e,function(r){for(var l=0;l<r.attributes.length;l++){var a=r.attributes[l];switch(a.name){case"src":case"srcset":case"data-src":case"data-srcset":return}if(/\\.(jpg|jpeg|png|webp)/i.test(a.value))return}r.parentNode.removeChild(r)});var i=Array.from(t.getElementsByTagName("noscript"));this._forEachNode(i,function(r){var l=t.createElement("div");if(l.innerHTML=r.innerHTML,!!this._isSingleImage(l)){var a=r.previousElementSibling;if(a&&this._isSingleImage(a)){var s=a;s.tagName!=="IMG"&&(s=a.getElementsByTagName("img")[0]);for(var h=l.getElementsByTagName("img")[0],c=0;c<s.attributes.length;c++){var n=s.attributes[c];if(n.value!==""&&(n.name==="src"||n.name==="srcset"||/\\.(jpg|jpeg|png|webp)/i.test(n.value))){if(h.getAttribute(n.name)===n.value)continue;var u=n.name;h.hasAttribute(u)&&(u="data-old-"+u),h.setAttribute(u,n.value)}}r.parentNode.replaceChild(l.firstElementChild,a)}}})},_removeScripts:function(t){this._removeNodes(this._getAllNodesWithTag(t,["script","noscript"]))},_hasSingleTagInsideElement:function(t,e){return t.children.length!=1||t.children[0].tagName!==e?!1:!this._someNode(t.childNodes,function(i){return i.nodeType===this.TEXT_NODE&&this.REGEXPS.hasContent.test(i.textContent)})},_isElementWithoutContent:function(t){return t.nodeType===this.ELEMENT_NODE&&t.textContent.trim().length==0&&(t.children.length==0||t.children.length==t.getElementsByTagName("br").length+t.getElementsByTagName("hr").length)},_hasChildBlockElement:function(t){return this._someNode(t.childNodes,function(e){return this.DIV_TO_P_ELEMS.has(e.tagName)||this._hasChildBlockElement(e)})},_isPhrasingContent:function(t){return t.nodeType===this.TEXT_NODE||this.PHRASING_ELEMS.indexOf(t.tagName)!==-1||(t.tagName==="A"||t.tagName==="DEL"||t.tagName==="INS")&&this._everyNode(t.childNodes,this._isPhrasingContent)},_isWhitespace:function(t){return t.nodeType===this.TEXT_NODE&&t.textContent.trim().length===0||t.nodeType===this.ELEMENT_NODE&&t.tagName==="BR"},_getInnerText:function(t,e){e=typeof e=="undefined"?!0:e;var i=t.textContent.trim();return e?i.replace(this.REGEXPS.normalize," "):i},_getCharCount:function(t,e){return e=e||",",this._getInnerText(t).split(e).length-1},_cleanStyles:function(t){if(!(!t||t.tagName.toLowerCase()==="svg")){for(var e=0;e<this.PRESENTATIONAL_ATTRIBUTES.length;e++)t.removeAttribute(this.PRESENTATIONAL_ATTRIBUTES[e]);this.DEPRECATED_SIZE_ATTRIBUTE_ELEMS.indexOf(t.tagName)!==-1&&(t.removeAttribute("width"),t.removeAttribute("height"));for(var i=t.firstElementChild;i!==null;)this._cleanStyles(i),i=i.nextElementSibling}},_getLinkDensity:function(t){var e=this._getInnerText(t).length;if(e===0)return 0;var i=0;return this._forEachNode(t.getElementsByTagName("a"),function(r){var l=r.getAttribute("href"),a=l&&this.REGEXPS.hashUrl.test(l)?.3:1;i+=this._getInnerText(r).length*a}),i/e},_getClassWeight:function(t){if(!this._flagIsActive(this.FLAG_WEIGHT_CLASSES))return 0;var e=0;return typeof t.className=="string"&&t.className!==""&&(this.REGEXPS.negative.test(t.className)&&(e-=25),this.REGEXPS.positive.test(t.className)&&(e+=25)),typeof t.id=="string"&&t.id!==""&&(this.REGEXPS.negative.test(t.id)&&(e-=25),this.REGEXPS.positive.test(t.id)&&(e+=25)),e},_clean:function(t,e){var i=["object","embed","iframe"].indexOf(e)!==-1;this._removeNodes(this._getAllNodesWithTag(t,[e]),function(r){if(i){for(var l=0;l<r.attributes.length;l++)if(this._allowedVideoRegex.test(r.attributes[l].value))return!1;if(r.tagName==="object"&&this._allowedVideoRegex.test(r.innerHTML))return!1}return!0})},_hasAncestorTag:function(t,e,i,r){i=i||3,e=e.toUpperCase();for(var l=0;t.parentNode;){if(i>0&&l>i)return!1;if(t.parentNode.tagName===e&&(!r||r(t.parentNode)))return!0;t=t.parentNode,l++}return!1},_getRowAndColumnCount:function(t){for(var e=0,i=0,r=t.getElementsByTagName("tr"),l=0;l<r.length;l++){var a=r[l].getAttribute("rowspan")||0;a&&(a=parseInt(a,10)),e+=a||1;for(var s=0,h=r[l].getElementsByTagName("td"),c=0;c<h.length;c++){var n=h[c].getAttribute("colspan")||0;n&&(n=parseInt(n,10)),s+=n||1}i=Math.max(i,s)}return{rows:e,columns:i}},_markDataTables:function(t){for(var e=t.getElementsByTagName("table"),i=0;i<e.length;i++){var r=e[i],l=r.getAttribute("role");if(l=="presentation"){r._readabilityDataTable=!1;continue}var a=r.getAttribute("datatable");if(a=="0"){r._readabilityDataTable=!1;continue}var s=r.getAttribute("summary");if(s){r._readabilityDataTable=!0;continue}var h=r.getElementsByTagName("caption")[0];if(h&&h.childNodes.length>0){r._readabilityDataTable=!0;continue}var c=["col","colgroup","tfoot","thead","th"],n=function(m){return!!r.getElementsByTagName(m)[0]};if(c.some(n)){this.log("Data table because found data-y descendant"),r._readabilityDataTable=!0;continue}if(r.getElementsByTagName("table")[0]){r._readabilityDataTable=!1;continue}var u=this._getRowAndColumnCount(r);if(u.rows>=10||u.columns>4){r._readabilityDataTable=!0;continue}r._readabilityDataTable=u.rows*u.columns>10}},_fixLazyImages:function(t){this._forEachNode(this._getAllNodesWithTag(t,["img","picture","figure"]),function(e){if(e.src&&this.REGEXPS.b64DataUrl.test(e.src)){var i=this.REGEXPS.b64DataUrl.exec(e.src);if(i[1]==="image/svg+xml")return;for(var r=!1,l=0;l<e.attributes.length;l++){var a=e.attributes[l];if(a.name!=="src"&&/\\.(jpg|jpeg|png|webp)/i.test(a.value)){r=!0;break}}if(r){var s=e.src.search(/base64\\s*/i)+7,h=e.src.length-s;h<133&&e.removeAttribute("src")}}if(!((e.src||e.srcset&&e.srcset!="null")&&e.className.toLowerCase().indexOf("lazy")===-1)){for(var c=0;c<e.attributes.length;c++)if(a=e.attributes[c],!(a.name==="src"||a.name==="srcset"||a.name==="alt")){var n=null;if(/\\.(jpg|jpeg|png|webp)\\s+\\d/.test(a.value)?n="srcset":/^\\s*\\S+\\.(jpg|jpeg|png|webp)\\S*\\s*$/.test(a.value)&&(n="src"),n){if(e.tagName==="IMG"||e.tagName==="PICTURE")e.setAttribute(n,a.value);else if(e.tagName==="FIGURE"&&!this._getAllNodesWithTag(e,["img","picture"]).length){var u=this._doc.createElement("img");u.setAttribute(n,a.value),e.appendChild(u)}}}}})},_getTextDensity:function(t,e){var i=this._getInnerText(t,!0).length;if(i===0)return 0;var r=0,l=this._getAllNodesWithTag(t,e);return this._forEachNode(l,a=>r+=this._getInnerText(a,!0).length),r/i},_cleanConditionally:function(t,e){this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY)&&this._removeNodes(this._getAllNodesWithTag(t,[e]),function(i){var r=function(g){return g._readabilityDataTable},l=e==="ul"||e==="ol";if(!l){var a=0,s=this._getAllNodesWithTag(i,["ul","ol"]);this._forEachNode(s,g=>a+=this._getInnerText(g).length),l=a/this._getInnerText(i).length>.9}if(e==="table"&&r(i)||this._hasAncestorTag(i,"table",-1,r)||this._hasAncestorTag(i,"code"))return!1;var h=this._getClassWeight(i);this.log("Cleaning Conditionally",i);var c=0;if(h+c<0)return!0;if(this._getCharCount(i,",")<10){for(var n=i.getElementsByTagName("p").length,u=i.getElementsByTagName("img").length,m=i.getElementsByTagName("li").length-100,b=i.getElementsByTagName("input").length,N=this._getTextDensity(i,["h1","h2","h3","h4","h5","h6"]),v=0,y=this._getAllNodesWithTag(i,["object","embed","iframe"]),E=0;E<y.length;E++){for(var d=0;d<y[E].attributes.length;d++)if(this._allowedVideoRegex.test(y[E].attributes[d].value))return!1;if(y[E].tagName==="object"&&this._allowedVideoRegex.test(y[E].innerHTML))return!1;v++}var p=this._getLinkDensity(i),x=this._getInnerText(i).length,o=u>1&&n/u<.5&&!this._hasAncestorTag(i,"figure")||!l&&m>n||b>Math.floor(n/3)||!l&&N<.9&&x<25&&(u===0||u>2)&&!this._hasAncestorTag(i,"figure")||!l&&h<25&&p>.2||h>=25&&p>.5||v===1&&x<75||v>1;if(l&&o){for(var L=0;L<i.children.length;L++)if(i.children[L].children.length>1)return o;let g=i.getElementsByTagName("li").length;if(u==g)return!1}return o}return!1})},_cleanMatchedNodes:function(t,e){for(var i=this._getNextNode(t,!0),r=this._getNextNode(t);r&&r!=i;)e.call(this,r,r.className+" "+r.id)?r=this._removeAndGetNext(r):r=this._getNextNode(r)},_cleanHeaders:function(t){let e=this._getAllNodesWithTag(t,["h1","h2"]);this._removeNodes(e,function(i){let r=this._getClassWeight(i)<0;return r&&this.log("Removing header with low class weight:",i),r})},_headerDuplicatesTitle:function(t){if(t.tagName!="H1"&&t.tagName!="H2")return!1;var e=this._getInnerText(t,!1);return this.log("Evaluating similarity of header:",e,this._articleTitle),this._textSimilarity(this._articleTitle,e)>.75},_flagIsActive:function(t){return(this._flags&t)>0},_removeFlag:function(t){this._flags=this._flags&~t},_isProbablyVisible:function(t){return(!t.style||t.style.display!="none")&&(!t.style||t.style.visibility!="hidden")&&!t.hasAttribute("hidden")&&(!t.hasAttribute("aria-hidden")||t.getAttribute("aria-hidden")!="true"||t.className&&t.className.indexOf&&t.className.indexOf("fallback-image")!==-1)},parse:function(){if(this._maxElemsToParse>0){var t=this._doc.getElementsByTagName("*").length;if(t>this._maxElemsToParse)throw new Error("Aborting parsing document; "+t+" elements found")}this._unwrapNoscriptImages(this._doc);var e=this._disableJSONLD?{}:this._getJSONLD(this._doc);this._removeScripts(this._doc),this._prepDocument();var i=this._getArticleMetadata(e);this._articleTitle=i.title;var r=this._grabArticle();if(!r)return null;if(this.log("Grabbed: "+r.innerHTML),this._postProcessContent(r),!i.excerpt){var l=r.getElementsByTagName("p");l.length>0&&(i.excerpt=l[0].textContent.trim())}var a=r.textContent;return{title:this._articleTitle,byline:i.byline||this._articleByline,dir:this._articleDir,lang:this._articleLang,content:this._serializer(r),textContent:a,length:a.length,excerpt:i.excerpt,siteName:i.siteName||this._articleSiteName,publishedTime:i.publishedTime}}};typeof module=="object"&&(module.exports=q);\n';
34
+ exports.READABILITY_SCRIPT = __webpack_exports__.READABILITY_SCRIPT;
35
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
36
+ "READABILITY_SCRIPT"
37
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
38
+ Object.defineProperty(exports, '__esModule', {
39
+ value: true
40
+ });
41
+
42
+ //# sourceMappingURL=readability-script.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content/readability-script.js","sources":["webpack://@agent-infra/browser-context/webpack/runtime/define_property_getters","webpack://@agent-infra/browser-context/webpack/runtime/has_own_property","webpack://@agent-infra/browser-context/webpack/runtime/make_namespace_object","webpack://@agent-infra/browser-context/./src/content/readability-script.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * PLEASE DO NOT MODIFY IT as it is generated by the build script\n *\n * Build: scripts/build-readability.ts\n * Source: https://github.com/mozilla/readability/blob/main/Readability.js\n */\n\n/**\n * Copyright (c) 2010 Arc90 Inc\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const READABILITY_SCRIPT =\n 'function q(t,e){if(e&&e.documentElement)t=e,e=arguments[2];else if(!t||!t.documentElement)throw new Error(\"First argument to Readability constructor should be a document object.\");if(e=e||{},this._doc=t,this._docJSDOMParser=this._doc.firstChild.__JSDOMParser__,this._articleTitle=null,this._articleByline=null,this._articleDir=null,this._articleSiteName=null,this._attempts=[],this._debug=!!e.debug,this._maxElemsToParse=e.maxElemsToParse||this.DEFAULT_MAX_ELEMS_TO_PARSE,this._nbTopCandidates=e.nbTopCandidates||this.DEFAULT_N_TOP_CANDIDATES,this._charThreshold=e.charThreshold||this.DEFAULT_CHAR_THRESHOLD,this._classesToPreserve=this.CLASSES_TO_PRESERVE.concat(e.classesToPreserve||[]),this._keepClasses=!!e.keepClasses,this._serializer=e.serializer||function(i){return i.innerHTML},this._disableJSONLD=!!e.disableJSONLD,this._allowedVideoRegex=e.allowedVideoRegex||this.REGEXPS.videos,this._flags=this.FLAG_STRIP_UNLIKELYS|this.FLAG_WEIGHT_CLASSES|this.FLAG_CLEAN_CONDITIONALLY,this._debug){let i=function(r){if(r.nodeType==r.TEXT_NODE)return`${r.nodeName} (\"${r.textContent}\")`;let l=Array.from(r.attributes||[],function(a){return`${a.name}=\"${a.value}\"`}).join(\" \");return`<${r.localName} ${l}>`};this.log=function(){if(typeof console!=\"undefined\"){let l=Array.from(arguments,a=>a&&a.nodeType==this.ELEMENT_NODE?i(a):a);l.unshift(\"Reader: (Readability)\"),console.log.apply(console,l)}else if(typeof dump!=\"undefined\"){var r=Array.prototype.map.call(arguments,function(l){return l&&l.nodeName?i(l):l}).join(\" \");dump(\"Reader: (Readability) \"+r+`\\n`)}}}else this.log=function(){}}q.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,commas:/\\\\u002C|\\\\u060C|\\\\uFE50|\\\\uFE10|\\\\uFE11|\\\\u2E41|\\\\u2E34|\\\\u2E32|\\\\uFF0C/g,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(t){this._fixRelativeUris(t),this._simplifyNestedElements(t),this._keepClasses||this._cleanClasses(t)},_removeNodes:function(t,e){if(this._docJSDOMParser&&t._isLiveNodeList)throw new Error(\"Do not pass live node lists to _removeNodes\");for(var i=t.length-1;i>=0;i--){var r=t[i],l=r.parentNode;l&&(!e||e.call(this,r,i,t))&&l.removeChild(r)}},_replaceNodeTags:function(t,e){if(this._docJSDOMParser&&t._isLiveNodeList)throw new Error(\"Do not pass live node lists to _replaceNodeTags\");for(let i of t)this._setNodeTag(i,e)},_forEachNode:function(t,e){Array.prototype.forEach.call(t,e,this)},_findNode:function(t,e){return Array.prototype.find.call(t,e,this)},_someNode:function(t,e){return Array.prototype.some.call(t,e,this)},_everyNode:function(t,e){return Array.prototype.every.call(t,e,this)},_concatNodeLists:function(){var t=Array.prototype.slice,e=t.call(arguments),i=e.map(function(r){return t.call(r)});return Array.prototype.concat.apply([],i)},_getAllNodesWithTag:function(t,e){return t.querySelectorAll?t.querySelectorAll(e.join(\",\")):[].concat.apply([],e.map(function(i){var r=t.getElementsByTagName(i);return Array.isArray(r)?r:Array.from(r)}))},_cleanClasses:function(t){var e=this._classesToPreserve,i=(t.getAttribute(\"class\")||\"\").split(/\\\\s+/).filter(function(r){return e.indexOf(r)!=-1}).join(\" \");for(i?t.setAttribute(\"class\",i):t.removeAttribute(\"class\"),t=t.firstElementChild;t;t=t.nextElementSibling)this._cleanClasses(t)},_fixRelativeUris:function(t){var e=this._doc.baseURI,i=this._doc.documentURI;function r(s){if(e==i&&s.charAt(0)==\"#\")return s;try{return new URL(s,e).href}catch(h){}return s}var l=this._getAllNodesWithTag(t,[\"a\"]);this._forEachNode(l,function(s){var h=s.getAttribute(\"href\");if(h)if(h.indexOf(\"javascript:\")===0)if(s.childNodes.length===1&&s.childNodes[0].nodeType===this.TEXT_NODE){var c=this._doc.createTextNode(s.textContent);s.parentNode.replaceChild(c,s)}else{for(var n=this._doc.createElement(\"span\");s.firstChild;)n.appendChild(s.firstChild);s.parentNode.replaceChild(n,s)}else s.setAttribute(\"href\",r(h))});var a=this._getAllNodesWithTag(t,[\"img\",\"picture\",\"figure\",\"video\",\"audio\",\"source\"]);this._forEachNode(a,function(s){var h=s.getAttribute(\"src\"),c=s.getAttribute(\"poster\"),n=s.getAttribute(\"srcset\");if(h&&s.setAttribute(\"src\",r(h)),c&&s.setAttribute(\"poster\",r(c)),n){var u=n.replace(this.REGEXPS.srcsetUrl,function(m,b,N,v){return r(b)+(N||\"\")+v});s.setAttribute(\"srcset\",u)}})},_simplifyNestedElements:function(t){for(var e=t;e;){if(e.parentNode&&[\"DIV\",\"SECTION\"].includes(e.tagName)&&!(e.id&&e.id.startsWith(\"readability\"))){if(this._isElementWithoutContent(e)){e=this._removeAndGetNext(e);continue}else if(this._hasSingleTagInsideElement(e,\"DIV\")||this._hasSingleTagInsideElement(e,\"SECTION\")){for(var i=e.children[0],r=0;r<e.attributes.length;r++)i.setAttribute(e.attributes[r].name,e.attributes[r].value);e.parentNode.replaceChild(i,e),e=i;continue}}e=this._getNextNode(e)}},_getArticleTitle:function(){var t=this._doc,e=\"\",i=\"\";try{e=i=t.title.trim(),typeof e!=\"string\"&&(e=i=this._getInnerText(t.getElementsByTagName(\"title\")[0]))}catch(u){}var r=!1;function l(u){return u.split(/\\\\s+/).length}if(/ [\\\\|\\\\-\\\\\\\\\\\\/>»] /.test(e))r=/ [\\\\\\\\\\\\/>»] /.test(e),e=i.replace(/(.*)[\\\\|\\\\-\\\\\\\\\\\\/>»] .*/gi,\"$1\"),l(e)<3&&(e=i.replace(/[^\\\\|\\\\-\\\\\\\\\\\\/>»]*[\\\\|\\\\-\\\\\\\\\\\\/>»](.*)/gi,\"$1\"));else if(e.indexOf(\": \")!==-1){var a=this._concatNodeLists(t.getElementsByTagName(\"h1\"),t.getElementsByTagName(\"h2\")),s=e.trim(),h=this._someNode(a,function(u){return u.textContent.trim()===s});h||(e=i.substring(i.lastIndexOf(\":\")+1),l(e)<3?e=i.substring(i.indexOf(\":\")+1):l(i.substr(0,i.indexOf(\":\")))>5&&(e=i))}else if(e.length>150||e.length<15){var c=t.getElementsByTagName(\"h1\");c.length===1&&(e=this._getInnerText(c[0]))}e=e.trim().replace(this.REGEXPS.normalize,\" \");var n=l(e);return n<=4&&(!r||n!=l(i.replace(/[\\\\|\\\\-\\\\\\\\\\\\/>»]+/g,\"\"))-1)&&(e=i),e},_prepDocument:function(){var t=this._doc;this._removeNodes(this._getAllNodesWithTag(t,[\"style\"])),t.body&&this._replaceBrs(t.body),this._replaceNodeTags(this._getAllNodesWithTag(t,[\"font\"]),\"SPAN\")},_nextNode:function(t){for(var e=t;e&&e.nodeType!=this.ELEMENT_NODE&&this.REGEXPS.whitespace.test(e.textContent);)e=e.nextSibling;return e},_replaceBrs:function(t){this._forEachNode(this._getAllNodesWithTag(t,[\"br\"]),function(e){for(var i=e.nextSibling,r=!1;(i=this._nextNode(i))&&i.tagName==\"BR\";){r=!0;var l=i.nextSibling;i.parentNode.removeChild(i),i=l}if(r){var a=this._doc.createElement(\"p\");for(e.parentNode.replaceChild(a,e),i=a.nextSibling;i;){if(i.tagName==\"BR\"){var s=this._nextNode(i.nextSibling);if(s&&s.tagName==\"BR\")break}if(!this._isPhrasingContent(i))break;var h=i.nextSibling;a.appendChild(i),i=h}for(;a.lastChild&&this._isWhitespace(a.lastChild);)a.removeChild(a.lastChild);a.parentNode.tagName===\"P\"&&this._setNodeTag(a.parentNode,\"DIV\")}})},_setNodeTag:function(t,e){if(this.log(\"_setNodeTag\",t,e),this._docJSDOMParser)return t.localName=e.toLowerCase(),t.tagName=e.toUpperCase(),t;for(var i=t.ownerDocument.createElement(e);t.firstChild;)i.appendChild(t.firstChild);t.parentNode.replaceChild(i,t),t.readability&&(i.readability=t.readability);for(var r=0;r<t.attributes.length;r++)try{i.setAttribute(t.attributes[r].name,t.attributes[r].value)}catch(l){}return i},_prepArticle:function(t){this._cleanStyles(t),this._markDataTables(t),this._fixLazyImages(t),this._cleanConditionally(t,\"form\"),this._cleanConditionally(t,\"fieldset\"),this._clean(t,\"object\"),this._clean(t,\"embed\"),this._clean(t,\"footer\"),this._clean(t,\"link\"),this._clean(t,\"aside\");var e=this.DEFAULT_CHAR_THRESHOLD;this._forEachNode(t.children,function(i){this._cleanMatchedNodes(i,function(r,l){return this.REGEXPS.shareElements.test(l)&&r.textContent.length<e})}),this._clean(t,\"iframe\"),this._clean(t,\"input\"),this._clean(t,\"textarea\"),this._clean(t,\"select\"),this._clean(t,\"button\"),this._cleanHeaders(t),this._cleanConditionally(t,\"table\"),this._cleanConditionally(t,\"ul\"),this._cleanConditionally(t,\"div\"),this._replaceNodeTags(this._getAllNodesWithTag(t,[\"h1\"]),\"h2\"),this._removeNodes(this._getAllNodesWithTag(t,[\"p\"]),function(i){var r=i.getElementsByTagName(\"img\").length,l=i.getElementsByTagName(\"embed\").length,a=i.getElementsByTagName(\"object\").length,s=i.getElementsByTagName(\"iframe\").length,h=r+l+a+s;return h===0&&!this._getInnerText(i,!1)}),this._forEachNode(this._getAllNodesWithTag(t,[\"br\"]),function(i){var r=this._nextNode(i.nextSibling);r&&r.tagName==\"P\"&&i.parentNode.removeChild(i)}),this._forEachNode(this._getAllNodesWithTag(t,[\"table\"]),function(i){var r=this._hasSingleTagInsideElement(i,\"TBODY\")?i.firstElementChild:i;if(this._hasSingleTagInsideElement(r,\"TR\")){var l=r.firstElementChild;if(this._hasSingleTagInsideElement(l,\"TD\")){var a=l.firstElementChild;a=this._setNodeTag(a,this._everyNode(a.childNodes,this._isPhrasingContent)?\"P\":\"DIV\"),i.parentNode.replaceChild(a,i)}}})},_initializeNode:function(t){switch(t.readability={contentScore:0},t.tagName){case\"DIV\":t.readability.contentScore+=5;break;case\"PRE\":case\"TD\":case\"BLOCKQUOTE\":t.readability.contentScore+=3;break;case\"ADDRESS\":case\"OL\":case\"UL\":case\"DL\":case\"DD\":case\"DT\":case\"LI\":case\"FORM\":t.readability.contentScore-=3;break;case\"H1\":case\"H2\":case\"H3\":case\"H4\":case\"H5\":case\"H6\":case\"TH\":t.readability.contentScore-=5;break}t.readability.contentScore+=this._getClassWeight(t)},_removeAndGetNext:function(t){var e=this._getNextNode(t,!0);return t.parentNode.removeChild(t),e},_getNextNode:function(t,e){if(!e&&t.firstElementChild)return t.firstElementChild;if(t.nextElementSibling)return t.nextElementSibling;do t=t.parentNode;while(t&&!t.nextElementSibling);return t&&t.nextElementSibling},_textSimilarity:function(t,e){var i=t.toLowerCase().split(this.REGEXPS.tokenize).filter(Boolean),r=e.toLowerCase().split(this.REGEXPS.tokenize).filter(Boolean);if(!i.length||!r.length)return 0;var l=r.filter(s=>!i.includes(s)),a=l.join(\" \").length/r.join(\" \").length;return 1-a},_checkByline:function(t,e){if(this._articleByline)return!1;if(t.getAttribute!==void 0)var i=t.getAttribute(\"rel\"),r=t.getAttribute(\"itemprop\");return(i===\"author\"||r&&r.indexOf(\"author\")!==-1||this.REGEXPS.byline.test(e))&&this._isValidByline(t.textContent)?(this._articleByline=t.textContent.trim(),!0):!1},_getNodeAncestors:function(t,e){e=e||0;for(var i=0,r=[];t.parentNode&&(r.push(t.parentNode),!(e&&++i===e));)t=t.parentNode;return r},_grabArticle:function(t){this.log(\"**** grabArticle ****\");var e=this._doc,i=t!==null;if(t=t||this._doc.body,!t)return this.log(\"No body found in document. Abort.\"),null;for(var r=t.innerHTML;;){this.log(\"Starting grabArticle loop\");var l=this._flagIsActive(this.FLAG_STRIP_UNLIKELYS),a=[],s=this._doc.documentElement;let J=!0;for(;s;){s.tagName===\"HTML\"&&(this._articleLang=s.getAttribute(\"lang\"));var h=s.className+\" \"+s.id;if(!this._isProbablyVisible(s)){this.log(\"Removing hidden node - \"+h),s=this._removeAndGetNext(s);continue}if(s.getAttribute(\"aria-modal\")==\"true\"&&s.getAttribute(\"role\")==\"dialog\"){s=this._removeAndGetNext(s);continue}if(this._checkByline(s,h)){s=this._removeAndGetNext(s);continue}if(J&&this._headerDuplicatesTitle(s)){this.log(\"Removing header: \",s.textContent.trim(),this._articleTitle.trim()),J=!1,s=this._removeAndGetNext(s);continue}if(l){if(this.REGEXPS.unlikelyCandidates.test(h)&&!this.REGEXPS.okMaybeItsACandidate.test(h)&&!this._hasAncestorTag(s,\"table\")&&!this._hasAncestorTag(s,\"code\")&&s.tagName!==\"BODY\"&&s.tagName!==\"A\"){this.log(\"Removing unlikely candidate - \"+h),s=this._removeAndGetNext(s);continue}if(this.UNLIKELY_ROLES.includes(s.getAttribute(\"role\"))){this.log(\"Removing content with role \"+s.getAttribute(\"role\")+\" - \"+h),s=this._removeAndGetNext(s);continue}}if((s.tagName===\"DIV\"||s.tagName===\"SECTION\"||s.tagName===\"HEADER\"||s.tagName===\"H1\"||s.tagName===\"H2\"||s.tagName===\"H3\"||s.tagName===\"H4\"||s.tagName===\"H5\"||s.tagName===\"H6\")&&this._isElementWithoutContent(s)){s=this._removeAndGetNext(s);continue}if(this.DEFAULT_TAGS_TO_SCORE.indexOf(s.tagName)!==-1&&a.push(s),s.tagName===\"DIV\"){for(var c=null,n=s.firstChild;n;){var u=n.nextSibling;if(this._isPhrasingContent(n))c!==null?c.appendChild(n):this._isWhitespace(n)||(c=e.createElement(\"p\"),s.replaceChild(c,n),c.appendChild(n));else if(c!==null){for(;c.lastChild&&this._isWhitespace(c.lastChild);)c.removeChild(c.lastChild);c=null}n=u}if(this._hasSingleTagInsideElement(s,\"P\")&&this._getLinkDensity(s)<.25){var m=s.children[0];s.parentNode.replaceChild(m,s),s=m,a.push(s)}else this._hasChildBlockElement(s)||(s=this._setNodeTag(s,\"P\"),a.push(s))}s=this._getNextNode(s)}var b=[];this._forEachNode(a,function(A){if(!(!A.parentNode||typeof A.parentNode.tagName==\"undefined\")){var T=this._getInnerText(A);if(!(T.length<25)){var K=this._getNodeAncestors(A,5);if(K.length!==0){var C=0;C+=1,C+=T.split(this.REGEXPS.commas).length,C+=Math.min(Math.floor(T.length/100),3),this._forEachNode(K,function(S,F){if(!(!S.tagName||!S.parentNode||typeof S.parentNode.tagName==\"undefined\")){if(typeof S.readability==\"undefined\"&&(this._initializeNode(S),b.push(S)),F===0)var X=1;else F===1?X=2:X=F*3;S.readability.contentScore+=C/X}})}}}});for(var N=[],v=0,y=b.length;v<y;v+=1){var E=b[v],d=E.readability.contentScore*(1-this._getLinkDensity(E));E.readability.contentScore=d,this.log(\"Candidate:\",E,\"with score \"+d);for(var p=0;p<this._nbTopCandidates;p++){var x=N[p];if(!x||d>x.readability.contentScore){N.splice(p,0,E),N.length>this._nbTopCandidates&&N.pop();break}}}var o=N[0]||null,L=!1,g;if(o===null||o.tagName===\"BODY\"){for(o=e.createElement(\"DIV\"),L=!0;t.firstChild;)this.log(\"Moving child out:\",t.firstChild),o.appendChild(t.firstChild);t.appendChild(o),this._initializeNode(o)}else if(o){for(var I=[],P=1;P<N.length;P++)N[P].readability.contentScore/o.readability.contentScore>=.75&&I.push(this._getNodeAncestors(N[P]));var O=3;if(I.length>=O)for(g=o.parentNode;g.tagName!==\"BODY\";){for(var G=0,H=0;H<I.length&&G<O;H++)G+=Number(I[H].includes(g));if(G>=O){o=g;break}g=g.parentNode}o.readability||this._initializeNode(o),g=o.parentNode;for(var M=o.readability.contentScore,Q=M/3;g.tagName!==\"BODY\";){if(!g.readability){g=g.parentNode;continue}var V=g.readability.contentScore;if(V<Q)break;if(V>M){o=g;break}M=g.readability.contentScore,g=g.parentNode}for(g=o.parentNode;g.tagName!=\"BODY\"&&g.children.length==1;)o=g,g=o.parentNode;o.readability||this._initializeNode(o)}var _=e.createElement(\"DIV\");i&&(_.id=\"readability-content\");var Z=Math.max(10,o.readability.contentScore*.2);g=o.parentNode;for(var U=g.children,w=0,j=U.length;w<j;w++){var f=U[w],R=!1;if(this.log(\"Looking at sibling node:\",f,f.readability?\"with score \"+f.readability.contentScore:\"\"),this.log(\"Sibling has score\",f.readability?f.readability.contentScore:\"Unknown\"),f===o)R=!0;else{var $=0;if(f.className===o.className&&o.className!==\"\"&&($+=o.readability.contentScore*.2),f.readability&&f.readability.contentScore+$>=Z)R=!0;else if(f.nodeName===\"P\"){var Y=this._getLinkDensity(f),z=this._getInnerText(f),k=z.length;(k>80&&Y<.25||k<80&&k>0&&Y===0&&z.search(/\\\\.( |$)/)!==-1)&&(R=!0)}}R&&(this.log(\"Appending node:\",f),this.ALTER_TO_DIV_EXCEPTIONS.indexOf(f.nodeName)===-1&&(this.log(\"Altering sibling:\",f,\"to div.\"),f=this._setNodeTag(f,\"DIV\")),_.appendChild(f),U=g.children,w-=1,j-=1)}if(this._debug&&this.log(\"Article content pre-prep: \"+_.innerHTML),this._prepArticle(_),this._debug&&this.log(\"Article content post-prep: \"+_.innerHTML),L)o.id=\"readability-page-1\",o.className=\"page\";else{var B=e.createElement(\"DIV\");for(B.id=\"readability-page-1\",B.className=\"page\";_.firstChild;)B.appendChild(_.firstChild);_.appendChild(B)}this._debug&&this.log(\"Article content after paging: \"+_.innerHTML);var W=!0,D=this._getInnerText(_,!0).length;if(D<this._charThreshold)if(W=!1,t.innerHTML=r,this._flagIsActive(this.FLAG_STRIP_UNLIKELYS))this._removeFlag(this.FLAG_STRIP_UNLIKELYS),this._attempts.push({articleContent:_,textLength:D});else if(this._flagIsActive(this.FLAG_WEIGHT_CLASSES))this._removeFlag(this.FLAG_WEIGHT_CLASSES),this._attempts.push({articleContent:_,textLength:D});else if(this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY))this._removeFlag(this.FLAG_CLEAN_CONDITIONALLY),this._attempts.push({articleContent:_,textLength:D});else{if(this._attempts.push({articleContent:_,textLength:D}),this._attempts.sort(function(A,T){return T.textLength-A.textLength}),!this._attempts[0].textLength)return null;_=this._attempts[0].articleContent,W=!0}if(W){var tt=[g,o].concat(this._getNodeAncestors(g));return this._someNode(tt,function(A){if(!A.tagName)return!1;var T=A.getAttribute(\"dir\");return T?(this._articleDir=T,!0):!1}),_}}},_isValidByline:function(t){return typeof t==\"string\"||t instanceof String?(t=t.trim(),t.length>0&&t.length<100):!1},_unescapeHtmlEntities:function(t){if(!t)return t;var e=this.HTML_ESCAPE_MAP;return t.replace(/&(quot|amp|apos|lt|gt);/g,function(i,r){return e[r]}).replace(/&#(?:x([0-9a-z]{1,4})|([0-9]{1,4}));/gi,function(i,r,l){var a=parseInt(r||l,r?16:10);return String.fromCharCode(a)})},_getJSONLD:function(t){var e=this._getAllNodesWithTag(t,[\"script\"]),i;return this._forEachNode(e,function(r){if(!i&&r.getAttribute(\"type\")===\"application/ld+json\")try{var l=r.textContent.replace(/^\\\\s*<!\\\\[CDATA\\\\[|\\\\]\\\\]>\\\\s*$/g,\"\"),a=JSON.parse(l);if(!a[\"@context\"]||!a[\"@context\"].match(/^https?\\\\:\\\\/\\\\/schema\\\\.org$/)||(!a[\"@type\"]&&Array.isArray(a[\"@graph\"])&&(a=a[\"@graph\"].find(function(n){return(n[\"@type\"]||\"\").match(this.REGEXPS.jsonLdArticleTypes)})),!a||!a[\"@type\"]||!a[\"@type\"].match(this.REGEXPS.jsonLdArticleTypes)))return;if(i={},typeof a.name==\"string\"&&typeof a.headline==\"string\"&&a.name!==a.headline){var s=this._getArticleTitle(),h=this._textSimilarity(a.name,s)>.75,c=this._textSimilarity(a.headline,s)>.75;c&&!h?i.title=a.headline:i.title=a.name}else typeof a.name==\"string\"?i.title=a.name.trim():typeof a.headline==\"string\"&&(i.title=a.headline.trim());a.author&&(typeof a.author.name==\"string\"?i.byline=a.author.name.trim():Array.isArray(a.author)&&a.author[0]&&typeof a.author[0].name==\"string\"&&(i.byline=a.author.filter(function(n){return n&&typeof n.name==\"string\"}).map(function(n){return n.name.trim()}).join(\", \"))),typeof a.description==\"string\"&&(i.excerpt=a.description.trim()),a.publisher&&typeof a.publisher.name==\"string\"&&(i.siteName=a.publisher.name.trim()),typeof a.datePublished==\"string\"&&(i.datePublished=a.datePublished.trim());return}catch(n){this.log(n.message)}}),i||{}},_getArticleMetadata:function(t){var e={},i={},r=this._doc.getElementsByTagName(\"meta\"),l=/\\\\s*(article|dc|dcterm|og|twitter)\\\\s*:\\\\s*(author|creator|description|published_time|title|site_name)\\\\s*/gi,a=/^\\\\s*(?:(dc|dcterm|og|twitter|weibo:(article|webpage))\\\\s*[\\\\.:]\\\\s*)?(author|creator|description|title|site_name)\\\\s*$/i;return this._forEachNode(r,function(s){var h=s.getAttribute(\"name\"),c=s.getAttribute(\"property\"),n=s.getAttribute(\"content\");if(n){var u=null,m=null;c&&(u=c.match(l),u&&(m=u[0].toLowerCase().replace(/\\\\s/g,\"\"),i[m]=n.trim())),!u&&h&&a.test(h)&&(m=h,n&&(m=m.toLowerCase().replace(/\\\\s/g,\"\").replace(/\\\\./g,\":\"),i[m]=n.trim()))}}),e.title=t.title||i[\"dc:title\"]||i[\"dcterm:title\"]||i[\"og:title\"]||i[\"weibo:article:title\"]||i[\"weibo:webpage:title\"]||i.title||i[\"twitter:title\"],e.title||(e.title=this._getArticleTitle()),e.byline=t.byline||i[\"dc:creator\"]||i[\"dcterm:creator\"]||i.author,e.excerpt=t.excerpt||i[\"dc:description\"]||i[\"dcterm:description\"]||i[\"og:description\"]||i[\"weibo:article:description\"]||i[\"weibo:webpage:description\"]||i.description||i[\"twitter:description\"],e.siteName=t.siteName||i[\"og:site_name\"],e.publishedTime=t.datePublished||i[\"article:published_time\"]||null,e.title=this._unescapeHtmlEntities(e.title),e.byline=this._unescapeHtmlEntities(e.byline),e.excerpt=this._unescapeHtmlEntities(e.excerpt),e.siteName=this._unescapeHtmlEntities(e.siteName),e.publishedTime=this._unescapeHtmlEntities(e.publishedTime),e},_isSingleImage:function(t){return t.tagName===\"IMG\"?!0:t.children.length!==1||t.textContent.trim()!==\"\"?!1:this._isSingleImage(t.children[0])},_unwrapNoscriptImages:function(t){var e=Array.from(t.getElementsByTagName(\"img\"));this._forEachNode(e,function(r){for(var l=0;l<r.attributes.length;l++){var a=r.attributes[l];switch(a.name){case\"src\":case\"srcset\":case\"data-src\":case\"data-srcset\":return}if(/\\\\.(jpg|jpeg|png|webp)/i.test(a.value))return}r.parentNode.removeChild(r)});var i=Array.from(t.getElementsByTagName(\"noscript\"));this._forEachNode(i,function(r){var l=t.createElement(\"div\");if(l.innerHTML=r.innerHTML,!!this._isSingleImage(l)){var a=r.previousElementSibling;if(a&&this._isSingleImage(a)){var s=a;s.tagName!==\"IMG\"&&(s=a.getElementsByTagName(\"img\")[0]);for(var h=l.getElementsByTagName(\"img\")[0],c=0;c<s.attributes.length;c++){var n=s.attributes[c];if(n.value!==\"\"&&(n.name===\"src\"||n.name===\"srcset\"||/\\\\.(jpg|jpeg|png|webp)/i.test(n.value))){if(h.getAttribute(n.name)===n.value)continue;var u=n.name;h.hasAttribute(u)&&(u=\"data-old-\"+u),h.setAttribute(u,n.value)}}r.parentNode.replaceChild(l.firstElementChild,a)}}})},_removeScripts:function(t){this._removeNodes(this._getAllNodesWithTag(t,[\"script\",\"noscript\"]))},_hasSingleTagInsideElement:function(t,e){return t.children.length!=1||t.children[0].tagName!==e?!1:!this._someNode(t.childNodes,function(i){return i.nodeType===this.TEXT_NODE&&this.REGEXPS.hasContent.test(i.textContent)})},_isElementWithoutContent:function(t){return t.nodeType===this.ELEMENT_NODE&&t.textContent.trim().length==0&&(t.children.length==0||t.children.length==t.getElementsByTagName(\"br\").length+t.getElementsByTagName(\"hr\").length)},_hasChildBlockElement:function(t){return this._someNode(t.childNodes,function(e){return this.DIV_TO_P_ELEMS.has(e.tagName)||this._hasChildBlockElement(e)})},_isPhrasingContent:function(t){return t.nodeType===this.TEXT_NODE||this.PHRASING_ELEMS.indexOf(t.tagName)!==-1||(t.tagName===\"A\"||t.tagName===\"DEL\"||t.tagName===\"INS\")&&this._everyNode(t.childNodes,this._isPhrasingContent)},_isWhitespace:function(t){return t.nodeType===this.TEXT_NODE&&t.textContent.trim().length===0||t.nodeType===this.ELEMENT_NODE&&t.tagName===\"BR\"},_getInnerText:function(t,e){e=typeof e==\"undefined\"?!0:e;var i=t.textContent.trim();return e?i.replace(this.REGEXPS.normalize,\" \"):i},_getCharCount:function(t,e){return e=e||\",\",this._getInnerText(t).split(e).length-1},_cleanStyles:function(t){if(!(!t||t.tagName.toLowerCase()===\"svg\")){for(var e=0;e<this.PRESENTATIONAL_ATTRIBUTES.length;e++)t.removeAttribute(this.PRESENTATIONAL_ATTRIBUTES[e]);this.DEPRECATED_SIZE_ATTRIBUTE_ELEMS.indexOf(t.tagName)!==-1&&(t.removeAttribute(\"width\"),t.removeAttribute(\"height\"));for(var i=t.firstElementChild;i!==null;)this._cleanStyles(i),i=i.nextElementSibling}},_getLinkDensity:function(t){var e=this._getInnerText(t).length;if(e===0)return 0;var i=0;return this._forEachNode(t.getElementsByTagName(\"a\"),function(r){var l=r.getAttribute(\"href\"),a=l&&this.REGEXPS.hashUrl.test(l)?.3:1;i+=this._getInnerText(r).length*a}),i/e},_getClassWeight:function(t){if(!this._flagIsActive(this.FLAG_WEIGHT_CLASSES))return 0;var e=0;return typeof t.className==\"string\"&&t.className!==\"\"&&(this.REGEXPS.negative.test(t.className)&&(e-=25),this.REGEXPS.positive.test(t.className)&&(e+=25)),typeof t.id==\"string\"&&t.id!==\"\"&&(this.REGEXPS.negative.test(t.id)&&(e-=25),this.REGEXPS.positive.test(t.id)&&(e+=25)),e},_clean:function(t,e){var i=[\"object\",\"embed\",\"iframe\"].indexOf(e)!==-1;this._removeNodes(this._getAllNodesWithTag(t,[e]),function(r){if(i){for(var l=0;l<r.attributes.length;l++)if(this._allowedVideoRegex.test(r.attributes[l].value))return!1;if(r.tagName===\"object\"&&this._allowedVideoRegex.test(r.innerHTML))return!1}return!0})},_hasAncestorTag:function(t,e,i,r){i=i||3,e=e.toUpperCase();for(var l=0;t.parentNode;){if(i>0&&l>i)return!1;if(t.parentNode.tagName===e&&(!r||r(t.parentNode)))return!0;t=t.parentNode,l++}return!1},_getRowAndColumnCount:function(t){for(var e=0,i=0,r=t.getElementsByTagName(\"tr\"),l=0;l<r.length;l++){var a=r[l].getAttribute(\"rowspan\")||0;a&&(a=parseInt(a,10)),e+=a||1;for(var s=0,h=r[l].getElementsByTagName(\"td\"),c=0;c<h.length;c++){var n=h[c].getAttribute(\"colspan\")||0;n&&(n=parseInt(n,10)),s+=n||1}i=Math.max(i,s)}return{rows:e,columns:i}},_markDataTables:function(t){for(var e=t.getElementsByTagName(\"table\"),i=0;i<e.length;i++){var r=e[i],l=r.getAttribute(\"role\");if(l==\"presentation\"){r._readabilityDataTable=!1;continue}var a=r.getAttribute(\"datatable\");if(a==\"0\"){r._readabilityDataTable=!1;continue}var s=r.getAttribute(\"summary\");if(s){r._readabilityDataTable=!0;continue}var h=r.getElementsByTagName(\"caption\")[0];if(h&&h.childNodes.length>0){r._readabilityDataTable=!0;continue}var c=[\"col\",\"colgroup\",\"tfoot\",\"thead\",\"th\"],n=function(m){return!!r.getElementsByTagName(m)[0]};if(c.some(n)){this.log(\"Data table because found data-y descendant\"),r._readabilityDataTable=!0;continue}if(r.getElementsByTagName(\"table\")[0]){r._readabilityDataTable=!1;continue}var u=this._getRowAndColumnCount(r);if(u.rows>=10||u.columns>4){r._readabilityDataTable=!0;continue}r._readabilityDataTable=u.rows*u.columns>10}},_fixLazyImages:function(t){this._forEachNode(this._getAllNodesWithTag(t,[\"img\",\"picture\",\"figure\"]),function(e){if(e.src&&this.REGEXPS.b64DataUrl.test(e.src)){var i=this.REGEXPS.b64DataUrl.exec(e.src);if(i[1]===\"image/svg+xml\")return;for(var r=!1,l=0;l<e.attributes.length;l++){var a=e.attributes[l];if(a.name!==\"src\"&&/\\\\.(jpg|jpeg|png|webp)/i.test(a.value)){r=!0;break}}if(r){var s=e.src.search(/base64\\\\s*/i)+7,h=e.src.length-s;h<133&&e.removeAttribute(\"src\")}}if(!((e.src||e.srcset&&e.srcset!=\"null\")&&e.className.toLowerCase().indexOf(\"lazy\")===-1)){for(var c=0;c<e.attributes.length;c++)if(a=e.attributes[c],!(a.name===\"src\"||a.name===\"srcset\"||a.name===\"alt\")){var n=null;if(/\\\\.(jpg|jpeg|png|webp)\\\\s+\\\\d/.test(a.value)?n=\"srcset\":/^\\\\s*\\\\S+\\\\.(jpg|jpeg|png|webp)\\\\S*\\\\s*$/.test(a.value)&&(n=\"src\"),n){if(e.tagName===\"IMG\"||e.tagName===\"PICTURE\")e.setAttribute(n,a.value);else if(e.tagName===\"FIGURE\"&&!this._getAllNodesWithTag(e,[\"img\",\"picture\"]).length){var u=this._doc.createElement(\"img\");u.setAttribute(n,a.value),e.appendChild(u)}}}}})},_getTextDensity:function(t,e){var i=this._getInnerText(t,!0).length;if(i===0)return 0;var r=0,l=this._getAllNodesWithTag(t,e);return this._forEachNode(l,a=>r+=this._getInnerText(a,!0).length),r/i},_cleanConditionally:function(t,e){this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY)&&this._removeNodes(this._getAllNodesWithTag(t,[e]),function(i){var r=function(g){return g._readabilityDataTable},l=e===\"ul\"||e===\"ol\";if(!l){var a=0,s=this._getAllNodesWithTag(i,[\"ul\",\"ol\"]);this._forEachNode(s,g=>a+=this._getInnerText(g).length),l=a/this._getInnerText(i).length>.9}if(e===\"table\"&&r(i)||this._hasAncestorTag(i,\"table\",-1,r)||this._hasAncestorTag(i,\"code\"))return!1;var h=this._getClassWeight(i);this.log(\"Cleaning Conditionally\",i);var c=0;if(h+c<0)return!0;if(this._getCharCount(i,\",\")<10){for(var n=i.getElementsByTagName(\"p\").length,u=i.getElementsByTagName(\"img\").length,m=i.getElementsByTagName(\"li\").length-100,b=i.getElementsByTagName(\"input\").length,N=this._getTextDensity(i,[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"]),v=0,y=this._getAllNodesWithTag(i,[\"object\",\"embed\",\"iframe\"]),E=0;E<y.length;E++){for(var d=0;d<y[E].attributes.length;d++)if(this._allowedVideoRegex.test(y[E].attributes[d].value))return!1;if(y[E].tagName===\"object\"&&this._allowedVideoRegex.test(y[E].innerHTML))return!1;v++}var p=this._getLinkDensity(i),x=this._getInnerText(i).length,o=u>1&&n/u<.5&&!this._hasAncestorTag(i,\"figure\")||!l&&m>n||b>Math.floor(n/3)||!l&&N<.9&&x<25&&(u===0||u>2)&&!this._hasAncestorTag(i,\"figure\")||!l&&h<25&&p>.2||h>=25&&p>.5||v===1&&x<75||v>1;if(l&&o){for(var L=0;L<i.children.length;L++)if(i.children[L].children.length>1)return o;let g=i.getElementsByTagName(\"li\").length;if(u==g)return!1}return o}return!1})},_cleanMatchedNodes:function(t,e){for(var i=this._getNextNode(t,!0),r=this._getNextNode(t);r&&r!=i;)e.call(this,r,r.className+\" \"+r.id)?r=this._removeAndGetNext(r):r=this._getNextNode(r)},_cleanHeaders:function(t){let e=this._getAllNodesWithTag(t,[\"h1\",\"h2\"]);this._removeNodes(e,function(i){let r=this._getClassWeight(i)<0;return r&&this.log(\"Removing header with low class weight:\",i),r})},_headerDuplicatesTitle:function(t){if(t.tagName!=\"H1\"&&t.tagName!=\"H2\")return!1;var e=this._getInnerText(t,!1);return this.log(\"Evaluating similarity of header:\",e,this._articleTitle),this._textSimilarity(this._articleTitle,e)>.75},_flagIsActive:function(t){return(this._flags&t)>0},_removeFlag:function(t){this._flags=this._flags&~t},_isProbablyVisible:function(t){return(!t.style||t.style.display!=\"none\")&&(!t.style||t.style.visibility!=\"hidden\")&&!t.hasAttribute(\"hidden\")&&(!t.hasAttribute(\"aria-hidden\")||t.getAttribute(\"aria-hidden\")!=\"true\"||t.className&&t.className.indexOf&&t.className.indexOf(\"fallback-image\")!==-1)},parse:function(){if(this._maxElemsToParse>0){var t=this._doc.getElementsByTagName(\"*\").length;if(t>this._maxElemsToParse)throw new Error(\"Aborting parsing document; \"+t+\" elements found\")}this._unwrapNoscriptImages(this._doc);var e=this._disableJSONLD?{}:this._getJSONLD(this._doc);this._removeScripts(this._doc),this._prepDocument();var i=this._getArticleMetadata(e);this._articleTitle=i.title;var r=this._grabArticle();if(!r)return null;if(this.log(\"Grabbed: \"+r.innerHTML),this._postProcessContent(r),!i.excerpt){var l=r.getElementsByTagName(\"p\");l.length>0&&(i.excerpt=l[0].textContent.trim())}var a=r.textContent;return{title:this._articleTitle,byline:i.byline||this._articleByline,dir:this._articleDir,lang:this._articleLang,content:this._serializer(r),textContent:a,length:a.length,excerpt:i.excerpt,siteName:i.siteName||this._articleSiteName,publishedTime:i.publishedTime}}};typeof module==\"object\"&&(module.exports=q);\\n';\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","READABILITY_SCRIPT"],"mappings":";;;;;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;ACiBO,MAAMI,qBACX"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ const READABILITY_SCRIPT = 'function q(t,e){if(e&&e.documentElement)t=e,e=arguments[2];else if(!t||!t.documentElement)throw new Error("First argument to Readability constructor should be a document object.");if(e=e||{},this._doc=t,this._docJSDOMParser=this._doc.firstChild.__JSDOMParser__,this._articleTitle=null,this._articleByline=null,this._articleDir=null,this._articleSiteName=null,this._attempts=[],this._debug=!!e.debug,this._maxElemsToParse=e.maxElemsToParse||this.DEFAULT_MAX_ELEMS_TO_PARSE,this._nbTopCandidates=e.nbTopCandidates||this.DEFAULT_N_TOP_CANDIDATES,this._charThreshold=e.charThreshold||this.DEFAULT_CHAR_THRESHOLD,this._classesToPreserve=this.CLASSES_TO_PRESERVE.concat(e.classesToPreserve||[]),this._keepClasses=!!e.keepClasses,this._serializer=e.serializer||function(i){return i.innerHTML},this._disableJSONLD=!!e.disableJSONLD,this._allowedVideoRegex=e.allowedVideoRegex||this.REGEXPS.videos,this._flags=this.FLAG_STRIP_UNLIKELYS|this.FLAG_WEIGHT_CLASSES|this.FLAG_CLEAN_CONDITIONALLY,this._debug){let i=function(r){if(r.nodeType==r.TEXT_NODE)return`${r.nodeName} ("${r.textContent}")`;let l=Array.from(r.attributes||[],function(a){return`${a.name}="${a.value}"`}).join(" ");return`<${r.localName} ${l}>`};this.log=function(){if(typeof console!="undefined"){let l=Array.from(arguments,a=>a&&a.nodeType==this.ELEMENT_NODE?i(a):a);l.unshift("Reader: (Readability)"),console.log.apply(console,l)}else if(typeof dump!="undefined"){var r=Array.prototype.map.call(arguments,function(l){return l&&l.nodeName?i(l):l}).join(" ");dump("Reader: (Readability) "+r+`\n`)}}}else this.log=function(){}}q.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|>([^\\|]|$)|\xbb([^\\|]|$))/i,prevLink:/(prev|earl|old|new|<|\xab)/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,commas:/\\u002C|\\u060C|\\uFE50|\\uFE10|\\uFE11|\\u2E41|\\u2E34|\\u2E32|\\uFF0C/g,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(t){this._fixRelativeUris(t),this._simplifyNestedElements(t),this._keepClasses||this._cleanClasses(t)},_removeNodes:function(t,e){if(this._docJSDOMParser&&t._isLiveNodeList)throw new Error("Do not pass live node lists to _removeNodes");for(var i=t.length-1;i>=0;i--){var r=t[i],l=r.parentNode;l&&(!e||e.call(this,r,i,t))&&l.removeChild(r)}},_replaceNodeTags:function(t,e){if(this._docJSDOMParser&&t._isLiveNodeList)throw new Error("Do not pass live node lists to _replaceNodeTags");for(let i of t)this._setNodeTag(i,e)},_forEachNode:function(t,e){Array.prototype.forEach.call(t,e,this)},_findNode:function(t,e){return Array.prototype.find.call(t,e,this)},_someNode:function(t,e){return Array.prototype.some.call(t,e,this)},_everyNode:function(t,e){return Array.prototype.every.call(t,e,this)},_concatNodeLists:function(){var t=Array.prototype.slice,e=t.call(arguments),i=e.map(function(r){return t.call(r)});return Array.prototype.concat.apply([],i)},_getAllNodesWithTag:function(t,e){return t.querySelectorAll?t.querySelectorAll(e.join(",")):[].concat.apply([],e.map(function(i){var r=t.getElementsByTagName(i);return Array.isArray(r)?r:Array.from(r)}))},_cleanClasses:function(t){var e=this._classesToPreserve,i=(t.getAttribute("class")||"").split(/\\s+/).filter(function(r){return e.indexOf(r)!=-1}).join(" ");for(i?t.setAttribute("class",i):t.removeAttribute("class"),t=t.firstElementChild;t;t=t.nextElementSibling)this._cleanClasses(t)},_fixRelativeUris:function(t){var e=this._doc.baseURI,i=this._doc.documentURI;function r(s){if(e==i&&s.charAt(0)=="#")return s;try{return new URL(s,e).href}catch(h){}return s}var l=this._getAllNodesWithTag(t,["a"]);this._forEachNode(l,function(s){var h=s.getAttribute("href");if(h)if(h.indexOf("javascript:")===0)if(s.childNodes.length===1&&s.childNodes[0].nodeType===this.TEXT_NODE){var c=this._doc.createTextNode(s.textContent);s.parentNode.replaceChild(c,s)}else{for(var n=this._doc.createElement("span");s.firstChild;)n.appendChild(s.firstChild);s.parentNode.replaceChild(n,s)}else s.setAttribute("href",r(h))});var a=this._getAllNodesWithTag(t,["img","picture","figure","video","audio","source"]);this._forEachNode(a,function(s){var h=s.getAttribute("src"),c=s.getAttribute("poster"),n=s.getAttribute("srcset");if(h&&s.setAttribute("src",r(h)),c&&s.setAttribute("poster",r(c)),n){var u=n.replace(this.REGEXPS.srcsetUrl,function(m,b,N,v){return r(b)+(N||"")+v});s.setAttribute("srcset",u)}})},_simplifyNestedElements:function(t){for(var e=t;e;){if(e.parentNode&&["DIV","SECTION"].includes(e.tagName)&&!(e.id&&e.id.startsWith("readability"))){if(this._isElementWithoutContent(e)){e=this._removeAndGetNext(e);continue}else if(this._hasSingleTagInsideElement(e,"DIV")||this._hasSingleTagInsideElement(e,"SECTION")){for(var i=e.children[0],r=0;r<e.attributes.length;r++)i.setAttribute(e.attributes[r].name,e.attributes[r].value);e.parentNode.replaceChild(i,e),e=i;continue}}e=this._getNextNode(e)}},_getArticleTitle:function(){var t=this._doc,e="",i="";try{e=i=t.title.trim(),typeof e!="string"&&(e=i=this._getInnerText(t.getElementsByTagName("title")[0]))}catch(u){}var r=!1;function l(u){return u.split(/\\s+/).length}if(/ [\\|\\-\\\\\\/>\xbb] /.test(e))r=/ [\\\\\\/>\xbb] /.test(e),e=i.replace(/(.*)[\\|\\-\\\\\\/>\xbb] .*/gi,"$1"),l(e)<3&&(e=i.replace(/[^\\|\\-\\\\\\/>\xbb]*[\\|\\-\\\\\\/>\xbb](.*)/gi,"$1"));else if(e.indexOf(": ")!==-1){var a=this._concatNodeLists(t.getElementsByTagName("h1"),t.getElementsByTagName("h2")),s=e.trim(),h=this._someNode(a,function(u){return u.textContent.trim()===s});h||(e=i.substring(i.lastIndexOf(":")+1),l(e)<3?e=i.substring(i.indexOf(":")+1):l(i.substr(0,i.indexOf(":")))>5&&(e=i))}else if(e.length>150||e.length<15){var c=t.getElementsByTagName("h1");c.length===1&&(e=this._getInnerText(c[0]))}e=e.trim().replace(this.REGEXPS.normalize," ");var n=l(e);return n<=4&&(!r||n!=l(i.replace(/[\\|\\-\\\\\\/>\xbb]+/g,""))-1)&&(e=i),e},_prepDocument:function(){var t=this._doc;this._removeNodes(this._getAllNodesWithTag(t,["style"])),t.body&&this._replaceBrs(t.body),this._replaceNodeTags(this._getAllNodesWithTag(t,["font"]),"SPAN")},_nextNode:function(t){for(var e=t;e&&e.nodeType!=this.ELEMENT_NODE&&this.REGEXPS.whitespace.test(e.textContent);)e=e.nextSibling;return e},_replaceBrs:function(t){this._forEachNode(this._getAllNodesWithTag(t,["br"]),function(e){for(var i=e.nextSibling,r=!1;(i=this._nextNode(i))&&i.tagName=="BR";){r=!0;var l=i.nextSibling;i.parentNode.removeChild(i),i=l}if(r){var a=this._doc.createElement("p");for(e.parentNode.replaceChild(a,e),i=a.nextSibling;i;){if(i.tagName=="BR"){var s=this._nextNode(i.nextSibling);if(s&&s.tagName=="BR")break}if(!this._isPhrasingContent(i))break;var h=i.nextSibling;a.appendChild(i),i=h}for(;a.lastChild&&this._isWhitespace(a.lastChild);)a.removeChild(a.lastChild);a.parentNode.tagName==="P"&&this._setNodeTag(a.parentNode,"DIV")}})},_setNodeTag:function(t,e){if(this.log("_setNodeTag",t,e),this._docJSDOMParser)return t.localName=e.toLowerCase(),t.tagName=e.toUpperCase(),t;for(var i=t.ownerDocument.createElement(e);t.firstChild;)i.appendChild(t.firstChild);t.parentNode.replaceChild(i,t),t.readability&&(i.readability=t.readability);for(var r=0;r<t.attributes.length;r++)try{i.setAttribute(t.attributes[r].name,t.attributes[r].value)}catch(l){}return i},_prepArticle:function(t){this._cleanStyles(t),this._markDataTables(t),this._fixLazyImages(t),this._cleanConditionally(t,"form"),this._cleanConditionally(t,"fieldset"),this._clean(t,"object"),this._clean(t,"embed"),this._clean(t,"footer"),this._clean(t,"link"),this._clean(t,"aside");var e=this.DEFAULT_CHAR_THRESHOLD;this._forEachNode(t.children,function(i){this._cleanMatchedNodes(i,function(r,l){return this.REGEXPS.shareElements.test(l)&&r.textContent.length<e})}),this._clean(t,"iframe"),this._clean(t,"input"),this._clean(t,"textarea"),this._clean(t,"select"),this._clean(t,"button"),this._cleanHeaders(t),this._cleanConditionally(t,"table"),this._cleanConditionally(t,"ul"),this._cleanConditionally(t,"div"),this._replaceNodeTags(this._getAllNodesWithTag(t,["h1"]),"h2"),this._removeNodes(this._getAllNodesWithTag(t,["p"]),function(i){var r=i.getElementsByTagName("img").length,l=i.getElementsByTagName("embed").length,a=i.getElementsByTagName("object").length,s=i.getElementsByTagName("iframe").length,h=r+l+a+s;return h===0&&!this._getInnerText(i,!1)}),this._forEachNode(this._getAllNodesWithTag(t,["br"]),function(i){var r=this._nextNode(i.nextSibling);r&&r.tagName=="P"&&i.parentNode.removeChild(i)}),this._forEachNode(this._getAllNodesWithTag(t,["table"]),function(i){var r=this._hasSingleTagInsideElement(i,"TBODY")?i.firstElementChild:i;if(this._hasSingleTagInsideElement(r,"TR")){var l=r.firstElementChild;if(this._hasSingleTagInsideElement(l,"TD")){var a=l.firstElementChild;a=this._setNodeTag(a,this._everyNode(a.childNodes,this._isPhrasingContent)?"P":"DIV"),i.parentNode.replaceChild(a,i)}}})},_initializeNode:function(t){switch(t.readability={contentScore:0},t.tagName){case"DIV":t.readability.contentScore+=5;break;case"PRE":case"TD":case"BLOCKQUOTE":t.readability.contentScore+=3;break;case"ADDRESS":case"OL":case"UL":case"DL":case"DD":case"DT":case"LI":case"FORM":t.readability.contentScore-=3;break;case"H1":case"H2":case"H3":case"H4":case"H5":case"H6":case"TH":t.readability.contentScore-=5;break}t.readability.contentScore+=this._getClassWeight(t)},_removeAndGetNext:function(t){var e=this._getNextNode(t,!0);return t.parentNode.removeChild(t),e},_getNextNode:function(t,e){if(!e&&t.firstElementChild)return t.firstElementChild;if(t.nextElementSibling)return t.nextElementSibling;do t=t.parentNode;while(t&&!t.nextElementSibling);return t&&t.nextElementSibling},_textSimilarity:function(t,e){var i=t.toLowerCase().split(this.REGEXPS.tokenize).filter(Boolean),r=e.toLowerCase().split(this.REGEXPS.tokenize).filter(Boolean);if(!i.length||!r.length)return 0;var l=r.filter(s=>!i.includes(s)),a=l.join(" ").length/r.join(" ").length;return 1-a},_checkByline:function(t,e){if(this._articleByline)return!1;if(t.getAttribute!==void 0)var i=t.getAttribute("rel"),r=t.getAttribute("itemprop");return(i==="author"||r&&r.indexOf("author")!==-1||this.REGEXPS.byline.test(e))&&this._isValidByline(t.textContent)?(this._articleByline=t.textContent.trim(),!0):!1},_getNodeAncestors:function(t,e){e=e||0;for(var i=0,r=[];t.parentNode&&(r.push(t.parentNode),!(e&&++i===e));)t=t.parentNode;return r},_grabArticle:function(t){this.log("**** grabArticle ****");var e=this._doc,i=t!==null;if(t=t||this._doc.body,!t)return this.log("No body found in document. Abort."),null;for(var r=t.innerHTML;;){this.log("Starting grabArticle loop");var l=this._flagIsActive(this.FLAG_STRIP_UNLIKELYS),a=[],s=this._doc.documentElement;let J=!0;for(;s;){s.tagName==="HTML"&&(this._articleLang=s.getAttribute("lang"));var h=s.className+" "+s.id;if(!this._isProbablyVisible(s)){this.log("Removing hidden node - "+h),s=this._removeAndGetNext(s);continue}if(s.getAttribute("aria-modal")=="true"&&s.getAttribute("role")=="dialog"){s=this._removeAndGetNext(s);continue}if(this._checkByline(s,h)){s=this._removeAndGetNext(s);continue}if(J&&this._headerDuplicatesTitle(s)){this.log("Removing header: ",s.textContent.trim(),this._articleTitle.trim()),J=!1,s=this._removeAndGetNext(s);continue}if(l){if(this.REGEXPS.unlikelyCandidates.test(h)&&!this.REGEXPS.okMaybeItsACandidate.test(h)&&!this._hasAncestorTag(s,"table")&&!this._hasAncestorTag(s,"code")&&s.tagName!=="BODY"&&s.tagName!=="A"){this.log("Removing unlikely candidate - "+h),s=this._removeAndGetNext(s);continue}if(this.UNLIKELY_ROLES.includes(s.getAttribute("role"))){this.log("Removing content with role "+s.getAttribute("role")+" - "+h),s=this._removeAndGetNext(s);continue}}if((s.tagName==="DIV"||s.tagName==="SECTION"||s.tagName==="HEADER"||s.tagName==="H1"||s.tagName==="H2"||s.tagName==="H3"||s.tagName==="H4"||s.tagName==="H5"||s.tagName==="H6")&&this._isElementWithoutContent(s)){s=this._removeAndGetNext(s);continue}if(this.DEFAULT_TAGS_TO_SCORE.indexOf(s.tagName)!==-1&&a.push(s),s.tagName==="DIV"){for(var c=null,n=s.firstChild;n;){var u=n.nextSibling;if(this._isPhrasingContent(n))c!==null?c.appendChild(n):this._isWhitespace(n)||(c=e.createElement("p"),s.replaceChild(c,n),c.appendChild(n));else if(c!==null){for(;c.lastChild&&this._isWhitespace(c.lastChild);)c.removeChild(c.lastChild);c=null}n=u}if(this._hasSingleTagInsideElement(s,"P")&&this._getLinkDensity(s)<.25){var m=s.children[0];s.parentNode.replaceChild(m,s),s=m,a.push(s)}else this._hasChildBlockElement(s)||(s=this._setNodeTag(s,"P"),a.push(s))}s=this._getNextNode(s)}var b=[];this._forEachNode(a,function(A){if(!(!A.parentNode||typeof A.parentNode.tagName=="undefined")){var T=this._getInnerText(A);if(!(T.length<25)){var K=this._getNodeAncestors(A,5);if(K.length!==0){var C=0;C+=1,C+=T.split(this.REGEXPS.commas).length,C+=Math.min(Math.floor(T.length/100),3),this._forEachNode(K,function(S,F){if(!(!S.tagName||!S.parentNode||typeof S.parentNode.tagName=="undefined")){if(typeof S.readability=="undefined"&&(this._initializeNode(S),b.push(S)),F===0)var X=1;else F===1?X=2:X=F*3;S.readability.contentScore+=C/X}})}}}});for(var N=[],v=0,y=b.length;v<y;v+=1){var E=b[v],d=E.readability.contentScore*(1-this._getLinkDensity(E));E.readability.contentScore=d,this.log("Candidate:",E,"with score "+d);for(var p=0;p<this._nbTopCandidates;p++){var x=N[p];if(!x||d>x.readability.contentScore){N.splice(p,0,E),N.length>this._nbTopCandidates&&N.pop();break}}}var o=N[0]||null,L=!1,g;if(o===null||o.tagName==="BODY"){for(o=e.createElement("DIV"),L=!0;t.firstChild;)this.log("Moving child out:",t.firstChild),o.appendChild(t.firstChild);t.appendChild(o),this._initializeNode(o)}else if(o){for(var I=[],P=1;P<N.length;P++)N[P].readability.contentScore/o.readability.contentScore>=.75&&I.push(this._getNodeAncestors(N[P]));var O=3;if(I.length>=O)for(g=o.parentNode;g.tagName!=="BODY";){for(var G=0,H=0;H<I.length&&G<O;H++)G+=Number(I[H].includes(g));if(G>=O){o=g;break}g=g.parentNode}o.readability||this._initializeNode(o),g=o.parentNode;for(var M=o.readability.contentScore,Q=M/3;g.tagName!=="BODY";){if(!g.readability){g=g.parentNode;continue}var V=g.readability.contentScore;if(V<Q)break;if(V>M){o=g;break}M=g.readability.contentScore,g=g.parentNode}for(g=o.parentNode;g.tagName!="BODY"&&g.children.length==1;)o=g,g=o.parentNode;o.readability||this._initializeNode(o)}var _=e.createElement("DIV");i&&(_.id="readability-content");var Z=Math.max(10,o.readability.contentScore*.2);g=o.parentNode;for(var U=g.children,w=0,j=U.length;w<j;w++){var f=U[w],R=!1;if(this.log("Looking at sibling node:",f,f.readability?"with score "+f.readability.contentScore:""),this.log("Sibling has score",f.readability?f.readability.contentScore:"Unknown"),f===o)R=!0;else{var $=0;if(f.className===o.className&&o.className!==""&&($+=o.readability.contentScore*.2),f.readability&&f.readability.contentScore+$>=Z)R=!0;else if(f.nodeName==="P"){var Y=this._getLinkDensity(f),z=this._getInnerText(f),k=z.length;(k>80&&Y<.25||k<80&&k>0&&Y===0&&z.search(/\\.( |$)/)!==-1)&&(R=!0)}}R&&(this.log("Appending node:",f),this.ALTER_TO_DIV_EXCEPTIONS.indexOf(f.nodeName)===-1&&(this.log("Altering sibling:",f,"to div."),f=this._setNodeTag(f,"DIV")),_.appendChild(f),U=g.children,w-=1,j-=1)}if(this._debug&&this.log("Article content pre-prep: "+_.innerHTML),this._prepArticle(_),this._debug&&this.log("Article content post-prep: "+_.innerHTML),L)o.id="readability-page-1",o.className="page";else{var B=e.createElement("DIV");for(B.id="readability-page-1",B.className="page";_.firstChild;)B.appendChild(_.firstChild);_.appendChild(B)}this._debug&&this.log("Article content after paging: "+_.innerHTML);var W=!0,D=this._getInnerText(_,!0).length;if(D<this._charThreshold)if(W=!1,t.innerHTML=r,this._flagIsActive(this.FLAG_STRIP_UNLIKELYS))this._removeFlag(this.FLAG_STRIP_UNLIKELYS),this._attempts.push({articleContent:_,textLength:D});else if(this._flagIsActive(this.FLAG_WEIGHT_CLASSES))this._removeFlag(this.FLAG_WEIGHT_CLASSES),this._attempts.push({articleContent:_,textLength:D});else if(this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY))this._removeFlag(this.FLAG_CLEAN_CONDITIONALLY),this._attempts.push({articleContent:_,textLength:D});else{if(this._attempts.push({articleContent:_,textLength:D}),this._attempts.sort(function(A,T){return T.textLength-A.textLength}),!this._attempts[0].textLength)return null;_=this._attempts[0].articleContent,W=!0}if(W){var tt=[g,o].concat(this._getNodeAncestors(g));return this._someNode(tt,function(A){if(!A.tagName)return!1;var T=A.getAttribute("dir");return T?(this._articleDir=T,!0):!1}),_}}},_isValidByline:function(t){return typeof t=="string"||t instanceof String?(t=t.trim(),t.length>0&&t.length<100):!1},_unescapeHtmlEntities:function(t){if(!t)return t;var e=this.HTML_ESCAPE_MAP;return t.replace(/&(quot|amp|apos|lt|gt);/g,function(i,r){return e[r]}).replace(/&#(?:x([0-9a-z]{1,4})|([0-9]{1,4}));/gi,function(i,r,l){var a=parseInt(r||l,r?16:10);return String.fromCharCode(a)})},_getJSONLD:function(t){var e=this._getAllNodesWithTag(t,["script"]),i;return this._forEachNode(e,function(r){if(!i&&r.getAttribute("type")==="application/ld+json")try{var l=r.textContent.replace(/^\\s*<!\\[CDATA\\[|\\]\\]>\\s*$/g,""),a=JSON.parse(l);if(!a["@context"]||!a["@context"].match(/^https?\\:\\/\\/schema\\.org$/)||(!a["@type"]&&Array.isArray(a["@graph"])&&(a=a["@graph"].find(function(n){return(n["@type"]||"").match(this.REGEXPS.jsonLdArticleTypes)})),!a||!a["@type"]||!a["@type"].match(this.REGEXPS.jsonLdArticleTypes)))return;if(i={},typeof a.name=="string"&&typeof a.headline=="string"&&a.name!==a.headline){var s=this._getArticleTitle(),h=this._textSimilarity(a.name,s)>.75,c=this._textSimilarity(a.headline,s)>.75;c&&!h?i.title=a.headline:i.title=a.name}else typeof a.name=="string"?i.title=a.name.trim():typeof a.headline=="string"&&(i.title=a.headline.trim());a.author&&(typeof a.author.name=="string"?i.byline=a.author.name.trim():Array.isArray(a.author)&&a.author[0]&&typeof a.author[0].name=="string"&&(i.byline=a.author.filter(function(n){return n&&typeof n.name=="string"}).map(function(n){return n.name.trim()}).join(", "))),typeof a.description=="string"&&(i.excerpt=a.description.trim()),a.publisher&&typeof a.publisher.name=="string"&&(i.siteName=a.publisher.name.trim()),typeof a.datePublished=="string"&&(i.datePublished=a.datePublished.trim());return}catch(n){this.log(n.message)}}),i||{}},_getArticleMetadata:function(t){var e={},i={},r=this._doc.getElementsByTagName("meta"),l=/\\s*(article|dc|dcterm|og|twitter)\\s*:\\s*(author|creator|description|published_time|title|site_name)\\s*/gi,a=/^\\s*(?:(dc|dcterm|og|twitter|weibo:(article|webpage))\\s*[\\.:]\\s*)?(author|creator|description|title|site_name)\\s*$/i;return this._forEachNode(r,function(s){var h=s.getAttribute("name"),c=s.getAttribute("property"),n=s.getAttribute("content");if(n){var u=null,m=null;c&&(u=c.match(l),u&&(m=u[0].toLowerCase().replace(/\\s/g,""),i[m]=n.trim())),!u&&h&&a.test(h)&&(m=h,n&&(m=m.toLowerCase().replace(/\\s/g,"").replace(/\\./g,":"),i[m]=n.trim()))}}),e.title=t.title||i["dc:title"]||i["dcterm:title"]||i["og:title"]||i["weibo:article:title"]||i["weibo:webpage:title"]||i.title||i["twitter:title"],e.title||(e.title=this._getArticleTitle()),e.byline=t.byline||i["dc:creator"]||i["dcterm:creator"]||i.author,e.excerpt=t.excerpt||i["dc:description"]||i["dcterm:description"]||i["og:description"]||i["weibo:article:description"]||i["weibo:webpage:description"]||i.description||i["twitter:description"],e.siteName=t.siteName||i["og:site_name"],e.publishedTime=t.datePublished||i["article:published_time"]||null,e.title=this._unescapeHtmlEntities(e.title),e.byline=this._unescapeHtmlEntities(e.byline),e.excerpt=this._unescapeHtmlEntities(e.excerpt),e.siteName=this._unescapeHtmlEntities(e.siteName),e.publishedTime=this._unescapeHtmlEntities(e.publishedTime),e},_isSingleImage:function(t){return t.tagName==="IMG"?!0:t.children.length!==1||t.textContent.trim()!==""?!1:this._isSingleImage(t.children[0])},_unwrapNoscriptImages:function(t){var e=Array.from(t.getElementsByTagName("img"));this._forEachNode(e,function(r){for(var l=0;l<r.attributes.length;l++){var a=r.attributes[l];switch(a.name){case"src":case"srcset":case"data-src":case"data-srcset":return}if(/\\.(jpg|jpeg|png|webp)/i.test(a.value))return}r.parentNode.removeChild(r)});var i=Array.from(t.getElementsByTagName("noscript"));this._forEachNode(i,function(r){var l=t.createElement("div");if(l.innerHTML=r.innerHTML,!!this._isSingleImage(l)){var a=r.previousElementSibling;if(a&&this._isSingleImage(a)){var s=a;s.tagName!=="IMG"&&(s=a.getElementsByTagName("img")[0]);for(var h=l.getElementsByTagName("img")[0],c=0;c<s.attributes.length;c++){var n=s.attributes[c];if(n.value!==""&&(n.name==="src"||n.name==="srcset"||/\\.(jpg|jpeg|png|webp)/i.test(n.value))){if(h.getAttribute(n.name)===n.value)continue;var u=n.name;h.hasAttribute(u)&&(u="data-old-"+u),h.setAttribute(u,n.value)}}r.parentNode.replaceChild(l.firstElementChild,a)}}})},_removeScripts:function(t){this._removeNodes(this._getAllNodesWithTag(t,["script","noscript"]))},_hasSingleTagInsideElement:function(t,e){return t.children.length!=1||t.children[0].tagName!==e?!1:!this._someNode(t.childNodes,function(i){return i.nodeType===this.TEXT_NODE&&this.REGEXPS.hasContent.test(i.textContent)})},_isElementWithoutContent:function(t){return t.nodeType===this.ELEMENT_NODE&&t.textContent.trim().length==0&&(t.children.length==0||t.children.length==t.getElementsByTagName("br").length+t.getElementsByTagName("hr").length)},_hasChildBlockElement:function(t){return this._someNode(t.childNodes,function(e){return this.DIV_TO_P_ELEMS.has(e.tagName)||this._hasChildBlockElement(e)})},_isPhrasingContent:function(t){return t.nodeType===this.TEXT_NODE||this.PHRASING_ELEMS.indexOf(t.tagName)!==-1||(t.tagName==="A"||t.tagName==="DEL"||t.tagName==="INS")&&this._everyNode(t.childNodes,this._isPhrasingContent)},_isWhitespace:function(t){return t.nodeType===this.TEXT_NODE&&t.textContent.trim().length===0||t.nodeType===this.ELEMENT_NODE&&t.tagName==="BR"},_getInnerText:function(t,e){e=typeof e=="undefined"?!0:e;var i=t.textContent.trim();return e?i.replace(this.REGEXPS.normalize," "):i},_getCharCount:function(t,e){return e=e||",",this._getInnerText(t).split(e).length-1},_cleanStyles:function(t){if(!(!t||t.tagName.toLowerCase()==="svg")){for(var e=0;e<this.PRESENTATIONAL_ATTRIBUTES.length;e++)t.removeAttribute(this.PRESENTATIONAL_ATTRIBUTES[e]);this.DEPRECATED_SIZE_ATTRIBUTE_ELEMS.indexOf(t.tagName)!==-1&&(t.removeAttribute("width"),t.removeAttribute("height"));for(var i=t.firstElementChild;i!==null;)this._cleanStyles(i),i=i.nextElementSibling}},_getLinkDensity:function(t){var e=this._getInnerText(t).length;if(e===0)return 0;var i=0;return this._forEachNode(t.getElementsByTagName("a"),function(r){var l=r.getAttribute("href"),a=l&&this.REGEXPS.hashUrl.test(l)?.3:1;i+=this._getInnerText(r).length*a}),i/e},_getClassWeight:function(t){if(!this._flagIsActive(this.FLAG_WEIGHT_CLASSES))return 0;var e=0;return typeof t.className=="string"&&t.className!==""&&(this.REGEXPS.negative.test(t.className)&&(e-=25),this.REGEXPS.positive.test(t.className)&&(e+=25)),typeof t.id=="string"&&t.id!==""&&(this.REGEXPS.negative.test(t.id)&&(e-=25),this.REGEXPS.positive.test(t.id)&&(e+=25)),e},_clean:function(t,e){var i=["object","embed","iframe"].indexOf(e)!==-1;this._removeNodes(this._getAllNodesWithTag(t,[e]),function(r){if(i){for(var l=0;l<r.attributes.length;l++)if(this._allowedVideoRegex.test(r.attributes[l].value))return!1;if(r.tagName==="object"&&this._allowedVideoRegex.test(r.innerHTML))return!1}return!0})},_hasAncestorTag:function(t,e,i,r){i=i||3,e=e.toUpperCase();for(var l=0;t.parentNode;){if(i>0&&l>i)return!1;if(t.parentNode.tagName===e&&(!r||r(t.parentNode)))return!0;t=t.parentNode,l++}return!1},_getRowAndColumnCount:function(t){for(var e=0,i=0,r=t.getElementsByTagName("tr"),l=0;l<r.length;l++){var a=r[l].getAttribute("rowspan")||0;a&&(a=parseInt(a,10)),e+=a||1;for(var s=0,h=r[l].getElementsByTagName("td"),c=0;c<h.length;c++){var n=h[c].getAttribute("colspan")||0;n&&(n=parseInt(n,10)),s+=n||1}i=Math.max(i,s)}return{rows:e,columns:i}},_markDataTables:function(t){for(var e=t.getElementsByTagName("table"),i=0;i<e.length;i++){var r=e[i],l=r.getAttribute("role");if(l=="presentation"){r._readabilityDataTable=!1;continue}var a=r.getAttribute("datatable");if(a=="0"){r._readabilityDataTable=!1;continue}var s=r.getAttribute("summary");if(s){r._readabilityDataTable=!0;continue}var h=r.getElementsByTagName("caption")[0];if(h&&h.childNodes.length>0){r._readabilityDataTable=!0;continue}var c=["col","colgroup","tfoot","thead","th"],n=function(m){return!!r.getElementsByTagName(m)[0]};if(c.some(n)){this.log("Data table because found data-y descendant"),r._readabilityDataTable=!0;continue}if(r.getElementsByTagName("table")[0]){r._readabilityDataTable=!1;continue}var u=this._getRowAndColumnCount(r);if(u.rows>=10||u.columns>4){r._readabilityDataTable=!0;continue}r._readabilityDataTable=u.rows*u.columns>10}},_fixLazyImages:function(t){this._forEachNode(this._getAllNodesWithTag(t,["img","picture","figure"]),function(e){if(e.src&&this.REGEXPS.b64DataUrl.test(e.src)){var i=this.REGEXPS.b64DataUrl.exec(e.src);if(i[1]==="image/svg+xml")return;for(var r=!1,l=0;l<e.attributes.length;l++){var a=e.attributes[l];if(a.name!=="src"&&/\\.(jpg|jpeg|png|webp)/i.test(a.value)){r=!0;break}}if(r){var s=e.src.search(/base64\\s*/i)+7,h=e.src.length-s;h<133&&e.removeAttribute("src")}}if(!((e.src||e.srcset&&e.srcset!="null")&&e.className.toLowerCase().indexOf("lazy")===-1)){for(var c=0;c<e.attributes.length;c++)if(a=e.attributes[c],!(a.name==="src"||a.name==="srcset"||a.name==="alt")){var n=null;if(/\\.(jpg|jpeg|png|webp)\\s+\\d/.test(a.value)?n="srcset":/^\\s*\\S+\\.(jpg|jpeg|png|webp)\\S*\\s*$/.test(a.value)&&(n="src"),n){if(e.tagName==="IMG"||e.tagName==="PICTURE")e.setAttribute(n,a.value);else if(e.tagName==="FIGURE"&&!this._getAllNodesWithTag(e,["img","picture"]).length){var u=this._doc.createElement("img");u.setAttribute(n,a.value),e.appendChild(u)}}}}})},_getTextDensity:function(t,e){var i=this._getInnerText(t,!0).length;if(i===0)return 0;var r=0,l=this._getAllNodesWithTag(t,e);return this._forEachNode(l,a=>r+=this._getInnerText(a,!0).length),r/i},_cleanConditionally:function(t,e){this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY)&&this._removeNodes(this._getAllNodesWithTag(t,[e]),function(i){var r=function(g){return g._readabilityDataTable},l=e==="ul"||e==="ol";if(!l){var a=0,s=this._getAllNodesWithTag(i,["ul","ol"]);this._forEachNode(s,g=>a+=this._getInnerText(g).length),l=a/this._getInnerText(i).length>.9}if(e==="table"&&r(i)||this._hasAncestorTag(i,"table",-1,r)||this._hasAncestorTag(i,"code"))return!1;var h=this._getClassWeight(i);this.log("Cleaning Conditionally",i);var c=0;if(h+c<0)return!0;if(this._getCharCount(i,",")<10){for(var n=i.getElementsByTagName("p").length,u=i.getElementsByTagName("img").length,m=i.getElementsByTagName("li").length-100,b=i.getElementsByTagName("input").length,N=this._getTextDensity(i,["h1","h2","h3","h4","h5","h6"]),v=0,y=this._getAllNodesWithTag(i,["object","embed","iframe"]),E=0;E<y.length;E++){for(var d=0;d<y[E].attributes.length;d++)if(this._allowedVideoRegex.test(y[E].attributes[d].value))return!1;if(y[E].tagName==="object"&&this._allowedVideoRegex.test(y[E].innerHTML))return!1;v++}var p=this._getLinkDensity(i),x=this._getInnerText(i).length,o=u>1&&n/u<.5&&!this._hasAncestorTag(i,"figure")||!l&&m>n||b>Math.floor(n/3)||!l&&N<.9&&x<25&&(u===0||u>2)&&!this._hasAncestorTag(i,"figure")||!l&&h<25&&p>.2||h>=25&&p>.5||v===1&&x<75||v>1;if(l&&o){for(var L=0;L<i.children.length;L++)if(i.children[L].children.length>1)return o;let g=i.getElementsByTagName("li").length;if(u==g)return!1}return o}return!1})},_cleanMatchedNodes:function(t,e){for(var i=this._getNextNode(t,!0),r=this._getNextNode(t);r&&r!=i;)e.call(this,r,r.className+" "+r.id)?r=this._removeAndGetNext(r):r=this._getNextNode(r)},_cleanHeaders:function(t){let e=this._getAllNodesWithTag(t,["h1","h2"]);this._removeNodes(e,function(i){let r=this._getClassWeight(i)<0;return r&&this.log("Removing header with low class weight:",i),r})},_headerDuplicatesTitle:function(t){if(t.tagName!="H1"&&t.tagName!="H2")return!1;var e=this._getInnerText(t,!1);return this.log("Evaluating similarity of header:",e,this._articleTitle),this._textSimilarity(this._articleTitle,e)>.75},_flagIsActive:function(t){return(this._flags&t)>0},_removeFlag:function(t){this._flags=this._flags&~t},_isProbablyVisible:function(t){return(!t.style||t.style.display!="none")&&(!t.style||t.style.visibility!="hidden")&&!t.hasAttribute("hidden")&&(!t.hasAttribute("aria-hidden")||t.getAttribute("aria-hidden")!="true"||t.className&&t.className.indexOf&&t.className.indexOf("fallback-image")!==-1)},parse:function(){if(this._maxElemsToParse>0){var t=this._doc.getElementsByTagName("*").length;if(t>this._maxElemsToParse)throw new Error("Aborting parsing document; "+t+" elements found")}this._unwrapNoscriptImages(this._doc);var e=this._disableJSONLD?{}:this._getJSONLD(this._doc);this._removeScripts(this._doc),this._prepDocument();var i=this._getArticleMetadata(e);this._articleTitle=i.title;var r=this._grabArticle();if(!r)return null;if(this.log("Grabbed: "+r.innerHTML),this._postProcessContent(r),!i.excerpt){var l=r.getElementsByTagName("p");l.length>0&&(i.excerpt=l[0].textContent.trim())}var a=r.textContent;return{title:this._articleTitle,byline:i.byline||this._articleByline,dir:this._articleDir,lang:this._articleLang,content:this._serializer(r),textContent:a,length:a.length,excerpt:i.excerpt,siteName:i.siteName||this._articleSiteName,publishedTime:i.publishedTime}}};typeof module=="object"&&(module.exports=q);\n';
6
+ export { READABILITY_SCRIPT };
7
+
8
+ //# sourceMappingURL=readability-script.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content/readability-script.mjs","sources":["webpack://@agent-infra/browser-context/./src/content/readability-script.ts"],"sourcesContent":["/**\n * PLEASE DO NOT MODIFY IT as it is generated by the build script\n *\n * Build: scripts/build-readability.ts\n * Source: https://github.com/mozilla/readability/blob/main/Readability.js\n */\n\n/**\n * Copyright (c) 2010 Arc90 Inc\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const READABILITY_SCRIPT =\n 'function q(t,e){if(e&&e.documentElement)t=e,e=arguments[2];else if(!t||!t.documentElement)throw new Error(\"First argument to Readability constructor should be a document object.\");if(e=e||{},this._doc=t,this._docJSDOMParser=this._doc.firstChild.__JSDOMParser__,this._articleTitle=null,this._articleByline=null,this._articleDir=null,this._articleSiteName=null,this._attempts=[],this._debug=!!e.debug,this._maxElemsToParse=e.maxElemsToParse||this.DEFAULT_MAX_ELEMS_TO_PARSE,this._nbTopCandidates=e.nbTopCandidates||this.DEFAULT_N_TOP_CANDIDATES,this._charThreshold=e.charThreshold||this.DEFAULT_CHAR_THRESHOLD,this._classesToPreserve=this.CLASSES_TO_PRESERVE.concat(e.classesToPreserve||[]),this._keepClasses=!!e.keepClasses,this._serializer=e.serializer||function(i){return i.innerHTML},this._disableJSONLD=!!e.disableJSONLD,this._allowedVideoRegex=e.allowedVideoRegex||this.REGEXPS.videos,this._flags=this.FLAG_STRIP_UNLIKELYS|this.FLAG_WEIGHT_CLASSES|this.FLAG_CLEAN_CONDITIONALLY,this._debug){let i=function(r){if(r.nodeType==r.TEXT_NODE)return`${r.nodeName} (\"${r.textContent}\")`;let l=Array.from(r.attributes||[],function(a){return`${a.name}=\"${a.value}\"`}).join(\" \");return`<${r.localName} ${l}>`};this.log=function(){if(typeof console!=\"undefined\"){let l=Array.from(arguments,a=>a&&a.nodeType==this.ELEMENT_NODE?i(a):a);l.unshift(\"Reader: (Readability)\"),console.log.apply(console,l)}else if(typeof dump!=\"undefined\"){var r=Array.prototype.map.call(arguments,function(l){return l&&l.nodeName?i(l):l}).join(\" \");dump(\"Reader: (Readability) \"+r+`\\n`)}}}else this.log=function(){}}q.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,commas:/\\\\u002C|\\\\u060C|\\\\uFE50|\\\\uFE10|\\\\uFE11|\\\\u2E41|\\\\u2E34|\\\\u2E32|\\\\uFF0C/g,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(t){this._fixRelativeUris(t),this._simplifyNestedElements(t),this._keepClasses||this._cleanClasses(t)},_removeNodes:function(t,e){if(this._docJSDOMParser&&t._isLiveNodeList)throw new Error(\"Do not pass live node lists to _removeNodes\");for(var i=t.length-1;i>=0;i--){var r=t[i],l=r.parentNode;l&&(!e||e.call(this,r,i,t))&&l.removeChild(r)}},_replaceNodeTags:function(t,e){if(this._docJSDOMParser&&t._isLiveNodeList)throw new Error(\"Do not pass live node lists to _replaceNodeTags\");for(let i of t)this._setNodeTag(i,e)},_forEachNode:function(t,e){Array.prototype.forEach.call(t,e,this)},_findNode:function(t,e){return Array.prototype.find.call(t,e,this)},_someNode:function(t,e){return Array.prototype.some.call(t,e,this)},_everyNode:function(t,e){return Array.prototype.every.call(t,e,this)},_concatNodeLists:function(){var t=Array.prototype.slice,e=t.call(arguments),i=e.map(function(r){return t.call(r)});return Array.prototype.concat.apply([],i)},_getAllNodesWithTag:function(t,e){return t.querySelectorAll?t.querySelectorAll(e.join(\",\")):[].concat.apply([],e.map(function(i){var r=t.getElementsByTagName(i);return Array.isArray(r)?r:Array.from(r)}))},_cleanClasses:function(t){var e=this._classesToPreserve,i=(t.getAttribute(\"class\")||\"\").split(/\\\\s+/).filter(function(r){return e.indexOf(r)!=-1}).join(\" \");for(i?t.setAttribute(\"class\",i):t.removeAttribute(\"class\"),t=t.firstElementChild;t;t=t.nextElementSibling)this._cleanClasses(t)},_fixRelativeUris:function(t){var e=this._doc.baseURI,i=this._doc.documentURI;function r(s){if(e==i&&s.charAt(0)==\"#\")return s;try{return new URL(s,e).href}catch(h){}return s}var l=this._getAllNodesWithTag(t,[\"a\"]);this._forEachNode(l,function(s){var h=s.getAttribute(\"href\");if(h)if(h.indexOf(\"javascript:\")===0)if(s.childNodes.length===1&&s.childNodes[0].nodeType===this.TEXT_NODE){var c=this._doc.createTextNode(s.textContent);s.parentNode.replaceChild(c,s)}else{for(var n=this._doc.createElement(\"span\");s.firstChild;)n.appendChild(s.firstChild);s.parentNode.replaceChild(n,s)}else s.setAttribute(\"href\",r(h))});var a=this._getAllNodesWithTag(t,[\"img\",\"picture\",\"figure\",\"video\",\"audio\",\"source\"]);this._forEachNode(a,function(s){var h=s.getAttribute(\"src\"),c=s.getAttribute(\"poster\"),n=s.getAttribute(\"srcset\");if(h&&s.setAttribute(\"src\",r(h)),c&&s.setAttribute(\"poster\",r(c)),n){var u=n.replace(this.REGEXPS.srcsetUrl,function(m,b,N,v){return r(b)+(N||\"\")+v});s.setAttribute(\"srcset\",u)}})},_simplifyNestedElements:function(t){for(var e=t;e;){if(e.parentNode&&[\"DIV\",\"SECTION\"].includes(e.tagName)&&!(e.id&&e.id.startsWith(\"readability\"))){if(this._isElementWithoutContent(e)){e=this._removeAndGetNext(e);continue}else if(this._hasSingleTagInsideElement(e,\"DIV\")||this._hasSingleTagInsideElement(e,\"SECTION\")){for(var i=e.children[0],r=0;r<e.attributes.length;r++)i.setAttribute(e.attributes[r].name,e.attributes[r].value);e.parentNode.replaceChild(i,e),e=i;continue}}e=this._getNextNode(e)}},_getArticleTitle:function(){var t=this._doc,e=\"\",i=\"\";try{e=i=t.title.trim(),typeof e!=\"string\"&&(e=i=this._getInnerText(t.getElementsByTagName(\"title\")[0]))}catch(u){}var r=!1;function l(u){return u.split(/\\\\s+/).length}if(/ [\\\\|\\\\-\\\\\\\\\\\\/>»] /.test(e))r=/ [\\\\\\\\\\\\/>»] /.test(e),e=i.replace(/(.*)[\\\\|\\\\-\\\\\\\\\\\\/>»] .*/gi,\"$1\"),l(e)<3&&(e=i.replace(/[^\\\\|\\\\-\\\\\\\\\\\\/>»]*[\\\\|\\\\-\\\\\\\\\\\\/>»](.*)/gi,\"$1\"));else if(e.indexOf(\": \")!==-1){var a=this._concatNodeLists(t.getElementsByTagName(\"h1\"),t.getElementsByTagName(\"h2\")),s=e.trim(),h=this._someNode(a,function(u){return u.textContent.trim()===s});h||(e=i.substring(i.lastIndexOf(\":\")+1),l(e)<3?e=i.substring(i.indexOf(\":\")+1):l(i.substr(0,i.indexOf(\":\")))>5&&(e=i))}else if(e.length>150||e.length<15){var c=t.getElementsByTagName(\"h1\");c.length===1&&(e=this._getInnerText(c[0]))}e=e.trim().replace(this.REGEXPS.normalize,\" \");var n=l(e);return n<=4&&(!r||n!=l(i.replace(/[\\\\|\\\\-\\\\\\\\\\\\/>»]+/g,\"\"))-1)&&(e=i),e},_prepDocument:function(){var t=this._doc;this._removeNodes(this._getAllNodesWithTag(t,[\"style\"])),t.body&&this._replaceBrs(t.body),this._replaceNodeTags(this._getAllNodesWithTag(t,[\"font\"]),\"SPAN\")},_nextNode:function(t){for(var e=t;e&&e.nodeType!=this.ELEMENT_NODE&&this.REGEXPS.whitespace.test(e.textContent);)e=e.nextSibling;return e},_replaceBrs:function(t){this._forEachNode(this._getAllNodesWithTag(t,[\"br\"]),function(e){for(var i=e.nextSibling,r=!1;(i=this._nextNode(i))&&i.tagName==\"BR\";){r=!0;var l=i.nextSibling;i.parentNode.removeChild(i),i=l}if(r){var a=this._doc.createElement(\"p\");for(e.parentNode.replaceChild(a,e),i=a.nextSibling;i;){if(i.tagName==\"BR\"){var s=this._nextNode(i.nextSibling);if(s&&s.tagName==\"BR\")break}if(!this._isPhrasingContent(i))break;var h=i.nextSibling;a.appendChild(i),i=h}for(;a.lastChild&&this._isWhitespace(a.lastChild);)a.removeChild(a.lastChild);a.parentNode.tagName===\"P\"&&this._setNodeTag(a.parentNode,\"DIV\")}})},_setNodeTag:function(t,e){if(this.log(\"_setNodeTag\",t,e),this._docJSDOMParser)return t.localName=e.toLowerCase(),t.tagName=e.toUpperCase(),t;for(var i=t.ownerDocument.createElement(e);t.firstChild;)i.appendChild(t.firstChild);t.parentNode.replaceChild(i,t),t.readability&&(i.readability=t.readability);for(var r=0;r<t.attributes.length;r++)try{i.setAttribute(t.attributes[r].name,t.attributes[r].value)}catch(l){}return i},_prepArticle:function(t){this._cleanStyles(t),this._markDataTables(t),this._fixLazyImages(t),this._cleanConditionally(t,\"form\"),this._cleanConditionally(t,\"fieldset\"),this._clean(t,\"object\"),this._clean(t,\"embed\"),this._clean(t,\"footer\"),this._clean(t,\"link\"),this._clean(t,\"aside\");var e=this.DEFAULT_CHAR_THRESHOLD;this._forEachNode(t.children,function(i){this._cleanMatchedNodes(i,function(r,l){return this.REGEXPS.shareElements.test(l)&&r.textContent.length<e})}),this._clean(t,\"iframe\"),this._clean(t,\"input\"),this._clean(t,\"textarea\"),this._clean(t,\"select\"),this._clean(t,\"button\"),this._cleanHeaders(t),this._cleanConditionally(t,\"table\"),this._cleanConditionally(t,\"ul\"),this._cleanConditionally(t,\"div\"),this._replaceNodeTags(this._getAllNodesWithTag(t,[\"h1\"]),\"h2\"),this._removeNodes(this._getAllNodesWithTag(t,[\"p\"]),function(i){var r=i.getElementsByTagName(\"img\").length,l=i.getElementsByTagName(\"embed\").length,a=i.getElementsByTagName(\"object\").length,s=i.getElementsByTagName(\"iframe\").length,h=r+l+a+s;return h===0&&!this._getInnerText(i,!1)}),this._forEachNode(this._getAllNodesWithTag(t,[\"br\"]),function(i){var r=this._nextNode(i.nextSibling);r&&r.tagName==\"P\"&&i.parentNode.removeChild(i)}),this._forEachNode(this._getAllNodesWithTag(t,[\"table\"]),function(i){var r=this._hasSingleTagInsideElement(i,\"TBODY\")?i.firstElementChild:i;if(this._hasSingleTagInsideElement(r,\"TR\")){var l=r.firstElementChild;if(this._hasSingleTagInsideElement(l,\"TD\")){var a=l.firstElementChild;a=this._setNodeTag(a,this._everyNode(a.childNodes,this._isPhrasingContent)?\"P\":\"DIV\"),i.parentNode.replaceChild(a,i)}}})},_initializeNode:function(t){switch(t.readability={contentScore:0},t.tagName){case\"DIV\":t.readability.contentScore+=5;break;case\"PRE\":case\"TD\":case\"BLOCKQUOTE\":t.readability.contentScore+=3;break;case\"ADDRESS\":case\"OL\":case\"UL\":case\"DL\":case\"DD\":case\"DT\":case\"LI\":case\"FORM\":t.readability.contentScore-=3;break;case\"H1\":case\"H2\":case\"H3\":case\"H4\":case\"H5\":case\"H6\":case\"TH\":t.readability.contentScore-=5;break}t.readability.contentScore+=this._getClassWeight(t)},_removeAndGetNext:function(t){var e=this._getNextNode(t,!0);return t.parentNode.removeChild(t),e},_getNextNode:function(t,e){if(!e&&t.firstElementChild)return t.firstElementChild;if(t.nextElementSibling)return t.nextElementSibling;do t=t.parentNode;while(t&&!t.nextElementSibling);return t&&t.nextElementSibling},_textSimilarity:function(t,e){var i=t.toLowerCase().split(this.REGEXPS.tokenize).filter(Boolean),r=e.toLowerCase().split(this.REGEXPS.tokenize).filter(Boolean);if(!i.length||!r.length)return 0;var l=r.filter(s=>!i.includes(s)),a=l.join(\" \").length/r.join(\" \").length;return 1-a},_checkByline:function(t,e){if(this._articleByline)return!1;if(t.getAttribute!==void 0)var i=t.getAttribute(\"rel\"),r=t.getAttribute(\"itemprop\");return(i===\"author\"||r&&r.indexOf(\"author\")!==-1||this.REGEXPS.byline.test(e))&&this._isValidByline(t.textContent)?(this._articleByline=t.textContent.trim(),!0):!1},_getNodeAncestors:function(t,e){e=e||0;for(var i=0,r=[];t.parentNode&&(r.push(t.parentNode),!(e&&++i===e));)t=t.parentNode;return r},_grabArticle:function(t){this.log(\"**** grabArticle ****\");var e=this._doc,i=t!==null;if(t=t||this._doc.body,!t)return this.log(\"No body found in document. Abort.\"),null;for(var r=t.innerHTML;;){this.log(\"Starting grabArticle loop\");var l=this._flagIsActive(this.FLAG_STRIP_UNLIKELYS),a=[],s=this._doc.documentElement;let J=!0;for(;s;){s.tagName===\"HTML\"&&(this._articleLang=s.getAttribute(\"lang\"));var h=s.className+\" \"+s.id;if(!this._isProbablyVisible(s)){this.log(\"Removing hidden node - \"+h),s=this._removeAndGetNext(s);continue}if(s.getAttribute(\"aria-modal\")==\"true\"&&s.getAttribute(\"role\")==\"dialog\"){s=this._removeAndGetNext(s);continue}if(this._checkByline(s,h)){s=this._removeAndGetNext(s);continue}if(J&&this._headerDuplicatesTitle(s)){this.log(\"Removing header: \",s.textContent.trim(),this._articleTitle.trim()),J=!1,s=this._removeAndGetNext(s);continue}if(l){if(this.REGEXPS.unlikelyCandidates.test(h)&&!this.REGEXPS.okMaybeItsACandidate.test(h)&&!this._hasAncestorTag(s,\"table\")&&!this._hasAncestorTag(s,\"code\")&&s.tagName!==\"BODY\"&&s.tagName!==\"A\"){this.log(\"Removing unlikely candidate - \"+h),s=this._removeAndGetNext(s);continue}if(this.UNLIKELY_ROLES.includes(s.getAttribute(\"role\"))){this.log(\"Removing content with role \"+s.getAttribute(\"role\")+\" - \"+h),s=this._removeAndGetNext(s);continue}}if((s.tagName===\"DIV\"||s.tagName===\"SECTION\"||s.tagName===\"HEADER\"||s.tagName===\"H1\"||s.tagName===\"H2\"||s.tagName===\"H3\"||s.tagName===\"H4\"||s.tagName===\"H5\"||s.tagName===\"H6\")&&this._isElementWithoutContent(s)){s=this._removeAndGetNext(s);continue}if(this.DEFAULT_TAGS_TO_SCORE.indexOf(s.tagName)!==-1&&a.push(s),s.tagName===\"DIV\"){for(var c=null,n=s.firstChild;n;){var u=n.nextSibling;if(this._isPhrasingContent(n))c!==null?c.appendChild(n):this._isWhitespace(n)||(c=e.createElement(\"p\"),s.replaceChild(c,n),c.appendChild(n));else if(c!==null){for(;c.lastChild&&this._isWhitespace(c.lastChild);)c.removeChild(c.lastChild);c=null}n=u}if(this._hasSingleTagInsideElement(s,\"P\")&&this._getLinkDensity(s)<.25){var m=s.children[0];s.parentNode.replaceChild(m,s),s=m,a.push(s)}else this._hasChildBlockElement(s)||(s=this._setNodeTag(s,\"P\"),a.push(s))}s=this._getNextNode(s)}var b=[];this._forEachNode(a,function(A){if(!(!A.parentNode||typeof A.parentNode.tagName==\"undefined\")){var T=this._getInnerText(A);if(!(T.length<25)){var K=this._getNodeAncestors(A,5);if(K.length!==0){var C=0;C+=1,C+=T.split(this.REGEXPS.commas).length,C+=Math.min(Math.floor(T.length/100),3),this._forEachNode(K,function(S,F){if(!(!S.tagName||!S.parentNode||typeof S.parentNode.tagName==\"undefined\")){if(typeof S.readability==\"undefined\"&&(this._initializeNode(S),b.push(S)),F===0)var X=1;else F===1?X=2:X=F*3;S.readability.contentScore+=C/X}})}}}});for(var N=[],v=0,y=b.length;v<y;v+=1){var E=b[v],d=E.readability.contentScore*(1-this._getLinkDensity(E));E.readability.contentScore=d,this.log(\"Candidate:\",E,\"with score \"+d);for(var p=0;p<this._nbTopCandidates;p++){var x=N[p];if(!x||d>x.readability.contentScore){N.splice(p,0,E),N.length>this._nbTopCandidates&&N.pop();break}}}var o=N[0]||null,L=!1,g;if(o===null||o.tagName===\"BODY\"){for(o=e.createElement(\"DIV\"),L=!0;t.firstChild;)this.log(\"Moving child out:\",t.firstChild),o.appendChild(t.firstChild);t.appendChild(o),this._initializeNode(o)}else if(o){for(var I=[],P=1;P<N.length;P++)N[P].readability.contentScore/o.readability.contentScore>=.75&&I.push(this._getNodeAncestors(N[P]));var O=3;if(I.length>=O)for(g=o.parentNode;g.tagName!==\"BODY\";){for(var G=0,H=0;H<I.length&&G<O;H++)G+=Number(I[H].includes(g));if(G>=O){o=g;break}g=g.parentNode}o.readability||this._initializeNode(o),g=o.parentNode;for(var M=o.readability.contentScore,Q=M/3;g.tagName!==\"BODY\";){if(!g.readability){g=g.parentNode;continue}var V=g.readability.contentScore;if(V<Q)break;if(V>M){o=g;break}M=g.readability.contentScore,g=g.parentNode}for(g=o.parentNode;g.tagName!=\"BODY\"&&g.children.length==1;)o=g,g=o.parentNode;o.readability||this._initializeNode(o)}var _=e.createElement(\"DIV\");i&&(_.id=\"readability-content\");var Z=Math.max(10,o.readability.contentScore*.2);g=o.parentNode;for(var U=g.children,w=0,j=U.length;w<j;w++){var f=U[w],R=!1;if(this.log(\"Looking at sibling node:\",f,f.readability?\"with score \"+f.readability.contentScore:\"\"),this.log(\"Sibling has score\",f.readability?f.readability.contentScore:\"Unknown\"),f===o)R=!0;else{var $=0;if(f.className===o.className&&o.className!==\"\"&&($+=o.readability.contentScore*.2),f.readability&&f.readability.contentScore+$>=Z)R=!0;else if(f.nodeName===\"P\"){var Y=this._getLinkDensity(f),z=this._getInnerText(f),k=z.length;(k>80&&Y<.25||k<80&&k>0&&Y===0&&z.search(/\\\\.( |$)/)!==-1)&&(R=!0)}}R&&(this.log(\"Appending node:\",f),this.ALTER_TO_DIV_EXCEPTIONS.indexOf(f.nodeName)===-1&&(this.log(\"Altering sibling:\",f,\"to div.\"),f=this._setNodeTag(f,\"DIV\")),_.appendChild(f),U=g.children,w-=1,j-=1)}if(this._debug&&this.log(\"Article content pre-prep: \"+_.innerHTML),this._prepArticle(_),this._debug&&this.log(\"Article content post-prep: \"+_.innerHTML),L)o.id=\"readability-page-1\",o.className=\"page\";else{var B=e.createElement(\"DIV\");for(B.id=\"readability-page-1\",B.className=\"page\";_.firstChild;)B.appendChild(_.firstChild);_.appendChild(B)}this._debug&&this.log(\"Article content after paging: \"+_.innerHTML);var W=!0,D=this._getInnerText(_,!0).length;if(D<this._charThreshold)if(W=!1,t.innerHTML=r,this._flagIsActive(this.FLAG_STRIP_UNLIKELYS))this._removeFlag(this.FLAG_STRIP_UNLIKELYS),this._attempts.push({articleContent:_,textLength:D});else if(this._flagIsActive(this.FLAG_WEIGHT_CLASSES))this._removeFlag(this.FLAG_WEIGHT_CLASSES),this._attempts.push({articleContent:_,textLength:D});else if(this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY))this._removeFlag(this.FLAG_CLEAN_CONDITIONALLY),this._attempts.push({articleContent:_,textLength:D});else{if(this._attempts.push({articleContent:_,textLength:D}),this._attempts.sort(function(A,T){return T.textLength-A.textLength}),!this._attempts[0].textLength)return null;_=this._attempts[0].articleContent,W=!0}if(W){var tt=[g,o].concat(this._getNodeAncestors(g));return this._someNode(tt,function(A){if(!A.tagName)return!1;var T=A.getAttribute(\"dir\");return T?(this._articleDir=T,!0):!1}),_}}},_isValidByline:function(t){return typeof t==\"string\"||t instanceof String?(t=t.trim(),t.length>0&&t.length<100):!1},_unescapeHtmlEntities:function(t){if(!t)return t;var e=this.HTML_ESCAPE_MAP;return t.replace(/&(quot|amp|apos|lt|gt);/g,function(i,r){return e[r]}).replace(/&#(?:x([0-9a-z]{1,4})|([0-9]{1,4}));/gi,function(i,r,l){var a=parseInt(r||l,r?16:10);return String.fromCharCode(a)})},_getJSONLD:function(t){var e=this._getAllNodesWithTag(t,[\"script\"]),i;return this._forEachNode(e,function(r){if(!i&&r.getAttribute(\"type\")===\"application/ld+json\")try{var l=r.textContent.replace(/^\\\\s*<!\\\\[CDATA\\\\[|\\\\]\\\\]>\\\\s*$/g,\"\"),a=JSON.parse(l);if(!a[\"@context\"]||!a[\"@context\"].match(/^https?\\\\:\\\\/\\\\/schema\\\\.org$/)||(!a[\"@type\"]&&Array.isArray(a[\"@graph\"])&&(a=a[\"@graph\"].find(function(n){return(n[\"@type\"]||\"\").match(this.REGEXPS.jsonLdArticleTypes)})),!a||!a[\"@type\"]||!a[\"@type\"].match(this.REGEXPS.jsonLdArticleTypes)))return;if(i={},typeof a.name==\"string\"&&typeof a.headline==\"string\"&&a.name!==a.headline){var s=this._getArticleTitle(),h=this._textSimilarity(a.name,s)>.75,c=this._textSimilarity(a.headline,s)>.75;c&&!h?i.title=a.headline:i.title=a.name}else typeof a.name==\"string\"?i.title=a.name.trim():typeof a.headline==\"string\"&&(i.title=a.headline.trim());a.author&&(typeof a.author.name==\"string\"?i.byline=a.author.name.trim():Array.isArray(a.author)&&a.author[0]&&typeof a.author[0].name==\"string\"&&(i.byline=a.author.filter(function(n){return n&&typeof n.name==\"string\"}).map(function(n){return n.name.trim()}).join(\", \"))),typeof a.description==\"string\"&&(i.excerpt=a.description.trim()),a.publisher&&typeof a.publisher.name==\"string\"&&(i.siteName=a.publisher.name.trim()),typeof a.datePublished==\"string\"&&(i.datePublished=a.datePublished.trim());return}catch(n){this.log(n.message)}}),i||{}},_getArticleMetadata:function(t){var e={},i={},r=this._doc.getElementsByTagName(\"meta\"),l=/\\\\s*(article|dc|dcterm|og|twitter)\\\\s*:\\\\s*(author|creator|description|published_time|title|site_name)\\\\s*/gi,a=/^\\\\s*(?:(dc|dcterm|og|twitter|weibo:(article|webpage))\\\\s*[\\\\.:]\\\\s*)?(author|creator|description|title|site_name)\\\\s*$/i;return this._forEachNode(r,function(s){var h=s.getAttribute(\"name\"),c=s.getAttribute(\"property\"),n=s.getAttribute(\"content\");if(n){var u=null,m=null;c&&(u=c.match(l),u&&(m=u[0].toLowerCase().replace(/\\\\s/g,\"\"),i[m]=n.trim())),!u&&h&&a.test(h)&&(m=h,n&&(m=m.toLowerCase().replace(/\\\\s/g,\"\").replace(/\\\\./g,\":\"),i[m]=n.trim()))}}),e.title=t.title||i[\"dc:title\"]||i[\"dcterm:title\"]||i[\"og:title\"]||i[\"weibo:article:title\"]||i[\"weibo:webpage:title\"]||i.title||i[\"twitter:title\"],e.title||(e.title=this._getArticleTitle()),e.byline=t.byline||i[\"dc:creator\"]||i[\"dcterm:creator\"]||i.author,e.excerpt=t.excerpt||i[\"dc:description\"]||i[\"dcterm:description\"]||i[\"og:description\"]||i[\"weibo:article:description\"]||i[\"weibo:webpage:description\"]||i.description||i[\"twitter:description\"],e.siteName=t.siteName||i[\"og:site_name\"],e.publishedTime=t.datePublished||i[\"article:published_time\"]||null,e.title=this._unescapeHtmlEntities(e.title),e.byline=this._unescapeHtmlEntities(e.byline),e.excerpt=this._unescapeHtmlEntities(e.excerpt),e.siteName=this._unescapeHtmlEntities(e.siteName),e.publishedTime=this._unescapeHtmlEntities(e.publishedTime),e},_isSingleImage:function(t){return t.tagName===\"IMG\"?!0:t.children.length!==1||t.textContent.trim()!==\"\"?!1:this._isSingleImage(t.children[0])},_unwrapNoscriptImages:function(t){var e=Array.from(t.getElementsByTagName(\"img\"));this._forEachNode(e,function(r){for(var l=0;l<r.attributes.length;l++){var a=r.attributes[l];switch(a.name){case\"src\":case\"srcset\":case\"data-src\":case\"data-srcset\":return}if(/\\\\.(jpg|jpeg|png|webp)/i.test(a.value))return}r.parentNode.removeChild(r)});var i=Array.from(t.getElementsByTagName(\"noscript\"));this._forEachNode(i,function(r){var l=t.createElement(\"div\");if(l.innerHTML=r.innerHTML,!!this._isSingleImage(l)){var a=r.previousElementSibling;if(a&&this._isSingleImage(a)){var s=a;s.tagName!==\"IMG\"&&(s=a.getElementsByTagName(\"img\")[0]);for(var h=l.getElementsByTagName(\"img\")[0],c=0;c<s.attributes.length;c++){var n=s.attributes[c];if(n.value!==\"\"&&(n.name===\"src\"||n.name===\"srcset\"||/\\\\.(jpg|jpeg|png|webp)/i.test(n.value))){if(h.getAttribute(n.name)===n.value)continue;var u=n.name;h.hasAttribute(u)&&(u=\"data-old-\"+u),h.setAttribute(u,n.value)}}r.parentNode.replaceChild(l.firstElementChild,a)}}})},_removeScripts:function(t){this._removeNodes(this._getAllNodesWithTag(t,[\"script\",\"noscript\"]))},_hasSingleTagInsideElement:function(t,e){return t.children.length!=1||t.children[0].tagName!==e?!1:!this._someNode(t.childNodes,function(i){return i.nodeType===this.TEXT_NODE&&this.REGEXPS.hasContent.test(i.textContent)})},_isElementWithoutContent:function(t){return t.nodeType===this.ELEMENT_NODE&&t.textContent.trim().length==0&&(t.children.length==0||t.children.length==t.getElementsByTagName(\"br\").length+t.getElementsByTagName(\"hr\").length)},_hasChildBlockElement:function(t){return this._someNode(t.childNodes,function(e){return this.DIV_TO_P_ELEMS.has(e.tagName)||this._hasChildBlockElement(e)})},_isPhrasingContent:function(t){return t.nodeType===this.TEXT_NODE||this.PHRASING_ELEMS.indexOf(t.tagName)!==-1||(t.tagName===\"A\"||t.tagName===\"DEL\"||t.tagName===\"INS\")&&this._everyNode(t.childNodes,this._isPhrasingContent)},_isWhitespace:function(t){return t.nodeType===this.TEXT_NODE&&t.textContent.trim().length===0||t.nodeType===this.ELEMENT_NODE&&t.tagName===\"BR\"},_getInnerText:function(t,e){e=typeof e==\"undefined\"?!0:e;var i=t.textContent.trim();return e?i.replace(this.REGEXPS.normalize,\" \"):i},_getCharCount:function(t,e){return e=e||\",\",this._getInnerText(t).split(e).length-1},_cleanStyles:function(t){if(!(!t||t.tagName.toLowerCase()===\"svg\")){for(var e=0;e<this.PRESENTATIONAL_ATTRIBUTES.length;e++)t.removeAttribute(this.PRESENTATIONAL_ATTRIBUTES[e]);this.DEPRECATED_SIZE_ATTRIBUTE_ELEMS.indexOf(t.tagName)!==-1&&(t.removeAttribute(\"width\"),t.removeAttribute(\"height\"));for(var i=t.firstElementChild;i!==null;)this._cleanStyles(i),i=i.nextElementSibling}},_getLinkDensity:function(t){var e=this._getInnerText(t).length;if(e===0)return 0;var i=0;return this._forEachNode(t.getElementsByTagName(\"a\"),function(r){var l=r.getAttribute(\"href\"),a=l&&this.REGEXPS.hashUrl.test(l)?.3:1;i+=this._getInnerText(r).length*a}),i/e},_getClassWeight:function(t){if(!this._flagIsActive(this.FLAG_WEIGHT_CLASSES))return 0;var e=0;return typeof t.className==\"string\"&&t.className!==\"\"&&(this.REGEXPS.negative.test(t.className)&&(e-=25),this.REGEXPS.positive.test(t.className)&&(e+=25)),typeof t.id==\"string\"&&t.id!==\"\"&&(this.REGEXPS.negative.test(t.id)&&(e-=25),this.REGEXPS.positive.test(t.id)&&(e+=25)),e},_clean:function(t,e){var i=[\"object\",\"embed\",\"iframe\"].indexOf(e)!==-1;this._removeNodes(this._getAllNodesWithTag(t,[e]),function(r){if(i){for(var l=0;l<r.attributes.length;l++)if(this._allowedVideoRegex.test(r.attributes[l].value))return!1;if(r.tagName===\"object\"&&this._allowedVideoRegex.test(r.innerHTML))return!1}return!0})},_hasAncestorTag:function(t,e,i,r){i=i||3,e=e.toUpperCase();for(var l=0;t.parentNode;){if(i>0&&l>i)return!1;if(t.parentNode.tagName===e&&(!r||r(t.parentNode)))return!0;t=t.parentNode,l++}return!1},_getRowAndColumnCount:function(t){for(var e=0,i=0,r=t.getElementsByTagName(\"tr\"),l=0;l<r.length;l++){var a=r[l].getAttribute(\"rowspan\")||0;a&&(a=parseInt(a,10)),e+=a||1;for(var s=0,h=r[l].getElementsByTagName(\"td\"),c=0;c<h.length;c++){var n=h[c].getAttribute(\"colspan\")||0;n&&(n=parseInt(n,10)),s+=n||1}i=Math.max(i,s)}return{rows:e,columns:i}},_markDataTables:function(t){for(var e=t.getElementsByTagName(\"table\"),i=0;i<e.length;i++){var r=e[i],l=r.getAttribute(\"role\");if(l==\"presentation\"){r._readabilityDataTable=!1;continue}var a=r.getAttribute(\"datatable\");if(a==\"0\"){r._readabilityDataTable=!1;continue}var s=r.getAttribute(\"summary\");if(s){r._readabilityDataTable=!0;continue}var h=r.getElementsByTagName(\"caption\")[0];if(h&&h.childNodes.length>0){r._readabilityDataTable=!0;continue}var c=[\"col\",\"colgroup\",\"tfoot\",\"thead\",\"th\"],n=function(m){return!!r.getElementsByTagName(m)[0]};if(c.some(n)){this.log(\"Data table because found data-y descendant\"),r._readabilityDataTable=!0;continue}if(r.getElementsByTagName(\"table\")[0]){r._readabilityDataTable=!1;continue}var u=this._getRowAndColumnCount(r);if(u.rows>=10||u.columns>4){r._readabilityDataTable=!0;continue}r._readabilityDataTable=u.rows*u.columns>10}},_fixLazyImages:function(t){this._forEachNode(this._getAllNodesWithTag(t,[\"img\",\"picture\",\"figure\"]),function(e){if(e.src&&this.REGEXPS.b64DataUrl.test(e.src)){var i=this.REGEXPS.b64DataUrl.exec(e.src);if(i[1]===\"image/svg+xml\")return;for(var r=!1,l=0;l<e.attributes.length;l++){var a=e.attributes[l];if(a.name!==\"src\"&&/\\\\.(jpg|jpeg|png|webp)/i.test(a.value)){r=!0;break}}if(r){var s=e.src.search(/base64\\\\s*/i)+7,h=e.src.length-s;h<133&&e.removeAttribute(\"src\")}}if(!((e.src||e.srcset&&e.srcset!=\"null\")&&e.className.toLowerCase().indexOf(\"lazy\")===-1)){for(var c=0;c<e.attributes.length;c++)if(a=e.attributes[c],!(a.name===\"src\"||a.name===\"srcset\"||a.name===\"alt\")){var n=null;if(/\\\\.(jpg|jpeg|png|webp)\\\\s+\\\\d/.test(a.value)?n=\"srcset\":/^\\\\s*\\\\S+\\\\.(jpg|jpeg|png|webp)\\\\S*\\\\s*$/.test(a.value)&&(n=\"src\"),n){if(e.tagName===\"IMG\"||e.tagName===\"PICTURE\")e.setAttribute(n,a.value);else if(e.tagName===\"FIGURE\"&&!this._getAllNodesWithTag(e,[\"img\",\"picture\"]).length){var u=this._doc.createElement(\"img\");u.setAttribute(n,a.value),e.appendChild(u)}}}}})},_getTextDensity:function(t,e){var i=this._getInnerText(t,!0).length;if(i===0)return 0;var r=0,l=this._getAllNodesWithTag(t,e);return this._forEachNode(l,a=>r+=this._getInnerText(a,!0).length),r/i},_cleanConditionally:function(t,e){this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY)&&this._removeNodes(this._getAllNodesWithTag(t,[e]),function(i){var r=function(g){return g._readabilityDataTable},l=e===\"ul\"||e===\"ol\";if(!l){var a=0,s=this._getAllNodesWithTag(i,[\"ul\",\"ol\"]);this._forEachNode(s,g=>a+=this._getInnerText(g).length),l=a/this._getInnerText(i).length>.9}if(e===\"table\"&&r(i)||this._hasAncestorTag(i,\"table\",-1,r)||this._hasAncestorTag(i,\"code\"))return!1;var h=this._getClassWeight(i);this.log(\"Cleaning Conditionally\",i);var c=0;if(h+c<0)return!0;if(this._getCharCount(i,\",\")<10){for(var n=i.getElementsByTagName(\"p\").length,u=i.getElementsByTagName(\"img\").length,m=i.getElementsByTagName(\"li\").length-100,b=i.getElementsByTagName(\"input\").length,N=this._getTextDensity(i,[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"]),v=0,y=this._getAllNodesWithTag(i,[\"object\",\"embed\",\"iframe\"]),E=0;E<y.length;E++){for(var d=0;d<y[E].attributes.length;d++)if(this._allowedVideoRegex.test(y[E].attributes[d].value))return!1;if(y[E].tagName===\"object\"&&this._allowedVideoRegex.test(y[E].innerHTML))return!1;v++}var p=this._getLinkDensity(i),x=this._getInnerText(i).length,o=u>1&&n/u<.5&&!this._hasAncestorTag(i,\"figure\")||!l&&m>n||b>Math.floor(n/3)||!l&&N<.9&&x<25&&(u===0||u>2)&&!this._hasAncestorTag(i,\"figure\")||!l&&h<25&&p>.2||h>=25&&p>.5||v===1&&x<75||v>1;if(l&&o){for(var L=0;L<i.children.length;L++)if(i.children[L].children.length>1)return o;let g=i.getElementsByTagName(\"li\").length;if(u==g)return!1}return o}return!1})},_cleanMatchedNodes:function(t,e){for(var i=this._getNextNode(t,!0),r=this._getNextNode(t);r&&r!=i;)e.call(this,r,r.className+\" \"+r.id)?r=this._removeAndGetNext(r):r=this._getNextNode(r)},_cleanHeaders:function(t){let e=this._getAllNodesWithTag(t,[\"h1\",\"h2\"]);this._removeNodes(e,function(i){let r=this._getClassWeight(i)<0;return r&&this.log(\"Removing header with low class weight:\",i),r})},_headerDuplicatesTitle:function(t){if(t.tagName!=\"H1\"&&t.tagName!=\"H2\")return!1;var e=this._getInnerText(t,!1);return this.log(\"Evaluating similarity of header:\",e,this._articleTitle),this._textSimilarity(this._articleTitle,e)>.75},_flagIsActive:function(t){return(this._flags&t)>0},_removeFlag:function(t){this._flags=this._flags&~t},_isProbablyVisible:function(t){return(!t.style||t.style.display!=\"none\")&&(!t.style||t.style.visibility!=\"hidden\")&&!t.hasAttribute(\"hidden\")&&(!t.hasAttribute(\"aria-hidden\")||t.getAttribute(\"aria-hidden\")!=\"true\"||t.className&&t.className.indexOf&&t.className.indexOf(\"fallback-image\")!==-1)},parse:function(){if(this._maxElemsToParse>0){var t=this._doc.getElementsByTagName(\"*\").length;if(t>this._maxElemsToParse)throw new Error(\"Aborting parsing document; \"+t+\" elements found\")}this._unwrapNoscriptImages(this._doc);var e=this._disableJSONLD?{}:this._getJSONLD(this._doc);this._removeScripts(this._doc),this._prepDocument();var i=this._getArticleMetadata(e);this._articleTitle=i.title;var r=this._grabArticle();if(!r)return null;if(this.log(\"Grabbed: \"+r.innerHTML),this._postProcessContent(r),!i.excerpt){var l=r.getElementsByTagName(\"p\");l.length>0&&(i.excerpt=l[0].textContent.trim())}var a=r.textContent;return{title:this._articleTitle,byline:i.byline||this._articleByline,dir:this._articleDir,lang:this._articleLang,content:this._serializer(r),textContent:a,length:a.length,excerpt:i.excerpt,siteName:i.siteName||this._articleSiteName,publishedTime:i.publishedTime}}};typeof module==\"object\"&&(module.exports=q);\\n';\n"],"names":["READABILITY_SCRIPT"],"mappings":";;;;AAuBO,MAAMA,qBACX"}
@@ -0,0 +1,14 @@
1
+ import Turndown, { TagName } from 'turndown';
2
+ export declare const DEFAULT_TAGS_TO_REMOVE: TagName[];
3
+ export interface ToMarkdownOptions extends Turndown.Options {
4
+ gfmExtension?: boolean;
5
+ removeTags?: TagName[];
6
+ }
7
+ /**
8
+ * Convert HTML content to Markdown format
9
+ * @param html HTML string
10
+ * @param options Conversion options
11
+ * @returns Markdown string
12
+ */
13
+ export declare function toMarkdown(html: string, options?: ToMarkdownOptions): string;
14
+ //# sourceMappingURL=to-markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-markdown.d.ts","sourceRoot":"","sources":["../../src/content/to-markdown.ts"],"names":[],"mappings":"AAKA,OAAO,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAG7C,eAAO,MAAM,sBAAsB,EAAE,OAAO,EAc3C,CAAC;AAEF,MAAM,WAAW,iBAAkB,SAAQ,QAAQ,CAAC,OAAO;IACzD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAgCR"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ "use strict";
6
+ var __webpack_require__ = {};
7
+ (()=>{
8
+ __webpack_require__.n = (module)=>{
9
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
10
+ __webpack_require__.d(getter, {
11
+ a: getter
12
+ });
13
+ return getter;
14
+ };
15
+ })();
16
+ (()=>{
17
+ __webpack_require__.d = (exports1, definition)=>{
18
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
19
+ enumerable: true,
20
+ get: definition[key]
21
+ });
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
+ })();
27
+ (()=>{
28
+ __webpack_require__.r = (exports1)=>{
29
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
+ value: 'Module'
31
+ });
32
+ Object.defineProperty(exports1, '__esModule', {
33
+ value: true
34
+ });
35
+ };
36
+ })();
37
+ var __webpack_exports__ = {};
38
+ __webpack_require__.r(__webpack_exports__);
39
+ __webpack_require__.d(__webpack_exports__, {
40
+ DEFAULT_TAGS_TO_REMOVE: ()=>DEFAULT_TAGS_TO_REMOVE,
41
+ toMarkdown: ()=>toMarkdown
42
+ });
43
+ const external_turndown_namespaceObject = require("turndown");
44
+ var external_turndown_default = /*#__PURE__*/ __webpack_require__.n(external_turndown_namespaceObject);
45
+ const external_turndown_plugin_gfm_namespaceObject = require("turndown-plugin-gfm");
46
+ const DEFAULT_TAGS_TO_REMOVE = [
47
+ "script",
48
+ 'style',
49
+ 'link',
50
+ 'head',
51
+ 'iframe',
52
+ 'video',
53
+ 'audio',
54
+ 'canvas',
55
+ 'object',
56
+ 'embed',
57
+ "noscript",
58
+ 'aside',
59
+ 'dialog'
60
+ ];
61
+ function toMarkdown(html, options = {}) {
62
+ if (!html) return '';
63
+ try {
64
+ const { codeBlockStyle = 'fenced', headingStyle = 'atx', emDelimiter = '*', strongDelimiter = '**', gfmExtension = true, removeTags = DEFAULT_TAGS_TO_REMOVE } = options;
65
+ const turndown = new (external_turndown_default())({
66
+ codeBlockStyle,
67
+ headingStyle,
68
+ emDelimiter,
69
+ strongDelimiter
70
+ });
71
+ turndown.remove(removeTags);
72
+ if (gfmExtension) turndown.use(external_turndown_plugin_gfm_namespaceObject.gfm);
73
+ return turndown.turndown(html);
74
+ } catch (error) {
75
+ console.error('HTML to Markdown conversion failed:', error);
76
+ return html;
77
+ }
78
+ }
79
+ exports.DEFAULT_TAGS_TO_REMOVE = __webpack_exports__.DEFAULT_TAGS_TO_REMOVE;
80
+ exports.toMarkdown = __webpack_exports__.toMarkdown;
81
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
82
+ "DEFAULT_TAGS_TO_REMOVE",
83
+ "toMarkdown"
84
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
85
+ Object.defineProperty(exports, '__esModule', {
86
+ value: true
87
+ });
88
+
89
+ //# sourceMappingURL=to-markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content/to-markdown.js","sources":["webpack://@agent-infra/browser-context/webpack/runtime/compat_get_default_export","webpack://@agent-infra/browser-context/webpack/runtime/define_property_getters","webpack://@agent-infra/browser-context/webpack/runtime/has_own_property","webpack://@agent-infra/browser-context/webpack/runtime/make_namespace_object","webpack://@agent-infra/browser-context/./src/content/to-markdown.ts"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","\n/*\n * Copyright (c) 2025 Bytedance, Inc. and its affiliates.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport Turndown, { TagName } from 'turndown';\nimport { gfm } from 'turndown-plugin-gfm';\n\nexport const DEFAULT_TAGS_TO_REMOVE: TagName[] = [\n 'script',\n 'style',\n 'link',\n 'head',\n 'iframe',\n 'video',\n 'audio',\n 'canvas',\n 'object',\n 'embed',\n 'noscript',\n 'aside',\n 'dialog',\n];\n\nexport interface ToMarkdownOptions extends Turndown.Options {\n gfmExtension?: boolean;\n removeTags?: TagName[];\n}\n\n/**\n * Convert HTML content to Markdown format\n * @param html HTML string\n * @param options Conversion options\n * @returns Markdown string\n */\nexport function toMarkdown(\n html: string,\n options: ToMarkdownOptions = {},\n): string {\n if (!html) return '';\n\n try {\n const {\n codeBlockStyle = 'fenced',\n headingStyle = 'atx',\n emDelimiter = '*',\n strongDelimiter = '**',\n gfmExtension = true,\n removeTags = DEFAULT_TAGS_TO_REMOVE,\n } = options;\n\n const turndown = new Turndown({\n codeBlockStyle,\n headingStyle,\n emDelimiter,\n strongDelimiter,\n });\n\n // issue: https://github.com/mixmark-io/turndown/issues/210#issuecomment-353666857\n turndown.remove(removeTags);\n\n if (gfmExtension) {\n turndown.use(gfm);\n }\n\n return turndown.turndown(html);\n } catch (error) {\n console.error('HTML to Markdown conversion failed:', error);\n return html;\n }\n}\n"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol","DEFAULT_TAGS_TO_REMOVE","toMarkdown","html","options","codeBlockStyle","headingStyle","emDelimiter","strongDelimiter","gfmExtension","removeTags","turndown","Turndown","gfm","error","console"],"mappings":";;;;;;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACM,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFP,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOQ,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;ACEO,MAAMI,yBAAoC;IAC/C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAaM,SAASC,WACdC,IAAY,EACZC,UAA6B,CAAC,CAAC;IAE/B,IAAI,CAACD,MAAM,OAAO;IAElB,IAAI;QACF,MAAM,EACJE,iBAAiB,QAAQ,EACzBC,eAAe,KAAK,EACpBC,cAAc,GAAG,EACjBC,kBAAkB,IAAI,EACtBC,eAAe,IAAI,EACnBC,aAAaT,sBAAsB,EACpC,GAAGG;QAEJ,MAAMO,WAAW,IAAIC,CAAAA,2BAAAA,EAAS;YAC5BP;YACAC;YACAC;YACAC;QACF;QAGAG,SAAS,MAAM,CAACD;QAEhB,IAAID,cACFE,SAAS,GAAG,CAACE,6CAAAA,GAAGA;QAGlB,OAAOF,SAAS,QAAQ,CAACR;IAC3B,EAAE,OAAOW,OAAO;QACdC,QAAQ,KAAK,CAAC,uCAAuCD;QACrD,OAAOX;IACT;AACF"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import turndown_0 from "turndown";
6
+ import { gfm } from "turndown-plugin-gfm";
7
+ const DEFAULT_TAGS_TO_REMOVE = [
8
+ "script",
9
+ 'style',
10
+ 'link',
11
+ 'head',
12
+ 'iframe',
13
+ 'video',
14
+ 'audio',
15
+ 'canvas',
16
+ 'object',
17
+ 'embed',
18
+ "noscript",
19
+ 'aside',
20
+ 'dialog'
21
+ ];
22
+ function toMarkdown(html, options = {}) {
23
+ if (!html) return '';
24
+ try {
25
+ const { codeBlockStyle = 'fenced', headingStyle = 'atx', emDelimiter = '*', strongDelimiter = '**', gfmExtension = true, removeTags = DEFAULT_TAGS_TO_REMOVE } = options;
26
+ const turndown = new turndown_0({
27
+ codeBlockStyle,
28
+ headingStyle,
29
+ emDelimiter,
30
+ strongDelimiter
31
+ });
32
+ turndown.remove(removeTags);
33
+ if (gfmExtension) turndown.use(gfm);
34
+ return turndown.turndown(html);
35
+ } catch (error) {
36
+ console.error('HTML to Markdown conversion failed:', error);
37
+ return html;
38
+ }
39
+ }
40
+ export { DEFAULT_TAGS_TO_REMOVE, toMarkdown };
41
+
42
+ //# sourceMappingURL=to-markdown.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content/to-markdown.mjs","sources":["webpack://@agent-infra/browser-context/./src/content/to-markdown.ts"],"sourcesContent":["\n/*\n * Copyright (c) 2025 Bytedance, Inc. and its affiliates.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport Turndown, { TagName } from 'turndown';\nimport { gfm } from 'turndown-plugin-gfm';\n\nexport const DEFAULT_TAGS_TO_REMOVE: TagName[] = [\n 'script',\n 'style',\n 'link',\n 'head',\n 'iframe',\n 'video',\n 'audio',\n 'canvas',\n 'object',\n 'embed',\n 'noscript',\n 'aside',\n 'dialog',\n];\n\nexport interface ToMarkdownOptions extends Turndown.Options {\n gfmExtension?: boolean;\n removeTags?: TagName[];\n}\n\n/**\n * Convert HTML content to Markdown format\n * @param html HTML string\n * @param options Conversion options\n * @returns Markdown string\n */\nexport function toMarkdown(\n html: string,\n options: ToMarkdownOptions = {},\n): string {\n if (!html) return '';\n\n try {\n const {\n codeBlockStyle = 'fenced',\n headingStyle = 'atx',\n emDelimiter = '*',\n strongDelimiter = '**',\n gfmExtension = true,\n removeTags = DEFAULT_TAGS_TO_REMOVE,\n } = options;\n\n const turndown = new Turndown({\n codeBlockStyle,\n headingStyle,\n emDelimiter,\n strongDelimiter,\n });\n\n // issue: https://github.com/mixmark-io/turndown/issues/210#issuecomment-353666857\n turndown.remove(removeTags);\n\n if (gfmExtension) {\n turndown.use(gfm);\n }\n\n return turndown.turndown(html);\n } catch (error) {\n console.error('HTML to Markdown conversion failed:', error);\n return html;\n }\n}\n"],"names":["DEFAULT_TAGS_TO_REMOVE","toMarkdown","html","options","codeBlockStyle","headingStyle","emDelimiter","strongDelimiter","gfmExtension","removeTags","turndown","Turndown","gfm","error","console"],"mappings":";;;;;;AAQO,MAAMA,yBAAoC;IAC/C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAaM,SAASC,WACdC,IAAY,EACZC,UAA6B,CAAC,CAAC;IAE/B,IAAI,CAACD,MAAM,OAAO;IAElB,IAAI;QACF,MAAM,EACJE,iBAAiB,QAAQ,EACzBC,eAAe,KAAK,EACpBC,cAAc,GAAG,EACjBC,kBAAkB,IAAI,EACtBC,eAAe,IAAI,EACnBC,aAAaT,sBAAsB,EACpC,GAAGG;QAEJ,MAAMO,WAAW,IAAIC,WAAS;YAC5BP;YACAC;YACAC;YACAC;QACF;QAGAG,SAAS,MAAM,CAACD;QAEhB,IAAID,cACFE,SAAS,GAAG,CAACE;QAGf,OAAOF,SAAS,QAAQ,CAACR;IAC3B,EAAE,OAAOW,OAAO;QACdC,QAAQ,KAAK,CAAC,uCAAuCD;QACrD,OAAOX;IACT;AACF"}
@@ -0,0 +1,2 @@
1
+ export * from './content/index.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,oBAAoB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ "use strict";
6
+ var __webpack_modules__ = {
7
+ "./content/index.js": function(module) {
8
+ module.exports = require("./content/index.js");
9
+ }
10
+ };
11
+ var __webpack_module_cache__ = {};
12
+ function __webpack_require__(moduleId) {
13
+ var cachedModule = __webpack_module_cache__[moduleId];
14
+ if (void 0 !== cachedModule) return cachedModule.exports;
15
+ var module = __webpack_module_cache__[moduleId] = {
16
+ exports: {}
17
+ };
18
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
19
+ return module.exports;
20
+ }
21
+ (()=>{
22
+ __webpack_require__.n = (module)=>{
23
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
24
+ __webpack_require__.d(getter, {
25
+ a: getter
26
+ });
27
+ return getter;
28
+ };
29
+ })();
30
+ (()=>{
31
+ __webpack_require__.d = (exports1, definition)=>{
32
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
33
+ enumerable: true,
34
+ get: definition[key]
35
+ });
36
+ };
37
+ })();
38
+ (()=>{
39
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
40
+ })();
41
+ (()=>{
42
+ __webpack_require__.r = (exports1)=>{
43
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
44
+ value: 'Module'
45
+ });
46
+ Object.defineProperty(exports1, '__esModule', {
47
+ value: true
48
+ });
49
+ };
50
+ })();
51
+ var __webpack_exports__ = {};
52
+ (()=>{
53
+ __webpack_require__.r(__webpack_exports__);
54
+ var _content_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./content/index.js");
55
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
56
+ for(var __WEBPACK_IMPORT_KEY__ in _content_index_js__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
57
+ return _content_index_js__WEBPACK_IMPORTED_MODULE_0__[key];
58
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
59
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
60
+ })();
61
+ for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
62
+ Object.defineProperty(exports, '__esModule', {
63
+ value: true
64
+ });
65
+
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["webpack://@agent-infra/browser-context/webpack/runtime/compat_get_default_export","webpack://@agent-infra/browser-context/webpack/runtime/define_property_getters","webpack://@agent-infra/browser-context/webpack/runtime/has_own_property","webpack://@agent-infra/browser-context/webpack/runtime/make_namespace_object"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol"],"mappings":";;;;;;;;;;;;;;;;;;;;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACM,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFP,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOQ,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D"}
package/dist/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ export * from "./content/index.mjs";
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@agent-infra/browser-context",
3
+ "description": "get browser context for AI Agent",
4
+ "version": "0.1.1",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "scripts": {
22
+ "dev": "rslib build --watch",
23
+ "build": "rslib build",
24
+ "prepare": "npm run build",
25
+ "prepublishOnly": "pnpm run build",
26
+ "test": "vitest run",
27
+ "test:watch": "vitest",
28
+ "test:e2e": "vitest --config vitest.e2e.config.ts",
29
+ "coverage": "vitest run --coverage",
30
+ "test:e2e:local": "vitest --config vitest.e2e.config.ts local-browser.e2e.test.ts"
31
+ },
32
+ "dependencies": {
33
+ "puppeteer-core": "24.14.0",
34
+ "turndown": "^7.2.0",
35
+ "turndown-plugin-gfm": "^1.0.2"
36
+ },
37
+ "devDependencies": {
38
+ "@types/turndown": "^5.0.5",
39
+ "@types/which": "3.0.4",
40
+ "@types/node": "24.1.0",
41
+ "typescript": "5.8.3",
42
+ "vitest": "3.2.4",
43
+ "@vitest/coverage-v8": "3.2.4",
44
+ "@rslib/core": "0.11.0"
45
+ }
46
+ }