This commit is contained in:
xing 2020-07-10 18:15:16 +08:00
parent 26ecb8c293
commit 8538e36633

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name tieba page // @name tieba page
// @namespace http://tampermonkey.net/ // @namespace http://tampermonkey.net/
// @version 1.008 // @version 1.009
// @author fthvgb1 // @author fthvgb1
// @match https://tieba.baidu.com/* // @match https://tieba.baidu.com/*
// @match https://tiebac.baidu.com/* // @match https://tiebac.baidu.com/*
@ -370,6 +370,7 @@
let tot = Math.ceil(orgnum / 10); let tot = Math.ceil(orgnum / 10);
let el = a.previousElementSibling; let el = a.previousElementSibling;
a.addEventListener('click', function () { a.addEventListener('click', function () {
let that = this; let that = this;
if (num === orgnum) { if (num === orgnum) {
let url = this.getAttribute('data-url'); let url = this.getAttribute('data-url');
@ -385,23 +386,25 @@
if (GM_xmlhttpRequest) { if (GM_xmlhttpRequest) {
const tt = Math.ceil((new Date()).getTime()); const tt = Math.ceil((new Date()).getTime());
url = `/p/comment?tid=${kz}&pid=${tid}&pn=1&t=${tt}`; url = `/p/comment?tid=${kz}&pid=${tid}&pn=1&t=${tt}`;
gmPage(url, el, 1) gmPage(url, el, 1, () => {
num -= 8;
that.innerText = `还有${num}条回复`; num -= 8;
if (orgnum > 10) { that.innerText = `还有${num}条回复`;
a.style.display = 'none'; if (orgnum > 10) {
tpage(tot, el, (page) => { a.style.display = 'none';
if (a.style.display !== 'none') { tpage(tot, el, (page) => {
a.style.display = 'none'; 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}`; let tt = Math.ceil((new Date()).getTime());
gmPage(url, el, page, function () { let url = `/p/comment?tid=${kz}&pid=${tid}&pn=${page}&t=${tt}`;
let l = lo(document, el); gmPage(url, el, page, function () {
window.scrollTo({top: l.top - 20, left: 0, behavior: "smooth"}); let l = lo(document, el);
window.scrollTo({top: l.top - 20, left: 0, behavior: "smooth"});
});
}); });
}); }
} })
} else { } else {
$.get(url, function (rst) { $.get(url, function (rst) {
replayPage({data: {floor_html: rst}}, el, ls => { replayPage({data: {floor_html: rst}}, el, ls => {
@ -432,23 +435,43 @@
} else { } else {
let url = `/mo/q//flr?fpn=${page}&kz=${kz}&pid=${tid}&is_ajax=1&has_url_param=0&template=lzl`; if (GM_xmlhttpRequest) {
$.get(url, function (res) { const tt = Math.ceil((new Date()).getTime());
replayPage(res, el); url = `/p/comment?tid=${kz}&pid=${tid}&pn=${page}&t=${tt}`;
let i = el.parentNode.querySelector('.pagexx input'); gmPage(url, el, page, () => {
if (i) { let i = el.parentNode.querySelector('.pagexx input');
i.dataset.r = `${page}`; if (i) {
i.type = 'text'; i.dataset.r = `${page}`;
i.value = page + '/' + tot; i.type = 'text';
} i.value = page + '/' + tot;
++page; }
if (num > 10) { ++page;
num -= 10; if (num > 10) {
that.innerText = `还有${num}条回复`; num -= 10;
} else { that.innerText = `还有${num}条回复`;
that.parentNode.removeChild(that); } 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);
}
})
}
} }
}); });
} }