添加部分url

This commit is contained in:
fthvgb1 2020-02-20 15:02:06 +08:00
parent 0d4166cacc
commit c794a4543c

View File

@ -1,14 +1,19 @@
// ==UserScript== // ==UserScript==
// @name tieba page // @name tieba page
// @namespace http://tampermonkey.net/ // @namespace http://tampermonkey.net/
// @version 0.52 // @version 0.53
// @author fthvgb1 // @author fthvgb1
// @match https://tieba.baidu.com/* // @match https://tieba.baidu.com/*
// @grant unsafeWindow // @grant none
// @description 显示手机版贴吧里被隐藏的楼层与翻页按钮 // @description 显示手机版贴吧里被隐藏的楼层与翻页按钮
// ==/UserScript== // ==/UserScript==
(function () {
'use strict';
function t() { function t() {
lz(); lz();
$("ul#pblist>li").forEach(function (e) { $("ul#pblist>li").forEach(function (e) {
@ -18,7 +23,7 @@ function t() {
var content = ee.find(".list_item_top"); var content = ee.find(".list_item_top");
var x = ee.find('.list_item_top a.j_report_btn'); var x = ee.find('.list_item_top a.j_report_btn');
if (x && x.length > 0) { if (x && x.length > 0) {
var kz = x[0].href.match(/tid=(\d+)\&/); var kz = x[0].href.match(/tid=(\d+)&/);
kz = kz[1]; kz = kz[1];
} }
@ -39,17 +44,14 @@ function t() {
if (num === orgnum) { if (num === orgnum) {
var url = this.getAttribute('data-url'); var url = this.getAttribute('data-url');
//console.log();
$.get(url, function (rst) { $.get(url, function (rst) {
var dom = (new DOMParser()).parseFromString(rst, 'text/html'); var dom = (new DOMParser()).parseFromString(rst, 'text/html');
var r = dom.querySelector('.j_floor_panel'); var r = dom.querySelector('.j_floor_panel');
var lii = r.querySelectorAll('li'); var lii = r.querySelectorAll('li');
lii.forEach(function (li, index) { lii.forEach(function (li, index) {
//console.log(li.className)
if (index < 2) { if (index < 2) {
return; return;
} }
var username = li.querySelector('.left>div .user_name').outerHTML; var username = li.querySelector('.left>div .user_name').outerHTML;
username = username.replace('</a>', ':</a>'); username = username.replace('</a>', ':</a>');
var s = li.querySelector('.content span'); var s = li.querySelector('.content span');
@ -132,10 +134,10 @@ function lz() {
var ff = 0; var ff = 0;
if (h.indexOf('see_lz=1') > -1) { if (h.indexOf('see_lz=1') > -1) {
lz.textContent = '取消只看楼主'; lz.textContent = '取消只看楼主';
h = h.replace('see_lz=1', 'see_lz=0') h = h.replace('see_lz=1', 'see_lz=0');
ff = 1; ff = 1;
} }
lz.addEventListener('click', evt => { lz.addEventListener('click', () => {
if (ff === 0) { if (ff === 0) {
h = h.indexOf('?') < 0 ? h + '?see_lz=1' : h + '&see_lz=1'; h = h.indexOf('?') < 0 ? h + '?see_lz=1' : h + '&see_lz=1';
@ -165,10 +167,10 @@ function f(value) {
} }
function check() { function check() {
let userAgentInfo = navigator.userAgent; var userAgentInfo = navigator.userAgent;
let Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
let flag = 0; var flag = 0;
for (let v = 0; v < Agents.length; v++) { for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > -1) { if (userAgentInfo.indexOf(Agents[v]) > -1) {
flag = 1; flag = 1;
break; break;
@ -181,18 +183,18 @@ function list() {
[ [
'.frs_daoliu_for_app', '.tl_shadow_for_app_modle', '.footer_logo', '.footer_link_highlight' '.frs_daoliu_for_app', '.tl_shadow_for_app_modle', '.footer_logo', '.footer_link_highlight'
].forEach(value => { ].forEach(value => {
let x = document.querySelector(value); var x = document.querySelector(value);
if (x) { if (x) {
x.parentNode.removeChild(x) x.parentNode.removeChild(x)
} }
}); });
let ads = document.querySelectorAll('li.tl_shadow_for_app'); var ads = document.querySelectorAll('li.tl_shadow_for_app');
if (ads.length > 0) { if (ads.length > 0) {
let url = document.querySelector('.tl_shadow_for_app').parentNode.querySelector('a.j_common').href; var url = document.querySelector('.tl_shadow_for_app').parentNode.querySelector('a.j_common').href;
ads.forEach(v => { ads.forEach(v => {
//v.classList.remove('tl_shadow_for_app'); //v.classList.remove('tl_shadow_for_app');
let a = v.querySelector('a.j_enter_for_app'); var a = v.querySelector('a.j_enter_for_app');
let tid = v.getAttribute('data-tid'); var tid = v.getAttribute('data-tid');
a.href = url.replace(/\/(\d+)\?/.exec(url)[1], tid); a.href = url.replace(/\/(\d+)\?/.exec(url)[1], tid);
a.classList.remove('tl_shadow_for_app'); a.classList.remove('tl_shadow_for_app');
}) })
@ -232,16 +234,15 @@ function detail() {
}) })
} }
(function () { if (check()) {
'use strict'; var url = location.href;
let url = location.href;
if (/\/p\/\d+/.test(url)) { if (/\/p\/\d+/.test(url) || /\/mo\/(.*)\/m\?kz=\d+/.test(url)) {
detail(); detail();
} }
if (/f\?kw=.+/.test(url) || /mo\/q\/m\?word=.+/.test(url)) { if (/f\?kw=.+/.test(url) || /mo\/q\/m\?word=.+/.test(url) || /\/mo\/(.*)\/m\?kw=/.test(url)) {
list(); list();
} }
}
})(); })();