// ==UserScript==
// @name tieba page
// @namespace http://tampermonkey.net/
// @version 0.3
// @author fthvgb1
// @match https://tieba.baidu.com/*
// @grant unsafeWindow
// @description 显示手机版贴吧里被隐藏的楼层与翻页按钮
// @downloadURL none
// ==/UserScript==
function t(){
$("ul#pblist>li").forEach(function(e){
var ee = $(e);
var tid = ee.attr("tid");
var content = ee.find(".list_item_top");
var x = ee.find('.list_item_top a.j_report_btn');
if(x && x.length>0){
var kz = x[0].href.match(/tid=(\d+)\&/);
kz=kz[1];
}
var floor = e.getElementsByClassName('pb_floow_load');
if(floor.length>0){
var text = floor[0].textContent;
var url = `https://tieba.baidu.com/t/p/${tid}`;
var num = parseInt(text.match(/\d+/));
content.append(`
`);
var res =content.find('a.reply');
var orgnum=num;
//console.log(content,res);
if(res){
res.forEach(function (v,i) {
v.addEventListener('click',function () {
var that = this;
var page =2;
if(num===orgnum){
var url = this.getAttribute('data-url');
//console.log();
$.get(url,function (rst) {
var dom = (new DOMParser()).parseFromString(rst,'text/html');
var r = dom.querySelector('.j_floor_panel');
var lii=r.querySelectorAll('li');
lii.forEach(function (li,index) {
//console.log(li.className)
if(index<2){
return;
}
var username = li.querySelector('.left>div .user_name').outerHTML;
username=username.replace('',':');
var s = li.querySelector('.content span');
s.className='floor_content';
var c = li.querySelector('.content').innerHTML;
var div = `
`;
li.innerHTML=div;
var ll = document.createElement('li');
ll.classList.add('list_item_floor');
ll.classList.add('j_list_item_floor');
ll.innerHTML=div;
//console.log(content.find('.flist'))
content.find('.flist')[0].appendChild(ll)
});
if(num<=8){
that.parentNode.removeChild(that);
}else {
num -= 8;
that.innerText=`查看剩余${num}条回复`;
}
});
}else{
var url=`https://tieba.baidu.com/mo/q//flr?fpn=${page}&kz=${kz}&pid=${tid}&is_ajax=1&has_url_param=0&template=lzl`;
$.get(url,function (res) {
var ht = (new DOMParser()).parseFromString(res.data.floor_html,'text/html');
var lii=ht.querySelectorAll('li');
lii.forEach(function (li,index) {
var username = li.querySelector('.left>div .user_name').outerHTML;
username=username.replace('',':');
var s = li.querySelector('.content span');
s.className='floor_content';
var c = li.querySelector('.content').innerHTML;
var div = `
`;
li.innerHTML=div;
var ll = document.createElement('li');
ll.classList.add('list_item_floor');
ll.classList.add('j_list_item_floor');
ll.innerHTML=div;
//console.log(content.find('.flist'))
content.find('.flist')[0].appendChild(ll)
});
if(num>10){
num -= 10;
that.innerText=`查看剩余${num}条回复`;
}else{
that.parentNode.removeChild(that);
}
})
}
})
})
}
floor[0].parentNode.removeChild(floor[0])
}
});
}
(function() {
$("#pblist").css("padding-bottom","0");
$("#pblist>li[fn]").css("display","block");
$("#pblist>li:not([fn])").remove();
var pager = $("#list_pager");
pager.attr("style","visibility:visible !important");
pager.css("padding","16px 0");
$("#list_pager").height(16);
$(".father_cut_daoliu").css("display","none");
t();
$("#list_pager>a").on("click",function(){setTimeout(t,3000);});
var recomnd=$('.father-cut-recommend-normal-box');
if(recomnd.length>0){
recomnd[0].parentNode.removeChild(recomnd[0])
}
})();