From 37cf14b5e377e9f94b8db61c389fca178ce50921 Mon Sep 17 00:00:00 2001 From: xing Date: Wed, 6 May 2020 11:07:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=80=92=E5=BA=8F=E7=9C=8B=E5=B8=96=EF=BC=8C?= =?UTF-8?q?=E5=A4=84=E7=90=86app=E5=88=86=E4=BA=AB=E7=9A=84url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tieba page.js | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/tieba page.js b/tieba page.js index 1daeeab..e828ee7 100644 --- a/tieba page.js +++ b/tieba page.js @@ -1,7 +1,7 @@ // ==UserScript== // @name tieba page // @namespace https://github.com/fthvgb1/tampermonkey-script -// @version 1.002 +// @version 1.003 // @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); }); @@ -250,6 +251,20 @@ } } + 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.length > 0) { + a.href = href[1]; + a.innerText = a.href; + } + } + }) + } + function t() { lz(); @@ -266,6 +281,7 @@ video.outerHTML = ``; }); } + url(e); delElement(['#diversBanner', '.j_videoFootDownBtn']); gif(e); jpg(e); @@ -348,21 +364,41 @@ 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')); + } + 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); } }