Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
ee38a89b09 | |||
67dc71da23 | |||
2524162988 | |||
9e33b23c14 | |||
37cf14b5e3 | |||
3bd0682c78 |
289
tieba page.js
289
tieba page.js
|
@ -1,7 +1,7 @@
|
|||
// ==UserScript==
|
||||
// @name tieba page
|
||||
// @namespace https://github.com/fthvgb1/tampermonkey-script
|
||||
// @version 1.000
|
||||
// @version 1.007
|
||||
// @author fthvgb1
|
||||
// @match https://tieba.baidu.com/*
|
||||
// @match https://tiebac.baidu.com/*
|
||||
|
@ -87,6 +87,7 @@
|
|||
call(x);
|
||||
}
|
||||
x.forEach(v => {
|
||||
url(v);
|
||||
el.appendChild(v);
|
||||
});
|
||||
|
||||
|
@ -96,7 +97,7 @@
|
|||
tot = parseInt(tot);
|
||||
let d = document.createElement('div');
|
||||
d.classList.add('pagexx');
|
||||
d.style.cssText = 'text-align: center;';
|
||||
d.style.cssText = 'text-align: center;margin:5px 0 2px';
|
||||
let a = document.createElement('a');
|
||||
a.href = 'javascript:void(0)';
|
||||
a.innerText = '<';
|
||||
|
@ -250,12 +251,87 @@
|
|||
}
|
||||
}
|
||||
|
||||
function url(li) {
|
||||
let as = li.querySelectorAll('a');
|
||||
as.forEach(a => {
|
||||
let src = a.href;
|
||||
if (src.search(/(fr=share)|(client_type=2)/) > -1) {
|
||||
|
||||
let href = src.match(/(https?:\/\/tieba\.baidu\.com\/p\/\d+)/);
|
||||
if (href && href.length > 0) {
|
||||
a.href = href[1];
|
||||
a.innerText = a.href;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
$("ul#pblist>li").forEach(function (e, iii) {
|
||||
f(e);
|
||||
if (iii === 0) {
|
||||
let ff = f(e);
|
||||
if (ff === 1) {
|
||||
ab(e);
|
||||
}
|
||||
let videos = e.querySelectorAll('.video');
|
||||
|
@ -266,6 +342,7 @@
|
|||
video.outerHTML = `<video poster="${img.src}" src="${src}" controls="controls" style="max-width:100%;min-width:100%"></video>`;
|
||||
});
|
||||
}
|
||||
url(e);
|
||||
delElement(['#diversBanner', '.j_videoFootDownBtn']);
|
||||
gif(e);
|
||||
jpg(e);
|
||||
|
@ -292,52 +369,108 @@
|
|||
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');
|
||||
$.get(url, function (rst) {
|
||||
replayPage({data: {floor_html: rst}}, el, ls => {
|
||||
ls.splice(0, 2)
|
||||
if (num <= 8) {
|
||||
$.get(url, function (rst) {
|
||||
replayPage({data: {floor_html: rst}}, el, ls => {
|
||||
ls.splice(0, 2)
|
||||
that.parentNode.removeChild(that);
|
||||
});
|
||||
});
|
||||
if (num <= 8) {
|
||||
that.parentNode.removeChild(that);
|
||||
} else {
|
||||
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 > 20) {
|
||||
if (orgnum > 10) {
|
||||
a.style.display = 'none';
|
||||
tpage(tot, el, (page) => {
|
||||
if (a.style.display !== 'none') {
|
||||
a.style.display = 'none';
|
||||
}
|
||||
let url = `/mo/q//flr?fpn=${page}&kz=${kz}&pid=${tid}&is_ajax=1&has_url_param=0&template=lzl`;
|
||||
$.get(url, res => {
|
||||
replayPage(res, el);
|
||||
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)
|
||||
});
|
||||
if (num <= 8) {
|
||||
that.parentNode.removeChild(that);
|
||||
} else {
|
||||
num -= 8;
|
||||
that.innerText = `还有${num}条回复`;
|
||||
if (orgnum > 18) {
|
||||
a.style.display = 'none';
|
||||
tpage(tot, el, (page) => {
|
||||
if (a.style.display !== 'none') {
|
||||
a.style.display = 'none';
|
||||
}
|
||||
let url = `/mo/q//flr?fpn=${page}&kz=${kz}&pid=${tid}&is_ajax=1&has_url_param=0&template=lzl`;
|
||||
$.get(url, res => {
|
||||
replayPage(res, el);
|
||||
let l = lo(document, el);
|
||||
window.scrollTo({top: l.top - 20, left: 0, behavior: "smooth"});
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
} 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);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -348,28 +481,50 @@
|
|||
function lz() {
|
||||
let lz = document.querySelector('span.poster_only');
|
||||
if (lz) {
|
||||
let r = document.createElement('span');
|
||||
r.classList.add('poster_only');
|
||||
r.style.marginLeft = '5px';
|
||||
r.innerText = '倒序看帖';
|
||||
lz.parentNode.insertBefore(r, lz);
|
||||
|
||||
lz.onclick = null;
|
||||
let h = location.href;
|
||||
let ff = 0;
|
||||
let rr = 0;
|
||||
if (h.indexOf('see_lz=1') > -1) {
|
||||
lz.textContent = '取消只看楼主';
|
||||
h = h.replace('see_lz=1', 'see_lz=0');
|
||||
ff = 1;
|
||||
}
|
||||
lz.addEventListener('click', () => {
|
||||
if (h.indexOf('r=1') > -1) {
|
||||
r.textContent = '取消倒序看帖';
|
||||
h = h.replace('r=1', 'r=0');
|
||||
rr = 1;
|
||||
}
|
||||
|
||||
r.addEventListener('click', (e) => {
|
||||
if (rr === 0) {
|
||||
h = h.indexOf('?') < 0 ? h + '?r=1' : (h[h.length - 1] === '&' ? (h + 'r=1&') : (h + '&r=1'));
|
||||
h = h.replace(/pn=\d+/, 'pn=' + (totalPage - 1) * 30);
|
||||
}
|
||||
location.href = h;
|
||||
e.stopPropagation();
|
||||
}, true);
|
||||
lz.addEventListener('click', (e) => {
|
||||
if (ff === 0) {
|
||||
h = h.indexOf('?') < 0 ? h + '?see_lz=1' : h + '&see_lz=1';
|
||||
}
|
||||
location.href = h;
|
||||
|
||||
});
|
||||
e.stopPropagation();
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
|
||||
function f(value) {
|
||||
let dt = JSON.parse(value.getAttribute('data-info'));
|
||||
let fl = 0;
|
||||
if (dt) {
|
||||
let fl = dt.floor_num;
|
||||
fl = dt.floor_num;
|
||||
let l = document.createElement('span');
|
||||
l.style.color = 'green';
|
||||
l.textContent = fl + '楼';
|
||||
|
@ -382,6 +537,7 @@
|
|||
}
|
||||
value.querySelector('.list_item_time').parentNode.appendChild(l);
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
|
||||
function check() {
|
||||
|
@ -542,10 +698,7 @@
|
|||
a.classList.remove('tl_shadow_for_app');
|
||||
})
|
||||
}
|
||||
|
||||
createTime();
|
||||
|
||||
|
||||
let list = document.querySelector('#tlist');
|
||||
let MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
|
||||
let observer = new MutationObserver((mutations) => {
|
||||
|
@ -806,17 +959,23 @@
|
|||
window.conxx = conf;
|
||||
window.xxLL = null;
|
||||
|
||||
let pa = document.querySelector('#list_pager');
|
||||
pa.parentNode.removeChild(pa);
|
||||
F.use('spb/widget/normal_post_list', function (threadList) {
|
||||
if (!window.xxLL) {
|
||||
window.xxLL = new threadList(conf)
|
||||
}
|
||||
window.totalPage = xxLL.pager._conf.totalPage;
|
||||
if (location.href.indexOf('r=1') > -1) {
|
||||
xxLL.pager._conf.url += '&r=1';
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelectorAll('.j_nreply_btn').forEach(value => {
|
||||
value.addEventListener('click', evt => {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
F.use('spb/widget/normal_post_list', function (threadList) {
|
||||
if (!window.xxLL) {
|
||||
window.xxLL = new threadList(conf)
|
||||
}
|
||||
window.xxLL.floorReply(evt);
|
||||
});
|
||||
|
||||
window.xxLL.floorReply(evt);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -858,9 +1017,13 @@
|
|||
f = f === 1 ? 2 : 1;
|
||||
}
|
||||
|
||||
let flag = 0;
|
||||
function drop(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
if (!flag) {
|
||||
return;
|
||||
}
|
||||
let touches = e.touches[0];
|
||||
let svg = d;
|
||||
endX = sx - touches.clientX - Math.ceil(svg.offsetWidth / 2);
|
||||
|
@ -885,25 +1048,22 @@
|
|||
value.style.display = 'none';
|
||||
} else {
|
||||
value.addEventListener('touchstart', ev => {
|
||||
startX = ev.touches[0].clientX - (value.offsetLeft ? value.offsetLeft : 0);
|
||||
startY = ev.touches[0].clientY - (value.offsetTop ? value.offsetTop : 0);
|
||||
startX = ev.touches[0].clientX - d.offsetLeft;
|
||||
startY = ev.touches[0].clientY - d.offsetLeft;
|
||||
timer = setTimeout(() => {
|
||||
//value.style.touchAction='none';
|
||||
value.style.fill = 'rgba(210,74,195,0.3)';
|
||||
value.addEventListener('touchmove', drop, {
|
||||
passive: false
|
||||
});
|
||||
flag = 1;
|
||||
}, 600);
|
||||
});
|
||||
value.addEventListener('touchmove', drop, {
|
||||
passive: false
|
||||
});
|
||||
value.addEventListener('touchend', ev => {
|
||||
clearTimeout(timer);
|
||||
localStorage.setItem('tiebaPageX', endX);
|
||||
localStorage.setItem('tiebaPageY', endY);
|
||||
value.style.fill = 'rgba(77, 74, 210,.3)';
|
||||
//value.style.touchAction='default';
|
||||
//document.querySelector('body').style.touchAction=null;
|
||||
//console.log('end');
|
||||
value.removeEventListener('touchmove', drop);
|
||||
flag = 0;
|
||||
})
|
||||
}
|
||||
value.style.fill = 'rgba(77, 74, 210,.3)';
|
||||
|
@ -941,9 +1101,16 @@
|
|||
css.textContent = `
|
||||
.class_hide_flag{display:block!important;}.father-cut-pager-class-no-page>#list_pager{visibility: visible!important;height: 44px!important;}#glob,body{margin-top: 0px!important;}.father_cut_list_class{padding-bottom: 0px!important;}.father-cut-recommend-normal-box,.father-cut-daoliu-normal-box,.fixed_bar,.pb,.frs,.no_mean,.addbodybottom,.img_desc,.top-guide-wrap,.open-style,.index-feed-cards .hot-topic,.appPromote_wrapper,.ui_image_header_bottom,.videoFooter,#diversBanner,.tb-footer-wrap,.interest-bar,.footer-wrap,.client-btn,.daoliu{display:none!important;}.tl_shadow:not([data-tid]),#pblist>li:not([data-tid]){display:none!important;}.navbar-view{top:24px!important;}.navbar-box{top:44px!important;}
|
||||
.footer_logo,.footer-version { display:none!important}
|
||||
.fr_list .list_item_floor { padding-top:6px;}
|
||||
.floor_footer_item .user_name { color:#125bc7; }
|
||||
.floor_content a { color:#498bef; }
|
||||
.fr_list .list_item_floor { padding-top: 8px;
|
||||
letter-spacing: 1px;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 2px
|
||||
border: 1px solid rgba(0,0,0,.1);
|
||||
box-shadow: 5px 5px 5px rgba(0,0,0,0.2);}
|
||||
.floor_footer_item .user_name,.floor_footer_item .user_name:visited { color:#125bc7; }
|
||||
.floor_content a,.floor_content a:visited { color:#498bef; }
|
||||
.fr_list .list_item_floor:nth-child(odd){ background-color:rgba(180, 228, 207, 0.2); }
|
||||
.fr_list .list_item_floor:nth-child(even){ background-color:rgba(168, 191, 157, 0.16); }
|
||||
`;
|
||||
document.querySelector('head').append(css);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user