gramilon
Full Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору !function(e) { function t(e) { var t = $[e]; return t || (t = $.Others), t } function n(e) { return e.replace(/^\s+/, "").replace(/\s+$/, "").replace(/\s+/g, " ") } function i(e, t) { e.classList.remove(t) } function o(e, t) { e.classList.add(t) } function a(e, t) { e.className = n(t) } function r(e) { return e.rect || (e.rect = e.getBoundingClientRect(), e.rect.offsetLeft = e.rect.left + e.ownerDocument.body.scrollLeft, e.rect.offsetTop = e.rect.top + e.ownerDocument.body.scrollTop), e.rect } function l(e) { return e.cs || (e.cs = getComputedStyle(e)), e.cs } function s(e) { var t = l(e).fontSize; return t ? parseInt(t, 10) : 0 } function c(e) { return e.replace(/\s+/g, "") } function h(e, t) { var n = l(e); if ("none" == n.display || "hidden" == n.visibility) return !1; var i = r(e); if (i.width <= 0 || i.height <= 0) return !1; if (t && 0 == document.body.scrollTop) { var o = e.getBoundingClientRect(); if (o.top + o.height / 2 < window.innerHeight) { var a = document.elementFromPoint(o.left + o.width / 2, o.top + o.height / 2); if (a) { for (; a != e && (a = a.parentElement); ) ; if (a != e) return !1 } } } return !0 } function d(e, t) { if (!e || !t) return !1; var n = /^https?:\/\/(?:[\w\-]+\.)*([\w\-]+\.[\w\-]+)/; return host1 = n.exec(e), host2 = n.exec(t), host1 && host2 ? host1[1] == host2[1] : !!/^(?:data):/.test(t) } function u(e) { return !(e < 4352) && (e >= 4352 || e <= 4607 || (e >= 19968 || e <= 40959 || (e >= 11904 || e <= 19903 || (e >= 44032 || e <= 55215 || (e >= 63744 || e <= 64255 || (e >= 65072 || e <= 65103)))))) } function g(e) { return parseInt(e.match(/(\d+)?$/), 10) } function m() { var e = new XMLHttpRequest; e.onreadystatechange = function() { 4 == e.readyState && (200 == e.status ? (H = e.responseText, R = !0) : console.log("fetch html error")) } ; try { e.open("get", "mx://read-mode/read.html"), e.send(null) } catch (e) {} } function f(e) { var t = window.location.host; if ("chuangshi.qq.com" == t || "yuedu.163.com" == t || "www.sxyj.net" == t) { if ("complete" == document.readyState) return !1; var n = 0 , i = function() { n += 1, window.removeEventListener("load", i, !1), F && F.showFlag || (O.getCandidate() ? e() : n < 3 && setTimeout(i, 200)) }; return window.addEventListener("load", i, !1), !0 } return !1 } function p() { var e = document.createElement("div"); e.style.overflowY = "scroll", e.style.width = "100px", document.body.appendChild(e); var t = 100 - e.clientWidth; return document.body.removeChild(e), t } function y() { for (var e, t, n, i = arguments.length, o = 0, a = 0, r = {}; o < i; o++) for (t = e = arguments[o]; t && 9 != t.nodeType; ) (n = t.getAttribute("data-find")) || (n = "_" + ++a, t.setAttribute("data-find", n)), r[n] ? r[n].count++ : r[n] = { node: t, count: 1 }, t = (e = t).parentElement || e.parentNode; for (o in r) if (r[o].count == i) return r[o].node } function v(e) { var t = ""; e.id ? t = "#" + e.id : e.className && (t = "." + e.classList[0]); for (var n = 2, i = e, o = "", a = e.parentNode; n && a && "BODY" != a.nodeName; a = a.parentNode) { a.id ? (o = "#" + a.id, n--) : a.className ? (o = "." + a.classList[0], n--) : o = ""; for (var r = 0, l = a.childElementCount; r < l; r++) if (a.children[r] == i) { o += ">:nth-child(" + (r + 1) + ")"; break } i = a, t = o + t } return n && (t = "BODY>" + t), t } function b(e, t) { this.element = e, this.contentDocument = t, this.directionIsNormal = !0, this.condition1 = 0, this.getContentScore = function() { for (var e = 0, t = this.textList, n = 0; n < t.length; n++) e += this.calcTextScore(t[n]); return console.log("getContentScore:", e), e } , this.calcTextScore = function(e) { if (!e) return 0; var t = e.length; if (t < 1) return 0; for (var n = 1, i = e.parentNode; i && i != this.element; ) n -= .1, i = i.parentNode; return Math.pow(t * n, 1.25) } , this.getClassWeight = function() { for (var e = /article|entry|post|body|column|main|content/i, t = /comment|combx|disqus|foot|header|list|item|menu|rss|shoutbox|sidebar|sponsor/i, n = 1, i = this.element; i; i = i.parentElement) { var o = i.className + i.id; o && (e.test(o) && (n += .4), t.test(o) && (n -= .8)) } return console.log("classWeight:" + n), n } , this.getEncodingType = function() { if (0 == this.encodingType) { if (this.textList && this.textList.length > 0) for (var e = Math.min(this.textList.length, 3), t = 0; t < e; t++) for (var n = this.textList[t].nodeValue.trim(), i = Math.min(n.length, 10), o = 0; o < i; o++) if (u(n.charCodeAt(o))) return void (this.encodingType = 3); this.encodingType = 1 } } , this.score = function() { return this.contentScore * this.classWeight } , this.getTextList = function(e) { var t = [] , n = e; n.firstElementChild && "FOUNDER-CONTENT" === n.firstElementChild.tagName && (n = e.firstElementChild); for (var i = { A: 1, DT: 1, OL: 1, OPTION: 1, SCRIPT: 1, NOSCRIPT: 1, STYLE: 1, UL: 1, IFRAME: 1, TEXTAREA: 1 }, o = this.contentDocument.evaluate("text()|*/text()|*/li/text()|*/strong/text()|*/span/text()|*/span/*/text()|*/font/text()|*/font/*/text()|blockquote/text()|blockquote/*/text()|*/blockquote/text()|*/blockquote/*/text()|*/div/p/text()|*/div/p/index/text()|*/p/text()", n, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null), a = 0; a < o.snapshotLength; a++) { var r = o.snapshotItem(a); !i[r.parentNode.tagName] && /\S/.test(r.nodeValue) && t.push(r) } return t } , this.condition0 = function() { return this.getEncodingType(), this.score() * this.encodingType < 100 } , this.condition1 = function() { for (var e = r(this.element), t = e.width * e.height, n = 0, i = this.element.querySelectorAll("iframe"), o = 0; o < i.length; o++) n += i[o].clientWidth * i[o].clientHeight; for (var a = this.element.querySelectorAll("object"), o = 0; o < a.length; o++) { var c = a[o]; n += c.clientWidth * c.clientHeight } for (var h = .3 * t, d = .2 * e.width, u = this.element.querySelectorAll("img"), o = 0; o < u.length; o++) if ((v = r(u[o])).width >= d && v.height > 50) { var g = v.width; if (v.width < e.width) { var m = u[o].getBoundingClientRect(); document.elementFromPoint(m.left + v.width + (e.width - v.width) / 2, m.top + v.height / 2) || (g = e.width) } var f = g * v.height; f < h && (n += f) } var p = this.contentDocument.evaluate("*[name()!='img' and name()!='object']", this.element, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); if (p.snapshotLength > 2) for (o = 0; o < p.snapshotLength; o++) { var y = p.snapshotItem(o); if (/comment/i.test(y.id + " " + y.className) || !/\S/.test(y.innerText) && 0 == y.getElementsByTagName("img").length) if ("BR" == y.tagName) (b = parseInt(l(this.element).lineHeight, 10) * parseInt(l(this.element).width, 10)) > 0 && (n += b); else { var v = r(y) , b = v.width * v.height; b > 0 && (n += b) } } for (var x = 16, C = fontSizeCount = 0, o = 0; o < this.textList.length; o++) (pNode = this.textList[o].parentNode) && (C += s(pNode), fontSizeCount++); fontSizeCount && (x = C / fontSizeCount); var T = this.score() , N = t - n; return this.getEncodingType(), this.condition1 = T / N * 1e3 * (x / 16) * this.encodingType, console.log("candition1: ", this.condition1, " score:", T, " contentArea:", t, " textsArea:", N, " averageFontsize:", x, " encodingType:", this.encodingType), this.condition1 < 5 } , this.condition2 = function() { for (var e = this.element.querySelectorAll("hr"), t = 0, n = r(this.element), i = .7 * n.width, o = 0; o < e.length; o++) e[o].clientWidth > i && t++; return !!(t && n.height / t < 180) } , this.condition3 = function() { var e = this.contentDocument.evaluate("(h1|h2|h3|h4|h5|h6|*/h1|*/h2|*/h3|*/h4|*/h5|*/h6)[a]", this.element, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); if (e.snapshotLength > 2) { for (var t = 0, n = r(this.element), i = .05 * n.height, o = 0; o < e.snapshotLength; o++) { var a = r(e.snapshotItem(o)); a.top - n.top > i && n.bottom - a.bottom > i && t++ } if (n.height / t < 300) return !0 } return !1 } , this.specialCondition = function() { location.href; return !("www.cnbeta.com" != location.host || !/cnbeta.com\/articles\//i.test(location.href) || this.element != document.querySelector("article.article")) || (!("www.dichtbij.nl" != location.host || !/\/artikel\//i.test(location.href) || this.element != document.querySelector('div[id$="ArticleDetail"] > div.widgetcontent')) || "mp.weixin.qq.com" == location.host && this.element == document.querySelector("#page-content .rich_media_content ")) } , this.textList = this.getTextList(e), this.contentScore = this.getContentScore(), this.classWeight = this.getClassWeight(), this.encodingType = 0 } function x(e) { this.contentDocument = e, this.candidate = null, this.articleTitle = null, this.articleTitleText = null, this.content = null, this.pageNumber = 1, this.nextPageUrl = null, this.getCandidate = function() { if (null != this.candidate) return this.candidate; var e = this.getCandidateList(); if (e.sort(function(e, t) { return t.score() - e.score() }), !e || !e.length) return null; for (var t = [], n = 0; n < e.length; n++) { var i = e[n]; if (console.log("candidate tag: " + i.element.tagName + " score:" + i.score() + " className/id: " + i.element.className + "/" + i.element.id), i.specialCondition()) { t = [i]; break } i.condition0() || (i.condition1() || i.condition2() || i.condition3() || t.push(i)) } if (console.log("results length:" + t.length), t.length) { if (this.candidate = t[0], t.length > 1) { var o = t[1]; Math.abs(r(this.candidate.element).width - r(o.element).width) < 50 && this.candidate.condition1 / o.condition1 < 1.5 && this.candidate.element !== o.element.parentElement && (console.log("findSameParent " + y(this.candidate.element, o.element).className), this.candidate.element = y(this.candidate.element, o.element)) } console.log("candidate element:" + this.candidate.element.tagName + " className/id: " + this.candidate.element.className + "/" + this.candidate.element.id); var a = l(this.candidate.element); this.candidate.directionIsNormal = !a || "ltr" === a.direction } return this.candidate } , this.getCandidateElement = function() { return (candidate = this.getCandidate()) ? candidate.element : null } , this.getContent = function() { if (null != this.content) return this.content; var e = this.getCandidateElement(); return e ? (this.content = e.cloneNode(!0), this.content = this.grabContent(e, this.content), this.content) : this.content = null } , this.getCandidateList = function() { for (var e = Date.now() + 1e3, t = this.contentDocument.body.getElementsByTagName("*"), n = { BODY: 1, DIV: 1, TD: 1, P: 1, PRE: 1, DD: 1, SPAN: 1, STRONG: 1, ARTICLE: 1 }, i = [], o = 0; o < t.length; o++) { var a = t[o]; if (n[a.tagName]) { var r = this.createCandidateByTag(a, this.contentDocument); if (r && i.push(r), Date.now() > e) { i = []; break } } } return console.info("getCandidateList " + i.length), i } , this.createCandidateByTag = function(e, t) { if (!h(e, !1)) return null; if (r(e).width < 450 || r(e).height < 100) return null; for (var n = /combx|comment|community|disqus|extra|foot|menu|reply|talkback|remark|rss|shoutbox|sponsor|ad-break|agegate|pagination|pager|popup|tweet|twitter/i, i = e; "BODY" !== i.tagName; i = i.parentNode) { var o = i.className + i.id; if (n.test(o)) return console.info("unlikely candidate - " + o), null } return console.info("-------createCandidate() tag: " + e.tagName + " className/id: " + e.className + "/" + e.id), new b(e,t) } , this.getArticleTitle = function() { if (null != this.articleTitleText) return this.articleTitleText; var e = /header|title|headline/i , t = this.getCandidateElement() , n = r(t) , i = n.offsetLeft + n.width / 2 , o = n.offsetTop , a = this.contentDocument.elementFromPoint(i, o - 150); if (a && "IMG" === a.tagName) { var c = r(a); c.height >= 300 && c.width >= .5 * n.width && (o = c.offsetTop) } for (var h = this.contentDocument.title.toLowerCase(), d = l(t), u = this.contentDocument.querySelectorAll("h1, h2, h3, h4, h5, .headline, .article_title, #hn-headline, .h1title"), g = null, m = 0; m < u.length; m++) { var f = u[m] , p = f.innerText; if (!(p.length < 4)) { var y = r(f) , v = y.offsetLeft + y.width / 2 , b = v - i , x = y.offsetTop - o , C = Math.sqrt(b * b + x * x) , T = Math.max(500 - C, 0); if (!(C > 500 || y.width < .5 * n.width || v < n.left || v > n.right)) { var N = s(f); if (N < 12) continue; if (T *= N / 16, N > 1.4 * parseInt(d.fontSize, 10) && (T *= 1.25), e.test(f.className + f.id) && (T *= 1.5), h.length > 0) { var w = p.toLowerCase() , E = 0; if (0 == h.length) E = w.length; else if (0 == w.length) E = h.length; else try { for (var S = h.replace(/([\-\^\]\\])/g, "\\$1"), L = w.replace(/([\-\^\]\\])/g, "\\$1"), P = new RegExp("(?=.*?)[^" + S + "](?=.*?)|(?=.*?)[^" + L + "](?=.*?)","g"), I = null; null != (I = P.exec(h + w)); ) E += I.length } catch (e) { console.info("Invalid regular expression!") } var M = 1 - E / h.length; T += M *= .2 * T } /下一页|下一章|下一篇|下一节|下页/i.test(p) && (T *= .5), (!g || T > g.score) && ((g = f).score = T, g.text = p) } } } return g && (this.articleTitleText = g.text, this.articleTitle = g), this.articleTitleText || (this.articleTitleText = this.contentDocument.title, this.articleTitle = null), this.articleTitleText } , this.grabContent = function(e, t) { function n(e) { f && (f += e), p && (p += e), y && (y += e), v && (v += e) } var i = /class|style|align/i , o = { FORM: 1, IFRAME: 1, SCRIPT: 1, STYLE: 1, LINK: 1, INPUT: 1, SELECT: 1 } , a = { DIV: 1, TABLE: 1, OBJECT: 1, UL: 1 } , s = { I: 1, EM: 1 } , c = { B: 1, STRONG: 1, H1: 1, H2: 1, H3: 1, H4: 1, H5: 1, H6: 1 } , h = { unlikelyCandidatesRe: /combx|modal|lightbox|comment|disqus|foot|header|menu|meta|nav|rss|shoutbox|sidebar|sponsor|social|teaserlist|time|tweet|twitter/i, okMaybeItsACandidateRe: /and|article|body|column|main|story|entry|^post/im } , d = this.contentDocument.location.host , u = [] , g = e , m = t , f = 0 , p = 0 , y = 0 , v = 0; for (this.getArticleTitle(); g && m; ) { var b = null , x = null , C = m.tagName; if (m.primalNode = g, C in o ? b = m : g === this.articleTitle && (b = m), b || (x = l(g), "PARAM" !== C && "none" === x.display && (b = m)), !b && 1 === m.childElementCount) { var T; for (T = m.firstElementChild; 1 === T.childElementCount; T = T.firstElementChild) ; "BR" !== T.tagName || /\S/.test(m.innerText) ? "SCRIPT" === T.tagName && (b = m) : b = m } if (!b) { var N = m.className + "\n" + m.id; -1 !== N.search(h.unlikelyCandidatesRe) && -1 == N.search(h.okMaybeItsACandidateRe) && "HTML" !== C && "BODY" !== C && (b = m), b || "wikipedia.org" != d.substr(d.length - 13, 13) || "editsection" != m.className || (b = m) } if (!b) { if ("DIV" === C && m.parentNode) { var w = g.querySelectorAll("a, blockquote, dl, div, img, ol, p, pre, table, ul"); f || "none" !== x.float || w.length || ((q = this.contentDocument.createElement("p")).innerHTML = m.innerHTML, m.parentNode.replaceChild(q, m), (m = q).primalNode = g, C = m.tagName) } m.parentNode && C in a && u.push(m), g !== e && !f && "IMG" !== C && "none" !== x.float && (r(g).height >= 40 || g.childElementCount > 1) && (f = 1); for (var E = m.attributes, S = 0; S < E.length; S++) { var L = E[S].nodeName; (i.test(L) || "align" == L && /justify/i.test(E[S].nodeValue)) && (m.removeAttribute(L), S--) } if (y || "normal" === x.fontStyle || (C in s || (m.style.fontStyle = x.fontStyle), y = 1), v || "normal" === x.fontWeight || (C in c || (m.style.fontWeight = x.fontWeight), v = 1), f) { if (1 === f && r(g).width === r(e).width ? m.setAttribute("class", "float full-width") : (m.setAttribute("class", "float " + x.float), m.style.clear = x.clear), D = g.style.getPropertyValue("width")) m.style.width = D; else if (I = window.getMatchedCSSRules(g, "", !0)) for (j = I.length - 1; j >= 0; j--) if (D = I[j].style.getPropertyValue("width")) { m.style.width = D; break } var P = r(g); 1 === f && !D && P < 2e3 && (m.style.width = P.width + "px", m.style.height = P.height + "px") } if ("TABLE" === C) p || (p = 1); else if ("IMG" === C) { if (m.removeAttribute("border"), m.removeAttribute("hspace"), m.removeAttribute("vspace"), m.removeAttribute("align"), f) m.style.float = x.float, m.style.clear = x.clear; else { var M = r(g); M.width < 128 && M.height < 128 && m.setAttribute("class", "tinyImage"), "none" !== x.float && (m.setAttribute("class", "float " + x.float), m.style.float = x.float, m.style.clear = x.clear) } var A = m.getAttribute("original"); A ? m.setAttribute("src", A) : m.currentSrc ? m.setAttribute("src", m.currentSrc) : m.setAttribute("src", m.src), m.primalNode.node = m, m.primalNode.addEventListener("load", this.imgLoadDone, !1), "www.mafengwo.cn" != window.location.host && "mp.weixin.qq.com" != window.location.host || (m.src = m.getAttribute("data-src")) } else if ("FONT" === C) m.removeAttribute("size"), m.removeAttribute("face"), m.removeAttribute("color"), /\b(4yt.net|jjwxc.net)\b/.test(d) && (m.style.display = "none"); else if ("A" === C && m.parentNode) { var B = m.getAttribute("href"); if (B && B.length && ("#" === B || "##" === B.substr(0, 2) || "javascript:" === B.substring(0, 11))) { if (p || m.childElementCount || 1 !== m.parentElement.childElementCount || this.contentDocument.childNodes.length - this.contentDocument.children.length || (b = m), !b) { var q = this.contentDocument.createElement("span"); if (1 === m.childElementCount && "IMG" === m.firstElementChild.tagName) { var F = m.firstElementChild; F.width > 32 && F.height > 32 && q.setAttribute("class", "image-anchor") } q.className || q.setAttribute("class", "text-anchor"), q.innerHTML = m.innerHTML, m.parentNode.replaceChild(q, m), m = q } } else B && "#" === B[0] || m.href && (m.setAttribute("href", m.href), m.setAttribute("target", "_new")) } else "SPAN" === C && ("html.hjsm.tom.com" == d && (m.style.display = "none"), "block" === x.display && (m.style.display = "block")) } if (j = b ? null : g.firstElementChild) g = j, m = m.firstElementChild, n(1); else { for (var H; g !== e && !(H = g.nextElementSibling); ) g = g.parentElement, m = m.parentElement, n(-1); if (g === e) { b && b.parentElement && b.parentElement.removeChild(b); break } g = H, m = m.nextElementSibling, 1 === f && (f = 0), 1 === p && (p = 0), 1 === y && (y = 0), 1 === v && (v = 0) } if (b && b.parentElement) do { j = b.parentElement, j.removeChild(b), b = j } while (j != g.parentElement && 0 == j.childElementCount && !/\S/.test(j.innerText)) } for (var O = u.length - 1; O >= 0; O--) { var _ = u[O]; if (_.parentNode && this.shouldDelete(_, _.primalNode, e)) { var R = _; R.parentElement.removeChild(R) } } for (var U = t.querySelectorAll(".float"), z = 0; z < U.length; z++) { var W = U[z] , $ = W.querySelectorAll("a, span.image-anchor") , V = W.querySelectorAll("span.text-anchor"); ($ = W.parentNode && V.length > $.length) || (V = W.querySelectorAll("embed, object").length, k = W.primalNode.querySelectorAll("embed, object").length, !V && k && ($ = !0)), $ && W.parentNode.removeChild(W) } return t } , this.imgLoadDone = function(e) { var t = e.target; t.primalNode && t.primalNode.src != t.src && (t.primalNode.src = t.src) } , this.shouldDelete = function(e, t, n) { var i = /article|body|content|entry|page|pagination|post|text/i , o = /comment|combx|disqus|contact|foot|link|masthead|media|meta|promo|related|scroll|shoutbox|sponsor|tags|widget|share|pagination/i; if (!e.parentElement) return !1; if ("OBJECT" !== e.tagName && "EMBED" !== e.tagName) { for (var a = !1, l = 0, u = e.childNodes.length; l < u; l++) { var g = (w = e.childNodes[l]).nodeType; if (g === Node.ELEMENT_NODE || g === Node.TEXT_NODE && /\S/.test(w.nodeValue)) { a = !0; break } } if (!a) return !0 } var m = 0; if (t && (i.test(t.className) && m++, i.test(t.id) && m++, o.test(t.className) && m--, o.test(t.id) && m--), m < 0) return !0; if ("UL" === e.tagName) return !(!t.querySelector("iframe") || !t.querySelector("script")); if ("OBJECT" === e.tagName) { var f = /youtube|vimeo|dailymotion|livestream\.com|viddler\.com/ , p = e.querySelector("embed[src]") , y = p ? p.src : ""; if (f.test(y)) return !1; var v = e.getAttribute("data"); if (f.test(v)) return !1; var b = this.contentDocument.location.href; return !d(b, y) && !d(b, v) } if (1 === t.childElementCount && "A" === (w = t.firstElementChild).tagName && 0 == w.getElementsByTagName("img").length && s(w) / s(n) < .75) return !0; if (1 === e.childElementCount && "A" === (w = e.firstElementChild).tagName) return !1; var x = e.querySelectorAll("img") , C = x.length , T = 0; if (C) { for (var N = 0, l = 0; l < C; l++) { var w = x[l].primalNode; if (h(w, !1)) { var E = r(w); N += E.width / C * (E.height / C); var S = E.width * E.height; (!d(this.contentDocument.location.href, w.src) || S < 16384) && T++ } } if (N > 4e4) return !1 } if (!this.isLittleParagraph(e, 10)) return !1; var L = e.querySelectorAll("p").length , P = e.querySelectorAll("br").length; if (L += Math.floor(P / 2), T > L) return !0; var I = e.querySelectorAll("a[href]").length , M = this.anchorTextRatio(e); return !(I > 1 && e.querySelectorAll('a[href^="#"]').length == I && L / I < .2 && M > .9) && (t.querySelectorAll("li a[href]").length > L || (e.querySelectorAll("input").length / L > .33 || (e.textContent.trim().length < 25 && (0 == C || C > 1 && T > 0) || (!!e.querySelector("embed") || (m >= 1 && M > .5 || (m < 1 && M > .2 || "TABLE" === e.tagName && c(e.innerText).length <= .5 * c(t.innerText).length)))))) } , this.isLittleParagraph = function(e, t) { for (var n = 0, i = e.textContent, o = -1; n < t && (o = i.indexOf(",", o + 1)) >= 0; ) n++; return n < t } , this.anchorTextRatio = function(e) { var t = c(e.textContent).length; if (!t) return 0; for (var n = e.querySelectorAll("a"), i = 0, o = 0; o < n.length; o++) { var a = n[o]; a.href && (i += c(a.textContent).length) } return i / t } , this.findNextPageUrl = function() { if (!this.candidate) return null; if (this.nextPageUrl) return this.nextPageUrl; if ("www.hbooker.com" == this.contentDocument.location.host) return this.nextPageUrl = this.findNextPageUrlSpecial1(this.contentDocument), this.nextPageUrl; if ("chuangshi.qq.com" == this.contentDocument.location.host) return this.nextPageUrl = this.findNextPageUrlSpecial2(this.contentDocument), this.nextPageUrl; if ("html.hjsm.tom.com" == this.contentDocument.location.host) return this.nextPageUrl = this.findNextPageUrlSpecial3(this.contentDocument), this.nextPageUrl; for (var e = this.candidate.element; e.nodeType == Node.ELEMENT_NODE && "HTML" != e.tagName; ) { if (this.nextPageUrl = this.getNextPageUrl(e)) return this.nextPageUrl; e = e.parentElement } return this.nextPageUrl } , this.getNextPageUrl = function(e) { for (var t = null, n = 1, i = this.contentDocument.evaluate("//a[@href]", e, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null), o = 0; o < i.snapshotLength; o++) { var a = i.snapshotItem(o) , r = this.calcNextPageLinkScore(a); r >= n && F.pageUrlList.indexOf(a.href) < 0 && (t = a, n = r) } if (t) return O.nextPagePath = v(t), O.nextPageIsHerf = !0, t.href; i = this.contentDocument.evaluate("//input", e, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); for (o = 0; o < i.snapshotLength; o++) { a = i.snapshotItem(o); if (/下一页|下一章|下一篇|下一节|下页/i.test(a.value)) return t = a.getAttribute("onclick"), O.nextPagePath = v(a), O.nextPageIsHerf = !1, t.replace(/[^'"]*(?:'|")([^'"]+)(?:'|")[^'"]*/i, function(e, t) { return t }) } return null } , this.calcNextPageLinkScore = function(e) { function t(e, t, n, i, o) { var a; if (/下一页|下一章|下一篇|下一节|下页/i.test(n)) return !0; t.substring(0, e.length) == e && (t = t.substring(e.length), e = ""); var r = g(t); if (isNaN(r)) return !1; var l = e ? g(e) : NaN; return isNaN(l) && (l = i), r == l && g(n) == l + 1 || (r == l + 1 || (r > l + 1 && parseInt(n, 10) == i + 1 || !(!o || (a = o.parentElement || o.parentNode, !/下一页|下一章|下一篇|下一节|下页/i.test(a.innerHTML))))) } function n(e) { for (var t = {}, n = e.substring(1).split("&"), i = 0; i < n.length; i++) { var o = n[i] , a = o.indexOf("="); -1 == a ? t[o] = null : t[o.substring(0, a)] = o.substring(a + 1) } return t } var i = this.contentDocument.location , o = e.textContent; if (e.host != i.host) return 0; if (e.pathname == i.pathname && e.search == i.search) return 0; if (-1 != e.toString().indexOf("#")) return 0; if (F.pageUrlList.indexOf(e.href) >= 0) return 0; if (!h(e, !1)) return 0; var a = r(e) , l = r(this.candidate.element) , s = Math.max(0, Math.max(l.top - (a.top + a.height), a.top - (l.top + l.height))); if (s > 1e3) return 0; if (Math.max(-1, Math.max(l.left - (a.left + a.width), a.left - (l.left + l.width))) > -1) return 0; var c = e.pathname.substring(1).split("/"); c[c.length - 1] || c.pop(); var d = i.pathname.substring(1).split("/"); if (d[d.length - 1] || d.pop(), d[0] || d.shift(), c.length < d.length) return 0; var u = 0 , m = c.length - 1 , f = c[m]; if ((b = d[m] ? d[m] : "") != f) { if (f.length >= b.length) { for (var p = 0; f[f.length - 1 - p] == b[b.length - 1 - p]; ) p++; p && (f = f.substring(0, f.length - p), b = b.substring(0, b.length - p)) } if (!t(b, f, o, this.pageNumber, e)) return 0; u = Math.pow(1.5, m - c.length + 1) } var y = 0; if (e.search || i.search) { u = 0, linkSearches = n(e.search), pageSearches = n(i.search); for (var v in pageSearches) { var b = pageSearches[v]; if (!(f = v in linkSearches ? linkSearches[v] : null)) { u = 0; break } b != f && (null == b && (b = ""), null == f && (f = ""), f.length < b.length ? y++ : t(b, f, o, this.pageNumber) ? u = Math.max(u, 1 / 1.5) : y++) } } if (!u) return 0; var x = 10 * (Math.pow(2, -y) + u) + 5 * s / 225; "LI" == e.parentNode.tagName && (x += 3); var C = e.innerText; return /next|>|>|>|\u00bb|»|»/i.test(C) && (x += 5), /page.*\d+/i.test(C) && (x += 5), /continue|read\s+more/i.test(C) && (x += 3), /下一页|下一章|下一篇|下一节|下页/i.test(C) && (x += 5), "next" == e.getAttribute("rel") && (x += 10), x } , this.findNextPageUrlSpecial1 = function(e) { return e.querySelector("#J_BtnPageNext") ? e.querySelector("#J_BtnPageNext").getAttribute("data-href") : "" } , this.findNextPageUrlSpecial2 = function(e) { return e.querySelector(".nextPageBox>#nextChapterBtn") ? e.querySelector(".nextPageBox>#nextChapterBtn").href : "" } , this.findNextPageUrlSpecial3 = function(e) { if (null != e.getElementById("lastMsg")) return null; if (nextpage) return nextpage; var t = function() { var t = e.location.href , n = t.lastIndexOf("/"); -1 == t.indexOf("&chapter_id=") ? (n = (t = t.substring(n + 5)).indexOf(","), t = "&chapter_id=" + parseInt(t.substring(0, n), 16)) : t = t.substr(t.indexOf("&chapter_id=")); for (var i = 0, o = $TOC.length; i < o; i++) if (-1 != $TOC[i].indexOf(t)) return i + 1; var a = (t = e.location.href).split("#"); "1" != a.length && (t = t.substring(0, a[0].length)); var r = t.split("?"); "1" != r.length && (t = t.substring(0, r[0].length)); for (var i = 0, o = $TOC.length; i < o; i++) if (t == $TOC[i]) return i + 1 }(); return t == $TOC.length ? null : $TOC[t] } } function C() { this.key = "others.read_mode_setting", this.init = function() { maxthon.internalWebSend("read.loadSetting", {}, function(e) { var t = e.result; F.settings = _.parseUserSetting(t), F.defaultFontSize = parseInt(F.settings.fontSize); var n = null; F.settings.autoMode && "on" == F.settings.autoMode[U] && (n = window.setInterval(function() { R && (n = window.clearInterval(n), MaxthonReadModeShowToggle()) }, 500)) }) } , this.parseUserSetting = function(e) { var t = { reflect: "1", txt: "1", fontSize: "2", bgMode: "n", articleWidth: "70%", bgColor: "gray", fontFamily: "zh-CN" == window.navigator.language ? "微软雅黑" : "Segoe UI", autoMode: {} }; if (e) try { return (e = JSON.parse(e)).reflect || (e.reflect = t.reflect), e.txt || (e.txt = t.txt), e.bgColor || (e.bgColor = t.bgColor), e.fontFamily || (e.fontFamily = t.fontFamily), e.autoMode && "string" != typeof e.autoMode || (e.autoMode = t.autoMode), e } catch (e) { return t } else maxthon.internalWebSend("read.saveSetting", { setting: JSON.stringify(t) }); return t } , this.save = function(e) { maxthon.internalWebSend("read.saveSetting", { setting: JSON.stringify(e) }) } } function T(e) { switch (e.keyCode) { case 27: F.close(); break; case 37: F.scrollPage(!0); break; case 39: F.scrollPage(!1); break; case 187: S(); break; case 189: L(); break; default: return } } function N(e) { var t = this.getElementsByClassName("page") , n = r(t[t.length - 1]).height; this.body.scrollHeight - this.body.scrollTop - 900 < n && 3 != F.loadingStatusType && F.requestNextPageData(!1) } function w() { var e = F.getCurrentPageIndex(); if (e > 0) { var t = F.pageUrlList[e]; if (t) { r = { url: location.href, state: "off" }; return void maxthon.internalWebSend("read.toggle", r, function() { window.location = t }) } } if (F.bgContainer) { document.body.removeChild(F.bgContainer), F.bgContainer = null; for (var n = F.articleContainer.contentDocument.getElementsByClassName("content"), i = n.length, o = 0; o < i; o++) { var a = n[o]; a && a.removeChild(a.firstChild) } document.body.removeChild(F.articleContainer), F.articleContainer = null } F.nextPageFrame && (document.body.removeChild(F.nextPageFrame), F.nextPageFrame = null), F.articleContainer = null, O.articleTitleText = null; var r = { url: location.href, state: "off" }; maxthon.internalWebSend("read.toggle", r) } function E() { W = !0; var e = F.getNextPageFrame(); if (e.removeEventListener("DOMContentLoaded", E, !1), e.contentDocument) { var t = new x(e.contentDocument); if (t.getCandidateElement()) { t.pageNumber = F.pageNumber++; var n = t.getContent() || t.getCandidateElement(); F.contentElementList[F.pageNumber] = n, F.createNextPageContainer(n, t.articleTitleText), F.updatePageNumber(!1), F.nextPageUrl = t.findNextPageUrl(), F.nextPageUrl ? F.requestNextPageData(!0) : F.updateLoadingStatus(1) } else F.updateLoadingStatus(2) } else F.nextPageUrl = F.pageUrlList.pop(); e.removeAttribute("src") } function S() { F.defaultFontSize = Math.min(F.defaultFontSize + 1, t(F.defaultFontFamily).sizes.length - 1), F.updateArticleContainerStyle(), F.settings.fontSize = F.defaultFontSize, _.save(F.settings) } function L() { F.defaultFontSize = Math.max(F.defaultFontSize - 1, 0), F.updateArticleContainerStyle(), F.settings.fontSize = F.defaultFontSize, _.save(F.settings) } function P() { F.bgModeToggle(!F.nightModeFlag), F.settings.bgMode = F.nightModeFlag ? "day" : "night", _.save(F.settings), Y.ueipSet("rm_mode", F.settings.bgMode) } function M() { var e, t = F.articleContainer.contentDocument, n = Math.round(t.body.clientWidth * parseFloat(this.value) / 10); this.value; t.getElementById("articleContainer").style.maxWidth = n + "px", t.getElementById("currentValue").innerText = n + "px", e = (e = t.body.clientWidth - n) < 70 ? e / 2 + 35 : 10, t.getElementById("right-top-fixed-div").style.right = e + "px" } function A() { this.articleContainer = null, this.bgContainer = null, this.showFlag = !1, this.scrollTopCache = 0, this.contentContainer = null, this.defaultFontFamily = "微软雅黑", this.defaultFontSize = 2, this.imagesDisabledFlag = !0, this.nightModeFlag = !1, this.loadingStatusType = 0, this.pageUrlList = [], this.contentElementList = [], this.pageNumber = 1, this.nextPageFrame = null, this.nextPageUrl = null, this.settings = null, this.preOnMouseWheel, this.showToggle = function() { if (null != this.articleContainer && this.showFlag) this.close(); else { if (this.showFlag = !0, !this.articleContainer) { if (!this.contentContainer) { var e = O.getContent() || O.getCandidateElement(); this.contentContainer = document.createElement("div"), this.contentContainer.appendChild(e) } this.preview(), window.setTimeout(function(e) { e.create() }, 300, this) } Y.ueipCount("rm_activate", "t") } } , this.preview = function() { console.log("preview content"), this.bgContainer = document.createElement("iframe"), this.bgContainer.id = "bg-iframe", this.bgContainer.style.cssText = "transform: translateZ(0);position:fixed !important; left:0px !important; top:0px !important; right:0px !important; bottom:0px !important; width:100% !important; height:100% !important; max-width:100% !important; max-height:100% !important; border:none !important; background-color:rgba(0,0,0,0.9); z-index:9999999999999!important; cursor:default !important; float:none !important; margin:0px !important; padding:0px !important; opacity:0; -webkit-transition:opacity 400ms;display: block !important;", document.body.appendChild(this.bgContainer), this.bgContainer.contentDocument.body.style.cssText = 'color:#fff;text-align:center;font-size:1em;font-family:"Segoe UI", Tahoma;', this.bgContainer.contentDocument.body.innerText = V.loading, this.bgContainer.style.opacity = "1"; for (var e = document.body.querySelectorAll("div, iframe, object, embed"), t = e.length - 1; t >= 0; t--) { var n = e[t]; if ("DIV" == n.tagName) { var i = window.getComputedStyle(n, null); i && parseFloat(i.zIndex) > 999997 && (n.zIndexCache = i.zIndex, n.style.zIndex = "999997") } else { if ("article-iframe" == n.id || "bg-iframe" == n.id) continue; n.cssTextCache = n.style.cssText, n.style.visibility = "hidden" } } } , this.create = function() { this.articleContainer = document.createElement("iframe"), this.articleContainer.id = "article-iframe", this.articleContainer.style.cssText = "position:fixed !important; left:0px !important; top:0px !important; right:0px !important; bottom:0px !important; width:100% !important; height:100% !important; max-width:100% !important; max-height:100% !important; border:none !important; background-color:rgba(0,0,0,0.0); z-index:9999999999999!important; color:#000; cursor:default !important; float:none !important; letter-spacing:normal; line-height:normal; text-align:left; text-decoration:none; white-space:normal; word-spacing:normal; margin:0px !important; padding:0px !important; direction:ltr; -webkit-transition:-webkit-transform 300ms ease-out; -webkit-transform:translate3d(0, 100%, 0);display: block !important;", document.body.cssTextCache = document.body.style.cssText, document.documentElement.cssTextCache = document.documentElement.style.cssText; var e = window.getComputedStyle(document.body, null) , t = p(); document.body.style.marginRight = parseInt(e.marginRight, 10) + t + "px", document.body.scrollTopCache = document.body.scrollTop, document.body.scrollTop = 0, document.body.style.overflow = "hidden", document.documentElement.style.overflow = "hidden", this.preOnMouseWheel = document.body.onmousewheel, document.body.onmousewheel = function() { return !1 } , document.body.appendChild(this.articleContainer); var n = this.articleContainer.contentDocument; try { n.open(), n.write(H), n.close(); var r = n.getElementsByClassName("title")[0]; if (!r) throw "no title" } catch (e) { return this.bgContainer.contentDocument.body.innerText = V.load_error, void setTimeout(function(e) { e.close() }, 500, this) } r.innerText = O.getArticleTitle(), n.getElementsByClassName("content")[0].innerHTML = this.contentContainer.innerHTML, n.onmouseup = function() { window.getSelection() && document.body.scrollTop > 0 && (document.body.scrollTop = 0) } , n.getElementById("btnZoomIn").onclick = S, n.getElementById("btnZoomOut").onclick = L, n.getElementById("btnBgMode").onclick = P; var l = n.getElementById("btnAutoMode") , s = F.settings.autoMode[U] ? F.settings.autoMode[U] : "off"; l.onclick = function() { var e = this.querySelector("img"); s = "on" == s ? "off" : "on", e.src = "mx://read-mode/images/auto-mode-" + s + ".png", e.title = V["auto_mode_" + s].replace("$currentdomain$", window.location.hostname), F.settings.autoMode[U] = s, _.save(F.settings), "on" == s && Y.ueipSet("rm_autoopenlist", U) } ; var c = l.querySelector("img"); c.src = "mx://read-mode/images/auto-mode-" + s + ".png", c.title = V["auto_mode_" + s].replace("$currentdomain$", window.location.hostname), n.getElementById("btnClose").onclick = function() { F.close() } , n.getElementById("closeModalBtn").onclick = function() { F.close() } , n.getElementById("reflect-btn").onclick = function() { n.querySelector("#right-top-fixed-div .reflect").style.display = "none", Y.ueipSet("rm_fb_" + (new Date).getTime(), window.location.href) } , n.onscroll = N; var h, d = n.getElementById("font-select"), u = n.getElementById("font-set"), g = n.getElementById("font-list"), m = []; "zh-cn" == V.locale || "en" == V.locale ? (d.style.display = "none", g.style.display = "none", u.innerHTML = F.settings.fontFamily, "zh-cn" == V.locale ? (m.push("<li>微软雅黑</li>"), m.push("<li>宋体</li>"), m.push("<li>仿宋</li>"), m.push("<li>黑体</li>"), m.push("<li>楷体</li>"), m.push("<li>隶书</li>"), m.push('<li id="other-fonts">其他字体</li>')) : "en" == V.locale && (m.push("<li>Segoe UI</li>"), m.push("<li>Verdana</li>"), m.push("<li>Arial</li>"), m.push("<li>Tahoma</li>"), m.push("<li>Georgia</li>"), m.push("<li>Times New Roman</li>"), m.push('<li id="other-fonts">Other fonts</li>')), g.innerHTML = m.join(""), h = n.getElementById("other-fonts"), u.addEventListener("click", function() { g.style.display = "none" != g.style.display ? "none" : "block" }, !1), g.addEventListener("click", function(e) { if ("[object HTMLLIElement]" == e.target) { var t = n.getElementById("font-style") , i = u.innerHTML; e.target == h ? setTimeout(function() { maxthon.internalWebSend("read.chooseFont", { name: F.settings.fontFamily }, function(e) { var i = e.result; i && (n.querySelector("#font-set").innerHTML = i, t.innerHTML = t.innerHTML.replace(/#article \* { font-family: ([^,]+),/, function(e, t) { return e.replace(t, i) })) }) }, 50) : i = e.target.innerHTML, i && (u.innerHTML = i), t.innerHTML = t.innerHTML.replace(/#article \* { font-family: ([^,]+),/, function(e, t) { return e.replace(t, i) }), this.style.display = "none", e.stopPropagation() } }, !1)) : (u.style.display = "none", g.style.display = "none", d.addEventListener("click", function() { var e = n.getElementById("font-style"); maxthon.internalWebSend("read.chooseFont", { name: F.settings.fontFamily }, function(t) { var n = t.result; "".setFontList([n]), this.innerHTML = n.getName(), e.innerHTML = e.innerHTML.replace(/#article \* { font-family: ([^,]+),/, function(e, t) { return e.replace(t, n.getName()) }) }) }, !1)), n.getElementById("range").onmousemove = M, n.getElementById("pwPannel").addEventListener("click", function(e) { var t; if ("bg-color" == e.target.getAttribute("name")) { if ("true" == (t = e.target.parentNode).getAttribute("disabled")) return; (t = n.querySelector('#pwPannel [name="bg-color"].selected')) && i(t, "selected"), o(e.target, "selected"), a(t = F.articleContainer.contentDocument.querySelector("#article"), e.target.className.replace("selected", "")) } }, !1), n.getElementById("set-save").addEventListener("click", function() { var e; e = n.getElementById("range"), F.settings.articleWidth = 10 * e.value + "%", _.save(F.settings), e = n.querySelector('#pwPannel [name="bg-color"].selected'), F.settings.bgColor = e.className.replace(/selected/g, "").replace(/^\s+/, "").replace(/\s+$/, ""), (e = n.getElementById("font-style").innerHTML.match(/#article \* { font-family: ([^,]+),/)) && e[1] && (F.settings.fontFamily = e[1]), _.save(F.settings), Y.ueipSet("rm_background_color", F.settings.bgColor), Y.ueipSet("rm_font", F.settings.fontFamily) }, !1), n.getElementById("set-cancel").addEventListener("click", function() { F.updateArticleContainerStyle() }, !1), "1" == F.settings.txt && (n.getElementById("txt-sign").value = "1", F.settings.txt = "0", _.save(F.settings)), "1" == F.settings.reflect && (n.getElementById("reflect-sign").value = "1", F.settings.reflect = "0", _.save(F.settings)), n.body.onkeydown = T, this.updateArticleContainerStyle(), O.getCandidate().directionIsNormal || o(n.getElementById("article"), "rtl"), this.articleContainer.style["-webkit-transform"] = "translate3d(0, 0, 0)", this.bgContainer.contentDocument.body.innerText = "", this.startRequestNextPage(); var f = { url: location.href, state: "on" }; maxthon.internalWebSend("read.toggle", f, function() {}) } , this.close = function() { this.showFlag = !1, this.nightModeFlag = !1; var e = this.articleContainer.contentDocument.getElementById("articleContainer"); e && (this.scrollTopCache = e.scrollTop), this.bgContainer.style.opacity = "0", this.articleContainer.style["-webkit-transform"] = "translate3d(0, 100%, 0)", document.body.style.cssText = document.body.cssTextCache, document.documentElement.style.cssText = document.documentElement.cssTextCache, document.body.scrollTop = document.body.scrollTopCache, document.body.onmousewheel = this.preOnMouseWheel; for (var t = document.body.querySelectorAll("div, iframe, object, embed"), n = t.length - 1; n >= 0; n--) { var i = t[n]; "DIV" == i.tagName ? i.style && i.zIndexCache && (i.style.zIndex = i.zIndexCache) : void 0 !== i.cssTextCache && (i.style.cssText = i.cssTextCache) } setTimeout(w, 300) } , this.getCurrentPageIndex = function() { var e = 0 , t = this.articleContainer.contentDocument; if (0 == t.body.scrollTop || 1 == this.pageNumber) return e; for (var n, i = t.getElementsByClassName("page"); e < i.length && !((n = i[e].getBoundingClientRect().top) > 0); e++) ; return (n > window.innerHeight || n < 0) && e--, e } , this.imagesToggle = function(e) { var t = this.articleContainer.contentDocument.getElementById("btnImages") , n = this.articleContainer.contentDocument.getElementsByClassName("content"); if (e) { t.src = "mx://read-mode/images/images-on.png", t.title = "Disable images"; for (i = 0; i < n.length; i++) o(n[i], "content") } else { t.src = "mx://read-mode/images/images-off.png", t.title = "Enable images"; for (var i = 0; i < n.length; i++) o(n[i], "content disableImages") } } , this.bgModeToggle = function(e) { if (F.articleContainer.contentDocument.getElementById("set-bg").setAttribute("disabled", e), this.nightModeFlag != e) { var t = this.articleContainer.contentDocument , n = t.getElementById("btnBgMode") , a = t.getElementsByClassName("contentWrapper") , r = t.getElementsByClassName("pageNumber") , l = t.getElementsByClassName("title"); if (this.nightModeFlag = e, this.nightModeFlag) { n.firstChild.src = "mx://read-mode/images/bgmode-day.png", n.firstChild.title = V.day_mode; for (s = 0; s < a.length; s++) o(a[s], "nightMode"), o(r[s], "nightMode"), o(l[s], "nightMode") } else { n.firstChild.src = "mx://read-mode/images/bgmode-night.png", n.firstChild.title = V.night_mode; for (var s = 0; s < a.length; s++) i(a[s], "nightMode"), i(r[s], "nightMode"), i(l[s], "nightMode") } } } , this.scrollPage = function(e) { var t = this.articleContainer.contentDocument , n = t.getElementById("articleContainer"); if (0 != n.scrollTop || !e) { for (var i = t.getElementsByClassName("page"), o = 0; o < i.length; o++) { var a = i[o].getBoundingClientRect().top; if (0 == a && e) break; if (a > (0 == o ? 20 : 0)) break } if (e) o = --o > 0 ? o : 0; else if (o == i.length) return n.scrollTop = n.scrollHeight - n.clientHeight, void (2 == this.loadingStatusType ? (this.close(), window.location = this.pageUrlList[this.pageNumber]) : (this.requestNextPageData(!1), 3 == this.loadingStatusType && (t.getElementById("controls").className = "visible", this.loadingStatusType = 0))); n.scrollTop = i[o].offsetTop } } , this.startRequestNextPage = function() { var e = this.articleContainer.contentDocument; if (1 == this.pageNumber) if (e.getElementById("articleContainer").scrollTop = this.scrollTopCache, this.pageUrlList = [], this.nextPageUrl = O.findNextPageUrl(), this.nextPageUrl) this.requestNextPageData(!0), this.updatePageNumber(!1); else { var t = e.getElementsByClassName("contentWrapper")[0]; r(t).height < window.innerHeight - 122 && (t.style.height = window.innerHeight - 122), this.updatePageNumber(!0), this.updateLoadingStatus(1) } else { for (var n = 2; n <= this.pageNumber; n++) { var i = this.contentElementList[n]; i && this.createNextPageContainer(i, "") } e.getElementById("articleContainer").scrollTop = this.scrollTopCache, this.pageUrlList.length > this.pageNumber ? (this.updatePageNumber(!1), this.nextPageUrl = this.pageUrlList.pop()) : (this.updateLoadingStatus(1), this.updatePageNumber(!1)) } } , this.requestNextPageData = function(e) { var t = this.nextPageUrl; t && -1 == this.pageUrlList.indexOf(t) && (0 != this.loadingStatusType || 20 != this.pageNumber ? e && this.pageNumber % 3 == 0 || (this.pageUrlList[this.pageNumber] = t, null != this.articleContainer && this.showFlag && setTimeout(function() { function e() { W ? clearTimeout(i) : n.contentWindow && ("complete" === n.contentWindow.document.readyState ? (n.removeEventListener("load", E), clearTimeout(i), E()) : setTimeout(e, 2e3)) } W = !1; var n = F.getNextPageFrame(); n.addEventListener("load", E, !1), n.onprocess = function(e) { console.info(e) } , n.src = t; var i = setTimeout(e, 8e3) }, 250), this.nextPageUrl = null) : this.updateLoadingStatus(3)) } , this.getNextPageFrame = function() { return this.nextPageFrame || (this.nextPageFrame = document.createElement("iframe"), this.nextPageFrame.style.position = "absolute", this.nextPageFrame.style.width = window.innerWidth + "px", document.body.appendChild(this.nextPageFrame)), this.nextPageFrame } , this.updatePageNumber = function(e) { var t = this.articleContainer.contentDocument.getElementsByClassName("pageNumber") , n = t.length; if (1 == n && e) t[0].style.display = "none"; else for (var i = 0; i < n; i++) t[i].firstChild.textContent = i + 1 } , this.updateLoadingStatus = function(e) { var t = this.articleContainer.contentDocument.getElementsByClassName("loader") , n = t[t.length - 1]; switch (this.loadingStatusType = e, e) { case 1: n.style.display = "none"; break; case 2: n.innerHTML = V.loading_next_err, o(n, "loader"), o(n, "enableClick"), n.onclick = function() { F.close(), window.location = F.pageUrlList[F.pageNumber] } , 1 == this.pageNumber && (n.style.display = "block"); break; case 3: n.innerHTML = V.loading_next_tips, o(n, "loader"), o(n, "enableClick"), n.onclick = function() { F.requestNextPageData(!1), F.loadingStatusType = 0 } } } , this.createNextPageContainer = function(e, t) { var n = this.articleContainer.contentDocument , i = n.getElementsByClassName("page")[0].cloneNode(!0); if (t.length) { var o = i.getElementsByClassName("title")[0]; o.innerText == t ? o.innerText = "" : o.innerText = t } var a = i.getElementsByClassName("content")[0] , r = document.createElement("div"); r.appendChild(e), a.innerHTML = r.innerHTML, n.getElementById("article").appendChild(i) } , this.updateArticleContainerStyle = function() { var e; this.defaultFontFamily = this.settings.fontFamily; var n = t(this.defaultFontFamily) , r = "#article * { font-family: " + this.defaultFontFamily + ", 宋体, Times New Roman, Verdana !important; font-size: " + n.sizes[this.defaultFontSize] + "px; line-height: " + n.lineHeight + "; }"; r += ".page .contentWrapper { padding: " + 10 / 1.2 + "% 10%; }"; var l = this.articleContainer.contentDocument , s = l.getElementById("font-style"); s || ((s = l.createElement("style")).id = "font-style"), s.innerText = r, l.body.appendChild(s); var c = this.settings.articleWidth; l.getElementById("articleContainer").style.maxWidth = window.innerWidth * parseInt(c) / 100 + "px", l.getElementById("range").value = parseInt(c) / 10, l.getElementById("currentValue").innerText = window.innerWidth * parseInt(c) / 100 + "px"; var h = l.getElementById("article"); a(h, F.settings.bgColor); var d = l.querySelector('#pwPannel [name="bg-color"].selected'); d && i(d, "selected"), (d = l.querySelector('#pwPannel [name="bg-color"].' + F.settings.bgColor)) && o(d, "selected"), h.style.fontFamily = "", "zh-cn" == V.locale || "en" == V.locale ? l.getElementById("font-set").innerHTML = F.settings.fontFamily : l.getElementById("font-select").innerHTML = "Other fonts", this.bgModeToggle("day" == this.settings.bgMode), e = (e = l.body.clientWidth * (1 - parseInt(c, 10) / 100)) < 70 ? e / 2 + 35 : 10, l.getElementById("right-top-fixed-div").style.right = e + "px" } } function B() { F = new A, O.findNextPageUrl(), _ || (_ = new C).init(); var e = document.querySelectorAll("embed"); Array.prototype.forEach.call(e, function(e) { var t = e.getAttribute("wmode"); "transparent" != t && "opaque" != t && e.setAttribute("wmode", "transparent") }); var t = { url: location.href, state: "show" }; maxthon.internalWebSend("read.toggle", t), setTimeout(m, 300) } function q(e) { console.info("start parse"), 0 != document.body.clientWidth ? "weibo.com" == location.host && (location.pathname.length < 6 || location.pathname.indexOf("article") < 0) || ("blog.csdn.net" != location.host && "www.cnblogs.com" != location.host ? (R = !1, (O = new x(document)).getCandidate() ? B() : f(B)) : setTimeout(q, 100, 1)) : "complete" != document.readyState ? setTimeout(q, 100, 0) : 1 !== e && setTimeout(q, 100, 1) } var F = null , H = "" , O = null , _ = null , R = !1 , U = window.location.hostname , z = 0 , W = !1 , $ = { "微软雅黑": { sizes: [14, 15, 16, 18, 20, 22, 23, 26, 28, 37], lineHeight: 1.9 }, "宋体": { sizes: [15, 16, 19, 20, 22, 23, 26, 28, 37, 46], lineHeight: 1.9 }, "Times New Roman": { sizes: [15, 16, 19, 20, 22, 23, 26, 28, 37, 46], lineHeight: 1.64 }, Verdana: { sizes: [11, 13, 14, 16, 17, 19, 21, 23, 32, 39], lineHeight: 1.9 }, Tahoma: { sizes: [12, 13, 15, 17, 18, 20, 22, 25, 30, 38], lineHeight: 1.9 }, Georgia: { sizes: [13, 14, 16, 18, 20, 23, 26, 28, 35, 40], lineHeight: 1.64 }, Palatino: { sizes: [14, 16, 17, 18, 20, 22, 24, 26, 37, 46], lineHeight: 1.7 }, Cambria: { sizes: [14, 16, 17, 18, 20, 22, 24, 26, 37, 46], lineHeight: 1.7 }, "Segoe UI": { sizes: [14, 16, 17, 18, 20, 22, 24, 26, 37, 46], lineHeight: 1.7 }, "Book Antiqua": { sizes: [14, 16, 17, 18, 20, 22, 24, 26, 37, 46], lineHeight: 1.7 }, Others: { sizes: [15, 16, 19, 20, 22, 23, 26, 28, 37, 46], lineHeight: 1.8 } } , V = { message: "Сообщение", loading: "Загрузка Режима чтения…", load_error: "Ошибка", auto_mode_on: "Авторежим чтения на $currentdomain$ (Вкл)", auto_mode_off: "Авторежим чтения на $currentdomain$ (Выкл)", auto_mode_Txt: "Нажмите здесь для автопереключения этого сайта ($currentdomain$) в Режим чтения.", auto_mode_Tip: "Авторежим чтения для сайта $currentdomain$ включен.", day_mode: "Дневной режим", night_mode: "Ночной режим, снижает утомление глаз", loading_next_err: "Не удаётся загрузить следующую страницу, нажмите здесь для проверки (клавиша →)", loading_next_tips: "Перейти на следующую страницу (клавиша →)", locale: "zh-CN" == window.navigator.language ? "zh-cn" : "en" } , Y = function() { var e = "readmode"; return { ueipSet: function(t, n) { maxthon.send("setUeip2", [{ params: { pt: e, dt: t, data: n } }]) }, ueipCount: function(e, t) {} } }(); window.MaxthonReadModeShowToggle = function() { console.info("showToggle"), F.showToggle() } , window.ReanalyzeDocument = function() { if (console.info("Reanalyze Document " + z), (z += 1) > 5) z = 0; else if (O.candidate && h(O.candidate.element)) setTimeout(function() { var e = { url: location.href, state: "show" }; maxthon.internalWebSend("read.toggle", e) }, 1e3); else { if (console.info("Reanalyze candidate clear candidate"), O.candidate = null, O.articleTitleText = null, O.getCandidate()) return console.info("Reanalyze document show clear content"), setTimeout(function() { var e = { url: location.href, state: "show" }; maxthon.internalWebSend("read.toggle", e) }, 1e3), O.articleTitle || (O.articleTitleText = null), F || B(), F.articleContainer = null, F.contentContainer = null, void (O.content = null); setTimeout(window.ReanalyzeDocument, 2e3) } } , q() }(window); |