Greasy Fork is available in English.
替代贴吧APP,需要配合user-agent switcher 切换成PC模式
当前为
// ==UserScript==
// @name 贴吧手机版
// @namespace https://space.bilibili.com/8286319
// @version 1.2
// @description 替代贴吧APP,需要配合user-agent switcher 切换成PC模式
// @author happmaoo
// @match https://tieba.baidu.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=baidu.com
// @grant GM_addStyle
// ==/UserScript==
function viewport() {
if (document.querySelector('meta[name="viewport"]')) {
return;
}
const el = document.createElement("meta");
el.name = "viewport";
el.content = "width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no";
document.head.append(el);
}
(function() {
'use strict';
// Your code here...
viewport();
var mycss2 = `
.u_ddl,.j-placeholder-pay-member,.p_share_ding,#d_post_manage,.j_clear_fullscreen,.dialogJmodal,.tbshare_popup_wrapper,.ui_bubble_wrap,.footer,.homeworks_guide,.tbui_aside_smiley,.ip-location,.p_mtail,.lzl_more,.replace_tip,.poster_head,.d_badge_title,.d_badge_lv,.threadlist_detail>.threadlist_author,.head_content,.share_btn_wrapper,.icon-jubao,.user-hide-post-down,.right_section,.suggestion_list,.search_top,#fixed_bar,.aside,.nav_wrap,.card_banner,.card_top_wrap{display:none!important;}
ul,li{list-style-type:none;padding:0px;margin:0;}
.aaaa{padding:0px!important;margin:0!important;width:auto!important;margin:0!important;}
.userbar ul li{float: left;}
.userbar {overflow: hidden;display: block;clear: both;}
.u_notity_bd ul li{float: left; margin:0 5px 0 0;}
.u_ddl{display:none;}
.search_ipt{width:100px!important;}
.search_logo::before {
content: "贴吧";
color: #4CAF50;
float: left;
display: block;
width: 40px;
height: 20px;
}
.search_btn{margin:0 5px;}
/* 列表 */
#thread_list{padding:0px;}
.threadlist_video{display:none!important;}
.threadlist_author{float:right;font-size:14px;color:#777!important;}
.threadlist_author a{font-size:14px;color:#777!important;}
.threadlist_media li,.col2_left{float:left;}
.threadlist_rep_num{background: #02b23e;color: #f4f4f4;border-radius: 5px;padding:2px 5px;margin-right:5px;font-size:14px;font-family: sans-serif;font-weight: bold;}
.j_thread_list{background:#fff;overflow:hidden;margin:0 0 10px 0;}
.j_thread_list a{text-decoration:none;color:#222;}
.threadlist_text {
display: -webkit-box;
font-size: 14px;
color: #999;
max-height: 100px;
text-indent: 2em;
overflow: hidden;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
}
.jump_input_bright{width:30px;}
.pb_content h1,.pb_content h3{font-size:20px;width:auto!important;}
/* 回复相关 */
.d_post_content_main{padding-left:10px;display:block;overflow: auto;flex: 0.9;}
.d_post_content img{max-width:300px;height:auto;}
.core_reply_content{background:#fff;margin-left:20px;padding:5px 10px;font-size:14px!important;}
.core_reply_content .j_user_card img{display:none;}
.p_author img{width:30px;height:auto;}
.lzl_jb{width:0;height:0;}
.core_reply_tail ul,.p_reply{float:left;font-size:12px;color:#aaa;}
.core_reply_tail .p_tail li{float:left;}
.core_reply_content a,.core_reply_tail a{}
.d_name a{text-decoration:none;font-size:14px;}
.p_author{float:left;}
.l_post{background:#fff;overflow:hidden;border-bottom: 1px solid #aaa;margin: 10px 0;padding-bottom:10px;}
.post-tail-wrap,.post-tail-wrap a{font-size:12px;color:#aaa;}
.l_post .d_author{display:block;width:60px;font-size:14px;line-break: anywhere;flex: 0.1;border-right: 1px solid #ccc;}
.lzl_jb{display:none!important;}
/* 编辑器相关 */
.edui-popup{display:block;background:#eee;border: 1px solid #aaa;padding:20px;}
.edui-btn-image{}
.edui-btn-image::before {
content: "图";
color:#fff;
text-align: center;
display:block;width:30px;height:30px;background:#4CAF50;
font-size: 14px; /* 设置字体大小 */
}
.next_step{display:block;width:100px;line-height:2em;background:#ccc;text-align: center;}
.slide_item{float:left;display:none;}
.j_ok {
position: fixed; /* 设置为固定定位 */
left: 0; /* 距离左边 0 像素 */
bottom: 0; /* 距离底部 0 像素 */
background-color: rgba(0, 0, 0, 0.7); /* 背景颜色 */
color: white; /* 字体颜色 */
padding: 10px; /* 内边距 */
}
.i_item_bg{width:60px;height:60px;}
.flash_editor_container,.error{display:none;}
.edui-container .BDE_Image{width:100px!important;height:auto!important;}
#ueditor_replace{width:350px!important;}
.edui-container{width:350px!important;}
.dialogJbody{height:250px!important;}
.poster_submit{margin:5px;display:block;padding:5px;width:100px;background:#eee;text-align: center;font-size: 16px;text-decoration:none;}
.poster_submit em{color:#000;font-style: normal!important;}
.edui-editor-body{border: 1px solid #aaa;width:auto;}
.dialogJcontent img{background-size: contain;}
/* reply 回复楼中楼 */
.core_reply_content{
max-height:200px;
overflow: hidden;
}
.core_reply_content:hover{
overflow: auto; /* 鼠标悬停时显示内容 */
}
.editor_for_container{background:#fff;}
.lzl_panel_submit{margin:5px;display:block;padding:5px;width:50px;background:#eee;text-align: center;font-size: 16px;text-decoration:none;}
.core_reply_tail{clear:both; display: block; overflow: hidden;}
.post-tail-wrap span{float:left;}
video{max-width:300px;}
.l_post{
display: flex;
flex-direction: row;
}
.BDE_Image{width:auto!important;}
.test{background:#0f0;}
/* 翻页 */
.pagination-default span,.pagination-default a{float:left;margin-left:5px;display:block;padding:2px 5px;background:#eee;}
.pagination-default{clear:both;overflow: hidden;}
.pb_list_pager span,.pb_list_pager a{float:left;margin:5px 0 5px 5px;display:block;padding:2px 5px;background:#eee;}
.art-poster,.art-subtitle,.art-danmuku,.art-layers,.art-mask,.art-bottom,.art-loading,.art-notice,.art-info,.art-mini-header,.art-contextmenus{display:none;}
/* 消息页面 https://tieba.baidu.com/i/i/replyme */
.sub_tab_content{margin: 10px 0;}
.feed ul li{margin:0 0 20px 0;padding:5px;border: 1px solid #aaa;clear: both;background:#eee;color: #aaa;font-size: 14px;}
.feed ul li a{color: #aaa;}
.replyme_content,.replyme_content a{color:#000!important;text-decoration:none;font-size: 16px;}
.sub_tab_content li,.tab_content li{float:left;margin-right:5px;}
/* 搜索页面 */
.s_aside{display:none;}
.s_post_list{margin:10px 0 10px 0;}
.s_post{margin:0px 0 20px 0;font-size:14px;}
.s_post_list .p_content{padding:5px;background:#f5f5f5;}
.pager-search span,.pager-search a{float:left;margin:5px 0 5px 5px;display:block;padding:2px 5px;background:#eee;}
`;
$('link[rel="stylesheet"], style').remove();
GM_addStyle(mycss2);
/* 顶部我的消息 */
$('.userbar ul li').not('.u_username, .u_news').hide();
$('.u_news_wrap').attr('href', 'https://tieba.baidu.com/i/sys/jump?type=replyme');
$('.u_news_wrap').attr('onclick', '');
$('.u_news_wrap').attr('target', '_blank');
/* 顶部 吧内搜索 */
var keyword = $('input[name="kw1"]').val();
var mysearch = `
<form class="search-form" action="https://tieba.baidu.com/f/search/res" method="GET" target="_blank">
<input type="hidden" name="ie" value="utf-8">
<input type="hidden" name="kw" value="${keyword}">
<input type="text" size="15" name="qw" placeholder="吧内搜贴" required>
<button type="submit">搜贴</button>
</form>
`;
$(".content").before(mysearch);
// 每 1 秒执行一次
setInterval(function() {
// 插入图片相关
$('html').css({
'overflow': '', // 清除 overflow 样式
'padding-right': '' // 清除 padding-right 样式
});
$('.dialogJfix').css({
'position': 'fixed',
'padding': '20px', // 清除 overflow 样式
'left': '10px',
'width': '280px',
'border': '1px solid #aaa',
'background': '#eee' // 清除 padding-right 样式
});
// 查找内容为 "广告" 的 span
$('span').filter(function() {
return $(this).text().trim() === '广告';
}).each(function() {
$(this).parent().html('ad1');
});
$('.l_post[data-field="{}"]').remove();
/* 视频相关 */
$('video').each(function() {
$(this).attr('controls', true);
$(this).removeAttr('autoplay');
});
//$('video').remove();
$('#thread_list>div').remove();
$('.p_postlist').children().not('.l_post, .p_postlist').html('ad2');
}, 1000);
$('.poster_submit').on('click', function() {
$(this).css('background-color', '#aaa');
setTimeout(() => {
$(this).css('background-color', '#eee');
}, 1000);
});
// 贴吧主页
if (window.location.href === 'https://tieba.baidu.com/' || window.location.href === 'https://tieba.baidu.com/index.html') {
var mycssindex = `
html{padding:20px;}
a{margin-right:10px;}
`;
GM_addStyle(mycssindex);
$('img').remove();
// 获取 ID 为 likeforumwraper 的元素的 HTML 内容
var newContent = $('.left-sec').html();
// 替换整个 body 的内容
$('body').html(newContent);
} else {
}
})();
/*
备份
// 去掉详情页的帖子广告
var nodes = document.querySelectorAll('.l_post');
nodes.forEach(function(node){
if(node.classList.length > 4) {
node.remove();
}
});
*/