From 8538e3663339261bb2eddc8cfe6c3297632b932b Mon Sep 17 00:00:00 2001 From: xing Date: Fri, 10 Jul 2020 18:15:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tieba page.js | 91 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 34 deletions(-) diff --git a/tieba page.js b/tieba page.js index 4d5a24d..4d70108 100644 --- a/tieba page.js +++ b/tieba page.js @@ -1,7 +1,7 @@ // ==UserScript== // @name tieba page // @namespace http://tampermonkey.net/ -// @version 1.008 +// @version 1.009 // @author fthvgb1 // @match https://tieba.baidu.com/* // @match https://tiebac.baidu.com/* @@ -370,6 +370,7 @@ let tot = Math.ceil(orgnum / 10); let el = a.previousElementSibling; a.addEventListener('click', function () { + let that = this; if (num === orgnum) { let url = this.getAttribute('data-url'); @@ -385,23 +386,25 @@ if (GM_xmlhttpRequest) { const tt = Math.ceil((new Date()).getTime()); url = `/p/comment?tid=${kz}&pid=${tid}&pn=1&t=${tt}`; - gmPage(url, el, 1) - num -= 8; - that.innerText = `还有${num}条回复`; - if (orgnum > 10) { - a.style.display = 'none'; - tpage(tot, el, (page) => { - if (a.style.display !== 'none') { - a.style.display = 'none'; - } - let tt = Math.ceil((new Date()).getTime()); - let url = `/p/comment?tid=${kz}&pid=${tid}&pn=${page}&t=${tt}`; - gmPage(url, el, page, function () { - let l = lo(document, el); - window.scrollTo({top: l.top - 20, left: 0, behavior: "smooth"}); + gmPage(url, el, 1, () => { + + num -= 8; + that.innerText = `还有${num}条回复`; + if (orgnum > 10) { + a.style.display = 'none'; + tpage(tot, el, (page) => { + if (a.style.display !== 'none') { + a.style.display = 'none'; + } + let tt = Math.ceil((new Date()).getTime()); + let url = `/p/comment?tid=${kz}&pid=${tid}&pn=${page}&t=${tt}`; + gmPage(url, el, page, function () { + let l = lo(document, el); + window.scrollTo({top: l.top - 20, left: 0, behavior: "smooth"}); + }); }); - }); - } + } + }) } else { $.get(url, function (rst) { replayPage({data: {floor_html: rst}}, el, ls => { @@ -432,23 +435,43 @@ } else { - let url = `/mo/q//flr?fpn=${page}&kz=${kz}&pid=${tid}&is_ajax=1&has_url_param=0&template=lzl`; - $.get(url, function (res) { - replayPage(res, el); - let i = el.parentNode.querySelector('.pagexx input'); - if (i) { - i.dataset.r = `${page}`; - i.type = 'text'; - i.value = page + '/' + tot; - } - ++page; - if (num > 10) { - num -= 10; - that.innerText = `还有${num}条回复`; - } else { - that.parentNode.removeChild(that); - } - }) + if (GM_xmlhttpRequest) { + const tt = Math.ceil((new Date()).getTime()); + url = `/p/comment?tid=${kz}&pid=${tid}&pn=${page}&t=${tt}`; + gmPage(url, el, page, () => { + let i = el.parentNode.querySelector('.pagexx input'); + if (i) { + i.dataset.r = `${page}`; + i.type = 'text'; + i.value = page + '/' + tot; + } + ++page; + if (num > 10) { + num -= 10; + that.innerText = `还有${num}条回复`; + } else { + that.parentNode.removeChild(that); + } + }) + } else { + let url = `/mo/q//flr?fpn=${page}&kz=${kz}&pid=${tid}&is_ajax=1&has_url_param=0&template=lzl`; + $.get(url, function (res) { + replayPage(res, el); + let i = el.parentNode.querySelector('.pagexx input'); + if (i) { + i.dataset.r = `${page}`; + i.type = 'text'; + i.value = page + '/' + tot; + } + ++page; + if (num > 10) { + num -= 10; + that.innerText = `还有${num}条回复`; + } else { + that.parentNode.removeChild(that); + } + }) + } } }); }