添加部分url

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

View File

@ -1,15 +1,20 @@
// ==UserScript==
// @name tieba page
// @namespace http://tampermonkey.net/
// @version 0.52
// @version 0.53
// @author fthvgb1
// @match https://tieba.baidu.com/*
// @grant unsafeWindow
// @grant none
// @description 显示手机版贴吧里被隐藏的楼层与翻页按钮
// ==/UserScript==
function t() {
(function () {
'use strict';
function t() {
lz();
$("ul#pblist>li").forEach(function (e) {
f(e);
@ -18,7 +23,7 @@ function t() {
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+)\&/);
var kz = x[0].href.match(/tid=(\d+)&/);
kz = kz[1];
}
@ -39,17 +44,14 @@ function t() {
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('</a>', ':</a>');
var s = li.querySelector('.content span');
@ -122,9 +124,9 @@ function t() {
}
});
}
}
function lz() {
function lz() {
var lz = document.querySelector('span.poster_only');
if (lz) {
lz.onclick = null;
@ -132,10 +134,10 @@ function lz() {
var ff = 0;
if (h.indexOf('see_lz=1') > -1) {
lz.textContent = '取消只看楼主';
h = h.replace('see_lz=1', 'see_lz=0')
h = h.replace('see_lz=1', 'see_lz=0');
ff = 1;
}
lz.addEventListener('click', evt => {
lz.addEventListener('click', () => {
if (ff === 0) {
h = h.indexOf('?') < 0 ? h + '?see_lz=1' : h + '&see_lz=1';
@ -144,9 +146,9 @@ function lz() {
});
}
}
}
function f(value) {
function f(value) {
var dt = JSON.parse(value.getAttribute('data-info'));
if (dt) {
var fl = dt.floor_num;
@ -162,46 +164,46 @@ function f(value) {
}
value.querySelector('.list_item_time').parentNode.appendChild(l);
}
}
}
function check() {
let userAgentInfo = navigator.userAgent;
let Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
let flag = 0;
for (let v = 0; v < Agents.length; v++) {
function check() {
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
var flag = 0;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > -1) {
flag = 1;
break;
}
}
return flag;
}
}
function list() {
function list() {
[
'.frs_daoliu_for_app', '.tl_shadow_for_app_modle', '.footer_logo', '.footer_link_highlight'
].forEach(value => {
let x = document.querySelector(value);
var x = document.querySelector(value);
if (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) {
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 => {
//v.classList.remove('tl_shadow_for_app');
let a = v.querySelector('a.j_enter_for_app');
let tid = v.getAttribute('data-tid');
var a = v.querySelector('a.j_enter_for_app');
var tid = v.getAttribute('data-tid');
a.href = url.replace(/\/(\d+)\?/.exec(url)[1], tid);
a.classList.remove('tl_shadow_for_app');
})
}
}
}
function detail() {
function detail() {
document.querySelectorAll('ul#pblist>li').forEach(value => {
if (value.classList.contains('class_hide_flag')) {
value.classList.remove('class_hide_flag');
@ -230,18 +232,17 @@ function detail() {
$('.j_pager_input').blur(() => {
setTimeout(t, 3000);
})
}
}
(function () {
'use strict';
let url = location.href;
if (check()) {
var url = location.href;
if (/\/p\/\d+/.test(url)) {
if (/\/p\/\d+/.test(url) || /\/mo\/(.*)\/m\?kz=\d+/.test(url)) {
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();
}
}
})();