楼中楼翻页
This commit is contained in:
parent
67dc71da23
commit
ee38a89b09
118
tieba page.js
118
tieba page.js
|
@ -1,7 +1,7 @@
|
|||
// ==UserScript==
|
||||
// @name tieba page
|
||||
// @namespace https://github.com/fthvgb1/tampermonkey-script
|
||||
// @version 1.006
|
||||
// @version 1.007
|
||||
// @author fthvgb1
|
||||
// @match https://tieba.baidu.com/*
|
||||
// @match https://tiebac.baidu.com/*
|
||||
|
@ -266,6 +266,66 @@
|
|||
})
|
||||
}
|
||||
|
||||
function gmPage(url, el, page, call) {
|
||||
GM_xmlhttpRequest({
|
||||
method: 'GET',
|
||||
url: url,
|
||||
headers: {
|
||||
"User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36'
|
||||
},
|
||||
onload: function (res) {
|
||||
let lis = (new DOMParser()).parseFromString(res.responseText, 'text/html');
|
||||
|
||||
let tmp = lis.querySelectorAll('li');
|
||||
let arr = [...tmp];
|
||||
arr.splice(tmp.length - 1, 1);
|
||||
if (page === 1 && el.length > 0) {
|
||||
arr.splice(0, 2);
|
||||
}
|
||||
arr.forEach(li => {
|
||||
|
||||
let o = JSON.parse(li.getAttribute('data-field'));
|
||||
let n = {
|
||||
pid: o.spid,
|
||||
un: o.user_name
|
||||
}
|
||||
let ell = document.createElement('li');
|
||||
ell.className = 'list_item_floor j_list_item_floor';
|
||||
ell.setAttribute('data-info', JSON.stringify(n))
|
||||
ell.setAttribute('pid', o.spid);
|
||||
let time = li.querySelector('.lzl_time').innerHTML;
|
||||
let h = li.querySelector('a[class="at j_user_card "]');
|
||||
|
||||
let he = `<a href="${h.href}" target="_blank" class="user_name">${h.getAttribute('username') + (h.innerText !== h.getAttribute('username') ? '(' + h.innerText + ')' : '')}</a>`;
|
||||
let re = li.querySelector('.lzl_content_main');
|
||||
|
||||
let rrr = re.querySelector('.at');
|
||||
let rrrxx = '';
|
||||
if (rrr) {
|
||||
rrrxx += `回复 <a href="${rrr.href}">${rrr.innerText}</a> : `
|
||||
re.removeChild(rrr)
|
||||
}
|
||||
rrrxx += re.innerHTML
|
||||
ell.innerHTML = `
|
||||
<div class="fmain j_floor_main">
|
||||
<div class="floor_footer_item">
|
||||
${he}: <span style="color: #8fa391">${time}</span>
|
||||
<span class="floor_content">
|
||||
${rrrxx}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
el.append(ell)
|
||||
|
||||
})
|
||||
if (call) {
|
||||
call()
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function t() {
|
||||
lz();
|
||||
|
||||
|
@ -309,9 +369,42 @@
|
|||
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');
|
||||
if (num <= 8) {
|
||||
$.get(url, function (rst) {
|
||||
replayPage({data: {floor_html: rst}}, el, ls => {
|
||||
ls.splice(0, 2)
|
||||
that.parentNode.removeChild(that);
|
||||
});
|
||||
});
|
||||
return
|
||||
}
|
||||
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"});
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$.get(url, function (rst) {
|
||||
replayPage({data: {floor_html: rst}}, el, ls => {
|
||||
ls.splice(0, 2)
|
||||
|
@ -337,6 +430,28 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
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) {
|
||||
|
@ -356,6 +471,7 @@
|
|||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user